diff --git a/api/agent/director.proto b/api/agent/director.proto index dd6d00c9c0..1ee5eda203 100644 --- a/api/agent/director.proto +++ b/api/agent/director.proto @@ -23,6 +23,9 @@ service Director { // Retrieve Directives from the CEPC rpc Retrieve(Identity) returns (stream Directive) {} + // Reports the result of a command execution to the cloud + rpc ReportCommandResult(CommandResult) returns (CommandResultResponse) {} + rpc RetrieveSnapshot(Identity) returns (stream RawSnapshotChunk) {} } @@ -116,4 +119,13 @@ message RolloutCommand { ABORT = 2; } Action action = 3; + string command_id = 4; +} + +message CommandResult { + string command_id = 1; + bool success = 2; + string message = 3; } + +message CommandResultResponse {} diff --git a/pkg/agent/agent.go b/pkg/agent/agent.go index 0076baabb3..da78dd731e 100644 --- a/pkg/agent/agent.go +++ b/pkg/agent/agent.go @@ -26,6 +26,7 @@ const cloudConnectTokenKey = "CLOUD_CONNECT_TOKEN" type Comm interface { Close() error Report(context.Context, *agent.Snapshot, string) error + ReportCommandResult(context.Context, *agent.CommandResult) error Directives() <-chan *agent.Directive } diff --git a/pkg/agent/comm.go b/pkg/agent/comm.go index 01515836de..ed5521db50 100644 --- a/pkg/agent/comm.go +++ b/pkg/agent/comm.go @@ -119,6 +119,7 @@ func (c *RPCComm) retrieveLoop(ctx context.Context) { func (c *RPCComm) retrieve(ctx context.Context) error { stream, err := c.client.Retrieve(ctx, c.agentID) + if err != nil { return err } @@ -142,6 +143,14 @@ func (c *RPCComm) Close() error { return c.conn.Close() } +func (c *RPCComm) ReportCommandResult(ctx context.Context, result *agent.CommandResult) error { + _, err := c.client.ReportCommandResult(ctx, result, grpc.EmptyCallOption{}) + if err != nil { + return fmt.Errorf("ReportCommandResult error: %w", err) + } + return nil +} + func (c *RPCComm) Report(ctx context.Context, report *agent.Snapshot, apiKey string) error { select { case c.rptWake <- struct{}{}: diff --git a/pkg/agent/comm_internal_test.go b/pkg/agent/comm_internal_test.go index 22cb88eb77..4eedab7121 100644 --- a/pkg/agent/comm_internal_test.go +++ b/pkg/agent/comm_internal_test.go @@ -26,6 +26,10 @@ type MockClient struct { LastMetadata metadata.MD } +func (m *MockClient) ReportCommandResult(ctx context.Context, in *agent.CommandResult, opts ...grpc.CallOption) (*agent.CommandResultResponse, error) { + panic("implement me") +} + func (m *MockClient) Close() error { return nil } diff --git a/pkg/agent/directive_handler.go b/pkg/agent/directive_handler.go index b1a7cd9118..f27860a3e1 100644 --- a/pkg/agent/directive_handler.go +++ b/pkg/agent/directive_handler.go @@ -48,14 +48,14 @@ func (dh *BasicDirectiveHandler) HandleDirective(ctx context.Context, a *Agent, } if command.RolloutCommand != nil { - dh.handleRolloutCommand(ctx, command.RolloutCommand, dh.rolloutsGetterFactory) + dh.handleRolloutCommand(ctx, command.RolloutCommand, a) } } a.SetLastDirectiveID(ctx, directive.ID) } -func (dh *BasicDirectiveHandler) handleRolloutCommand(ctx context.Context, cmdSchema *agentapi.RolloutCommand, rolloutsGetterFactory rolloutsGetterFactory) { +func (dh *BasicDirectiveHandler) handleRolloutCommand(ctx context.Context, cmdSchema *agentapi.RolloutCommand, a *Agent) { if dh.rolloutsGetterFactory == nil { dlog.Warn(ctx, "Received rollout command but does not know how to talk to Argo Rollouts.") return @@ -64,6 +64,7 @@ func (dh *BasicDirectiveHandler) handleRolloutCommand(ctx context.Context, cmdSc rolloutName := cmdSchema.GetName() namespace := cmdSchema.GetNamespace() action := int32(cmdSchema.GetAction()) + commandID := cmdSchema.GetCommandId() if rolloutName == "" { dlog.Warn(ctx, "Rollout command received without a rollout name.") @@ -75,13 +76,31 @@ func (dh *BasicDirectiveHandler) handleRolloutCommand(ctx context.Context, cmdSc return } + if commandID == "" { + dlog.Warn(ctx, "Rollout command received without a command ID.") + return + } + cmd := &rolloutCommand{ rolloutName: rolloutName, namespace: namespace, action: rolloutAction(agentapi.RolloutCommand_Action_name[action]), } - err := cmd.RunWithClientFactory(ctx, rolloutsGetterFactory) + err := cmd.RunWithClientFactory(ctx, dh.rolloutsGetterFactory) if err != nil { dlog.Errorf(ctx, "error running rollout command %s: %s", cmd, err) } + dh.reportCommandResult(ctx, commandID, cmd, err, a) +} + +func (dh *BasicDirectiveHandler) reportCommandResult(ctx context.Context, commandID string, cmd *rolloutCommand, cmdError error, a *Agent) { + result := &agentapi.CommandResult{CommandId: commandID, Success: true} + if cmdError != nil { + result.Success = false + result.Message = cmdError.Error() + } + err := a.comm.ReportCommandResult(ctx, result) + if err != nil { + dlog.Errorf(ctx, "error reporting result of rollout command %s: %s", cmd, cmdError) + } } diff --git a/pkg/api/agent/director.pb.go b/pkg/api/agent/director.pb.go index 4241499ea4..957aebfb35 100644 --- a/pkg/api/agent/director.pb.go +++ b/pkg/api/agent/director.pb.go @@ -595,6 +595,7 @@ type RolloutCommand struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Namespace string `protobuf:"bytes,2,opt,name=namespace,proto3" json:"namespace,omitempty"` Action RolloutCommand_Action `protobuf:"varint,3,opt,name=action,proto3,enum=agent.RolloutCommand_Action" json:"action,omitempty"` + CommandId string `protobuf:"bytes,4,opt,name=command_id,json=commandId,proto3" json:"command_id,omitempty"` } func (x *RolloutCommand) Reset() { @@ -650,6 +651,114 @@ func (x *RolloutCommand) GetAction() RolloutCommand_Action { return RolloutCommand_PAUSE } +func (x *RolloutCommand) GetCommandId() string { + if x != nil { + return x.CommandId + } + return "" +} + +type CommandResult struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + CommandId string `protobuf:"bytes,1,opt,name=command_id,json=commandId,proto3" json:"command_id,omitempty"` + Success bool `protobuf:"varint,2,opt,name=success,proto3" json:"success,omitempty"` + Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *CommandResult) Reset() { + *x = CommandResult{} + if protoimpl.UnsafeEnabled { + mi := &file_agent_director_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CommandResult) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CommandResult) ProtoMessage() {} + +func (x *CommandResult) ProtoReflect() protoreflect.Message { + mi := &file_agent_director_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CommandResult.ProtoReflect.Descriptor instead. +func (*CommandResult) Descriptor() ([]byte, []int) { + return file_agent_director_proto_rawDescGZIP(), []int{8} +} + +func (x *CommandResult) GetCommandId() string { + if x != nil { + return x.CommandId + } + return "" +} + +func (x *CommandResult) GetSuccess() bool { + if x != nil { + return x.Success + } + return false +} + +func (x *CommandResult) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +type CommandResultResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *CommandResultResponse) Reset() { + *x = CommandResultResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_agent_director_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CommandResultResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CommandResultResponse) ProtoMessage() {} + +func (x *CommandResultResponse) ProtoReflect() protoreflect.Message { + mi := &file_agent_director_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CommandResultResponse.ProtoReflect.Descriptor instead. +func (*CommandResultResponse) Descriptor() ([]byte, []int) { + return file_agent_director_proto_rawDescGZIP(), []int{9} +} + var File_agent_director_proto protoreflect.FileDescriptor var file_agent_director_proto_rawDesc = []byte{ @@ -729,7 +838,7 @@ var file_agent_director_proto_rawDesc = []byte{ 0x0a, 0x0e, 0x72, 0x6f, 0x6c, 0x6c, 0x6f, 0x75, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2e, 0x52, 0x6f, 0x6c, 0x6c, 0x6f, 0x75, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x0e, 0x72, - 0x6f, 0x6c, 0x6c, 0x6f, 0x75, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x22, 0xa4, 0x01, + 0x6f, 0x6c, 0x6c, 0x6f, 0x75, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x22, 0xc3, 0x01, 0x0a, 0x0e, 0x52, 0x6f, 0x6c, 0x6c, 0x6f, 0x75, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, @@ -737,26 +846,41 @@ var file_agent_director_proto_rawDesc = []byte{ 0x63, 0x65, 0x12, 0x34, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1c, 0x2e, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2e, 0x52, 0x6f, 0x6c, 0x6c, 0x6f, 0x75, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x2a, 0x0a, 0x06, 0x41, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x12, 0x09, 0x0a, 0x05, 0x50, 0x41, 0x55, 0x53, 0x45, 0x10, 0x00, 0x12, 0x0a, 0x0a, - 0x06, 0x52, 0x45, 0x53, 0x55, 0x4d, 0x45, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x42, 0x4f, - 0x52, 0x54, 0x10, 0x02, 0x32, 0xfe, 0x01, 0x0a, 0x08, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, - 0x72, 0x12, 0x37, 0x0a, 0x06, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x0f, 0x2e, 0x61, 0x67, - 0x65, 0x6e, 0x74, 0x2e, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x1a, 0x17, 0x2e, 0x61, - 0x67, 0x65, 0x6e, 0x74, 0x2e, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x03, 0x88, 0x02, 0x01, 0x12, 0x44, 0x0a, 0x0c, 0x52, 0x65, - 0x70, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x17, 0x2e, 0x61, 0x67, 0x65, - 0x6e, 0x74, 0x2e, 0x52, 0x61, 0x77, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x43, 0x68, - 0x75, 0x6e, 0x6b, 0x1a, 0x17, 0x2e, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2e, 0x53, 0x6e, 0x61, 0x70, - 0x73, 0x68, 0x6f, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, - 0x12, 0x31, 0x0a, 0x08, 0x52, 0x65, 0x74, 0x72, 0x69, 0x65, 0x76, 0x65, 0x12, 0x0f, 0x2e, 0x61, - 0x67, 0x65, 0x6e, 0x74, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x1a, 0x10, 0x2e, - 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2e, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x22, - 0x00, 0x30, 0x01, 0x12, 0x40, 0x0a, 0x10, 0x52, 0x65, 0x74, 0x72, 0x69, 0x65, 0x76, 0x65, 0x53, - 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x12, 0x0f, 0x2e, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2e, - 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x1a, 0x17, 0x2e, 0x61, 0x67, 0x65, 0x6e, 0x74, - 0x2e, 0x52, 0x61, 0x77, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x43, 0x68, 0x75, 0x6e, - 0x6b, 0x22, 0x00, 0x30, 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x49, 0x64, 0x22, 0x2a, 0x0a, 0x06, 0x41, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x12, 0x09, 0x0a, 0x05, 0x50, 0x41, 0x55, 0x53, 0x45, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, + 0x52, 0x45, 0x53, 0x55, 0x4d, 0x45, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x42, 0x4f, 0x52, + 0x54, 0x10, 0x02, 0x22, 0x62, 0x0a, 0x0d, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, + 0x73, 0x75, 0x6c, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x5f, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x18, 0x0a, + 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x17, 0x0a, 0x15, 0x43, 0x6f, 0x6d, 0x6d, 0x61, + 0x6e, 0x64, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x32, 0xcb, 0x02, 0x0a, 0x08, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x37, 0x0a, + 0x06, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x0f, 0x2e, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2e, + 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x1a, 0x17, 0x2e, 0x61, 0x67, 0x65, 0x6e, 0x74, + 0x2e, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x03, 0x88, 0x02, 0x01, 0x12, 0x44, 0x0a, 0x0c, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, + 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x17, 0x2e, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2e, 0x52, + 0x61, 0x77, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x1a, + 0x17, 0x2e, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2e, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x12, 0x31, 0x0a, 0x08, + 0x52, 0x65, 0x74, 0x72, 0x69, 0x65, 0x76, 0x65, 0x12, 0x0f, 0x2e, 0x61, 0x67, 0x65, 0x6e, 0x74, + 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x1a, 0x10, 0x2e, 0x61, 0x67, 0x65, 0x6e, + 0x74, 0x2e, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, + 0x4b, 0x0a, 0x13, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x14, 0x2e, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2e, 0x43, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x1a, 0x1c, 0x2e, 0x61, + 0x67, 0x65, 0x6e, 0x74, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x75, + 0x6c, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x40, 0x0a, 0x10, + 0x52, 0x65, 0x74, 0x72, 0x69, 0x65, 0x76, 0x65, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, + 0x12, 0x0f, 0x2e, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, + 0x79, 0x1a, 0x17, 0x2e, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2e, 0x52, 0x61, 0x77, 0x53, 0x6e, 0x61, + 0x70, 0x73, 0x68, 0x6f, 0x74, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x22, 0x00, 0x30, 0x01, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -772,42 +896,46 @@ func file_agent_director_proto_rawDescGZIP() []byte { } var file_agent_director_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_agent_director_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_agent_director_proto_msgTypes = make([]protoimpl.MessageInfo, 12) var file_agent_director_proto_goTypes = []interface{}{ - (RolloutCommand_Action)(0), // 0: agent.RolloutCommand.Action - (*Identity)(nil), // 1: agent.Identity - (*Snapshot)(nil), // 2: agent.Snapshot - (*RawSnapshotChunk)(nil), // 3: agent.RawSnapshotChunk - (*Service)(nil), // 4: agent.Service - (*SnapshotResponse)(nil), // 5: agent.SnapshotResponse - (*Directive)(nil), // 6: agent.Directive - (*Command)(nil), // 7: agent.Command - (*RolloutCommand)(nil), // 8: agent.RolloutCommand - nil, // 9: agent.Service.LabelsEntry - nil, // 10: agent.Service.AnnotationsEntry - (*timestamp.Timestamp)(nil), // 11: google.protobuf.Timestamp - (*duration.Duration)(nil), // 12: google.protobuf.Duration + (RolloutCommand_Action)(0), // 0: agent.RolloutCommand.Action + (*Identity)(nil), // 1: agent.Identity + (*Snapshot)(nil), // 2: agent.Snapshot + (*RawSnapshotChunk)(nil), // 3: agent.RawSnapshotChunk + (*Service)(nil), // 4: agent.Service + (*SnapshotResponse)(nil), // 5: agent.SnapshotResponse + (*Directive)(nil), // 6: agent.Directive + (*Command)(nil), // 7: agent.Command + (*RolloutCommand)(nil), // 8: agent.RolloutCommand + (*CommandResult)(nil), // 9: agent.CommandResult + (*CommandResultResponse)(nil), // 10: agent.CommandResultResponse + nil, // 11: agent.Service.LabelsEntry + nil, // 12: agent.Service.AnnotationsEntry + (*timestamp.Timestamp)(nil), // 13: google.protobuf.Timestamp + (*duration.Duration)(nil), // 14: google.protobuf.Duration } var file_agent_director_proto_depIdxs = []int32{ 1, // 0: agent.Snapshot.identity:type_name -> agent.Identity 4, // 1: agent.Snapshot.services:type_name -> agent.Service - 11, // 2: agent.Snapshot.snapshot_ts:type_name -> google.protobuf.Timestamp - 9, // 3: agent.Service.labels:type_name -> agent.Service.LabelsEntry - 10, // 4: agent.Service.annotations:type_name -> agent.Service.AnnotationsEntry - 12, // 5: agent.Directive.min_report_period:type_name -> google.protobuf.Duration + 13, // 2: agent.Snapshot.snapshot_ts:type_name -> google.protobuf.Timestamp + 11, // 3: agent.Service.labels:type_name -> agent.Service.LabelsEntry + 12, // 4: agent.Service.annotations:type_name -> agent.Service.AnnotationsEntry + 14, // 5: agent.Directive.min_report_period:type_name -> google.protobuf.Duration 7, // 6: agent.Directive.commands:type_name -> agent.Command 8, // 7: agent.Command.rolloutCommand:type_name -> agent.RolloutCommand 0, // 8: agent.RolloutCommand.action:type_name -> agent.RolloutCommand.Action 2, // 9: agent.Director.Report:input_type -> agent.Snapshot 3, // 10: agent.Director.ReportStream:input_type -> agent.RawSnapshotChunk 1, // 11: agent.Director.Retrieve:input_type -> agent.Identity - 1, // 12: agent.Director.RetrieveSnapshot:input_type -> agent.Identity - 5, // 13: agent.Director.Report:output_type -> agent.SnapshotResponse - 5, // 14: agent.Director.ReportStream:output_type -> agent.SnapshotResponse - 6, // 15: agent.Director.Retrieve:output_type -> agent.Directive - 3, // 16: agent.Director.RetrieveSnapshot:output_type -> agent.RawSnapshotChunk - 13, // [13:17] is the sub-list for method output_type - 9, // [9:13] is the sub-list for method input_type + 9, // 12: agent.Director.ReportCommandResult:input_type -> agent.CommandResult + 1, // 13: agent.Director.RetrieveSnapshot:input_type -> agent.Identity + 5, // 14: agent.Director.Report:output_type -> agent.SnapshotResponse + 5, // 15: agent.Director.ReportStream:output_type -> agent.SnapshotResponse + 6, // 16: agent.Director.Retrieve:output_type -> agent.Directive + 10, // 17: agent.Director.ReportCommandResult:output_type -> agent.CommandResultResponse + 3, // 18: agent.Director.RetrieveSnapshot:output_type -> agent.RawSnapshotChunk + 14, // [14:19] is the sub-list for method output_type + 9, // [9:14] is the sub-list for method input_type 9, // [9:9] is the sub-list for extension type_name 9, // [9:9] is the sub-list for extension extendee 0, // [0:9] is the sub-list for field type_name @@ -915,6 +1043,30 @@ func file_agent_director_proto_init() { return nil } } + file_agent_director_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CommandResult); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_agent_director_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CommandResultResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -922,7 +1074,7 @@ func file_agent_director_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_agent_director_proto_rawDesc, NumEnums: 1, - NumMessages: 10, + NumMessages: 12, NumExtensions: 0, NumServices: 1, }, @@ -957,6 +1109,8 @@ type DirectorClient interface { ReportStream(ctx context.Context, opts ...grpc.CallOption) (Director_ReportStreamClient, error) // Retrieve Directives from the CEPC Retrieve(ctx context.Context, in *Identity, opts ...grpc.CallOption) (Director_RetrieveClient, error) + // Reports the result of a command execution to the cloud + ReportCommandResult(ctx context.Context, in *CommandResult, opts ...grpc.CallOption) (*CommandResultResponse, error) RetrieveSnapshot(ctx context.Context, in *Identity, opts ...grpc.CallOption) (Director_RetrieveSnapshotClient, error) } @@ -1044,6 +1198,15 @@ func (x *directorRetrieveClient) Recv() (*Directive, error) { return m, nil } +func (c *directorClient) ReportCommandResult(ctx context.Context, in *CommandResult, opts ...grpc.CallOption) (*CommandResultResponse, error) { + out := new(CommandResultResponse) + err := c.cc.Invoke(ctx, "/agent.Director/ReportCommandResult", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *directorClient) RetrieveSnapshot(ctx context.Context, in *Identity, opts ...grpc.CallOption) (Director_RetrieveSnapshotClient, error) { stream, err := c.cc.NewStream(ctx, &_Director_serviceDesc.Streams[2], "/agent.Director/RetrieveSnapshot", opts...) if err != nil { @@ -1086,6 +1249,8 @@ type DirectorServer interface { ReportStream(Director_ReportStreamServer) error // Retrieve Directives from the CEPC Retrieve(*Identity, Director_RetrieveServer) error + // Reports the result of a command execution to the cloud + ReportCommandResult(context.Context, *CommandResult) (*CommandResultResponse, error) RetrieveSnapshot(*Identity, Director_RetrieveSnapshotServer) error } @@ -1102,6 +1267,9 @@ func (*UnimplementedDirectorServer) ReportStream(Director_ReportStreamServer) er func (*UnimplementedDirectorServer) Retrieve(*Identity, Director_RetrieveServer) error { return status.Errorf(codes.Unimplemented, "method Retrieve not implemented") } +func (*UnimplementedDirectorServer) ReportCommandResult(context.Context, *CommandResult) (*CommandResultResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ReportCommandResult not implemented") +} func (*UnimplementedDirectorServer) RetrieveSnapshot(*Identity, Director_RetrieveSnapshotServer) error { return status.Errorf(codes.Unimplemented, "method RetrieveSnapshot not implemented") } @@ -1175,6 +1343,24 @@ func (x *directorRetrieveServer) Send(m *Directive) error { return x.ServerStream.SendMsg(m) } +func _Director_ReportCommandResult_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CommandResult) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DirectorServer).ReportCommandResult(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/agent.Director/ReportCommandResult", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DirectorServer).ReportCommandResult(ctx, req.(*CommandResult)) + } + return interceptor(ctx, in, info, handler) +} + func _Director_RetrieveSnapshot_Handler(srv interface{}, stream grpc.ServerStream) error { m := new(Identity) if err := stream.RecvMsg(m); err != nil { @@ -1204,6 +1390,10 @@ var _Director_serviceDesc = grpc.ServiceDesc{ MethodName: "Report", Handler: _Director_Report_Handler, }, + { + MethodName: "ReportCommandResult", + Handler: _Director_ReportCommandResult_Handler, + }, }, Streams: []grpc.StreamDesc{ {