|
31 | 31 | UpdateDataPlaneStatus(ctx context.Context, resource *mpi.Resource) error |
32 | 32 | UpdateDataPlaneHealth(ctx context.Context, instanceHealths []*mpi.InstanceHealth) error |
33 | 33 | SendDataPlaneResponse(ctx context.Context, response *mpi.DataPlaneResponse) error |
34 | | - UpdateClient(client mpi.CommandServiceClient) |
| 34 | + UpdateClient(ctx context.Context, client mpi.CommandServiceClient) error |
35 | 35 | Subscribe(ctx context.Context) |
36 | 36 | IsConnected() bool |
37 | 37 | CreateConnection(ctx context.Context, resource *mpi.Resource) (*mpi.CreateConnectionResponse, error) |
@@ -68,7 +68,7 @@ func (cp *CommandPlugin) Init(ctx context.Context, messagePipe bus.MessagePipeIn |
68 | 68 | } |
69 | 69 |
|
70 | 70 | func (cp *CommandPlugin) Close(ctx context.Context) error { |
71 | | - slog.InfoContext(ctx, "Canceling subscribe context") |
| 71 | + slog.InfoContext(ctx, "Closing command plugin") |
72 | 72 |
|
73 | 73 | cp.subscribeMutex.Lock() |
74 | 74 | if cp.subscribeCancel != nil { |
@@ -178,12 +178,16 @@ func (cp *CommandPlugin) processDataPlaneResponse(ctx context.Context, msg *bus. |
178 | 178 | func (cp *CommandPlugin) processConnectionReset(ctx context.Context, msg *bus.Message) { |
179 | 179 | slog.DebugContext(ctx, "Command plugin received connection reset") |
180 | 180 | if newConnection, ok := msg.Data.(grpc.GrpcConnectionInterface); ok { |
181 | | - err := cp.conn.Close(ctx) |
182 | | - if err != nil { |
183 | | - slog.ErrorContext(ctx, "Command plugin: unable to close connection", "error", err) |
| 181 | + connectionErr := cp.conn.Close(ctx) |
| 182 | + if connectionErr != nil { |
| 183 | + slog.ErrorContext(ctx, "Command plugin: unable to close connection", "error", connectionErr) |
184 | 184 | } |
185 | 185 | cp.conn = newConnection |
186 | | - cp.commandService.UpdateClient(cp.conn.CommandServiceClient()) |
| 186 | + err := cp.commandService.UpdateClient(ctx, cp.conn.CommandServiceClient()) |
| 187 | + if err != nil { |
| 188 | + slog.ErrorContext(ctx, "Failed to reset connection", "error", err) |
| 189 | + return |
| 190 | + } |
187 | 191 | slog.DebugContext(ctx, "Command service client reset successfully") |
188 | 192 | } |
189 | 193 | } |
|
0 commit comments