Skip to content

Commit 40cd06c

Browse files
committed
PR feedback: disable watcher during config apply
1 parent 562c312 commit 40cd06c

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

internal/command/command_plugin.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,6 @@ func (cp *CommandPlugin) processDataPlaneResponse(ctx context.Context, msg *bus.
178178
func (cp *CommandPlugin) processConnectionReset(ctx context.Context, msg *bus.Message) {
179179
slog.DebugContext(ctx, "Command plugin received connection reset")
180180
if newConnection, ok := msg.Data.(grpc.GrpcConnectionInterface); ok {
181-
if !cp.commandService.IsConnected() {
182-
slog.DebugContext(ctx, "Command plugin: service is not connected")
183-
return
184-
}
185181
err := cp.conn.Close(ctx)
186182
if err != nil {
187183
slog.ErrorContext(ctx, "Command plugin: unable to close connection", "error", err)

internal/command/command_service_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ func TestCommandService_UpdateClient(t *testing.T) {
207207
make(chan *mpi.ManagementPlaneRequest),
208208
)
209209
commandService.UpdateClient(commandServiceClient)
210-
assert.NotNil(t, commandServiceClient)
210+
assert.NotNil(t, commandService.commandServiceClient)
211211
}
212212

213213
func TestCommandService_UpdateDataPlaneHealth(t *testing.T) {

internal/watcher/watcher_plugin.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ type (
6161
ctx context.Context,
6262
credentialUpdateChannel chan<- credentials.CredentialUpdateMessage,
6363
)
64+
SetEnabled(enabled bool)
6465
}
6566
)
6667

@@ -167,7 +168,10 @@ func (w *Watcher) handleConfigApplyRequest(ctx context.Context, msg *bus.Message
167168
instanceID := request.ConfigApplyRequest.GetOverview().GetConfigVersion().GetInstanceId()
168169

169170
w.instancesWithConfigApplyInProgress = append(w.instancesWithConfigApplyInProgress, instanceID)
171+
172+
slog.DebugContext(ctx, "Config Apply in progress: Disabling watchers...")
170173
w.fileWatcherService.SetEnabled(false)
174+
w.credentialWatcherService.SetEnabled(false)
171175
}
172176

173177
func (w *Watcher) handleConfigApplySuccess(ctx context.Context, msg *bus.Message) {
@@ -187,7 +191,10 @@ func (w *Watcher) handleConfigApplySuccess(ctx context.Context, msg *bus.Message
187191
return element == instanceID
188192
},
189193
)
194+
195+
slog.DebugContext(ctx, "Config Apply succeeded: re-enabling watchers...")
190196
w.fileWatcherService.SetEnabled(true)
197+
w.credentialWatcherService.SetEnabled(true)
191198

192199
w.instanceWatcherService.ReparseConfig(ctx, instanceID)
193200
}
@@ -215,7 +222,9 @@ func (w *Watcher) handleConfigApplyComplete(ctx context.Context, msg *bus.Messag
215222
return element == instanceID
216223
},
217224
)
225+
218226
w.fileWatcherService.SetEnabled(true)
227+
w.credentialWatcherService.SetEnabled(true)
219228
}
220229

221230
func (w *Watcher) handleCredentialUpdate(ctx context.Context) {

0 commit comments

Comments
 (0)