Skip to content

Commit 3f39fbf

Browse files
committed
fix message response
1 parent f2d1fb2 commit 3f39fbf

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

internal/command/command_plugin.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ func (cp *CommandPlugin) monitorSubscribeChannel(ctx context.Context) {
260260
if cp.commandServerType != model.Command {
261261
slog.WarnContext(newCtx, "Auxiliary command server can not perform config apply",
262262
"command_server_type", cp.commandServerType.String())
263-
cp.handleInvalidRequest(newCtx, message)
263+
cp.handleInvalidRequest(newCtx, message, "Config apply failed")
264264

265265
return
266266
}
@@ -273,7 +273,7 @@ func (cp *CommandPlugin) monitorSubscribeChannel(ctx context.Context) {
273273
if cp.commandServerType != model.Command {
274274
slog.WarnContext(newCtx, "Auxiliary command server can not perform api action",
275275
"command_server_type", cp.commandServerType.String())
276-
cp.handleInvalidRequest(newCtx, message)
276+
cp.handleInvalidRequest(newCtx, message, "API action failed")
277277

278278
return
279279
}
@@ -365,15 +365,17 @@ func (cp *CommandPlugin) handleHealthRequest(newCtx context.Context) {
365365
cp.messagePipe.Process(newCtx, &bus.Message{Topic: bus.DataPlaneHealthRequestTopic})
366366
}
367367

368-
func (cp *CommandPlugin) handleInvalidRequest(ctx context.Context, message *mpi.ManagementPlaneRequest) {
368+
func (cp *CommandPlugin) handleInvalidRequest(ctx context.Context,
369+
request *mpi.ManagementPlaneRequest, message string,
370+
) {
369371
err := cp.commandService.SendDataPlaneResponse(ctx, &mpi.DataPlaneResponse{
370-
MessageMeta: message.GetMessageMeta(),
372+
MessageMeta: request.GetMessageMeta(),
371373
CommandResponse: &mpi.CommandResponse{
372374
Status: mpi.CommandResponse_COMMAND_STATUS_FAILURE,
373-
Message: "Can not perform write action as auxiliary command server",
374-
Error: "request not allowed",
375+
Message: message,
376+
Error: "Can not perform write action as auxiliary command server",
375377
},
376-
InstanceId: message.GetActionRequest().GetInstanceId(),
378+
InstanceId: request.GetActionRequest().GetInstanceId(),
377379
})
378380
if err != nil {
379381
slog.ErrorContext(ctx, "Unable to send data plane response", "error", err)

0 commit comments

Comments
 (0)