Skip to content

Commit e4dc0d2

Browse files
committed
fix tests
1 parent 262d353 commit e4dc0d2

File tree

2 files changed

+15
-21
lines changed

2 files changed

+15
-21
lines changed

internal/resource/resource_service.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,6 @@ func (r *ResourceService) ApplyConfig(ctx context.Context, instanceID string) (*
216216
return nginxConfigContext, nil
217217
}
218218

219-
func (r *ResourceService) ParseConfig(ctx context.Context, instance *mpi.Instance) (*model.NginxConfigContext, error) {
220-
slog.DebugContext(ctx, "Parsing NGINX instance config", "instance_id", instance.GetInstanceMeta().GetInstanceId())
221-
222-
nginxConfigContext, parseErr := r.nginxConfigParser.Parse(ctx, instance)
223-
if parseErr != nil {
224-
return nil, parseErr
225-
}
226-
227-
return nginxConfigContext, nil
228-
}
229-
230219
func (r *ResourceService) GetHTTPUpstreamServers(ctx context.Context, instance *mpi.Instance,
231220
upstream string,
232221
) ([]client.UpstreamServer, error) {

internal/watcher/instance/instance_watcher_service.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,23 +126,28 @@ func (iw *InstanceWatcherService) Watch(
126126
func (iw *InstanceWatcherService) ReparseConfigs(ctx context.Context) {
127127
slog.DebugContext(ctx, "Reparsing all instance configurations")
128128
for _, instance := range iw.instanceCache {
129+
nginxConfigContext := &model.NginxConfigContext{}
130+
var parseErr error
129131
slog.DebugContext(
130132
ctx,
131133
"Reparsing NGINX instance config",
132134
"instance_id", instance.GetInstanceMeta().GetInstanceId(),
133135
)
134136

135-
nginxConfigContext, parseErr := iw.nginxConfigParser.Parse(ctx, instance)
136-
if parseErr != nil {
137-
slog.WarnContext(
138-
ctx,
139-
"Failed to parse NGINX instance config",
140-
"config_path", instance.GetInstanceRuntime().GetConfigPath(),
141-
"instance_id", instance.GetInstanceMeta().GetInstanceId(),
142-
"error", parseErr,
143-
)
137+
if instance.GetInstanceMeta().GetInstanceType() == mpi.InstanceMeta_INSTANCE_TYPE_NGINX ||
138+
instance.GetInstanceMeta().GetInstanceType() == mpi.InstanceMeta_INSTANCE_TYPE_NGINX_PLUS {
139+
nginxConfigContext, parseErr = iw.nginxConfigParser.Parse(ctx, instance)
140+
if parseErr != nil {
141+
slog.WarnContext(
142+
ctx,
143+
"Failed to parse NGINX instance config",
144+
"config_path", instance.GetInstanceRuntime().GetConfigPath(),
145+
"instance_id", instance.GetInstanceMeta().GetInstanceId(),
146+
"error", parseErr,
147+
)
144148

145-
return
149+
return
150+
}
146151
}
147152

148153
iw.HandleNginxConfigContextUpdate(ctx, instance.GetInstanceMeta().GetInstanceId(), nginxConfigContext)

0 commit comments

Comments
 (0)