Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added API Action Request #951

Merged
merged 37 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
0d3ba77
agent parsing stub status, metrics not working yet
aphralG Nov 18, 2024
daaddb9
remove TODO
aphralG Nov 19, 2024
5abe057
Merge branch 'v3' into add-ability-to-use-unix-socket
aphralG Nov 19, 2024
a152d35
revert config changes
aphralG Nov 19, 2024
d7feb70
lint
aphralG Nov 19, 2024
5bd18b7
working unix plus and oss
aphralG Nov 22, 2024
2e7c55f
WIP
aphralG Nov 26, 2024
5b3a821
WIP
aphralG Nov 26, 2024
9c96943
WIP
aphralG Nov 26, 2024
c5d963a
WIP
aphralG Nov 26, 2024
b948bd0
WIP
aphralG Nov 26, 2024
b37dbc6
working oss metrics with unix
aphralG Nov 28, 2024
1b577d8
working plus
aphralG Nov 28, 2024
41b37c2
working plus
aphralG Nov 28, 2024
fbbd6d0
clean up
aphralG Nov 28, 2024
b9c4794
clean up:
aphralG Nov 28, 2024
f6ea17c
clean up:
aphralG Nov 28, 2024
23358c9
clean up
aphralG Nov 28, 2024
8e53d34
add unit tests
aphralG Nov 29, 2024
1b25e59
add unit tests
aphralG Nov 29, 2024
6b8965b
merge v3
aphralG Nov 29, 2024
a28f55b
fix integration tests
aphralG Nov 29, 2024
b431c1f
merge v3
aphralG Nov 29, 2024
5dafe48
update runtime info
aphralG Dec 3, 2024
e92113d
update README
aphralG Dec 5, 2024
f54ee62
Merge branch 'v3' into add-ability-to-use-unix-socket
aphralG Dec 5, 2024
b4ea46e
merge v3
aphralG Dec 5, 2024
06bbe29
add api action request
aphralG Dec 16, 2024
ce81487
merge v3
aphralG Dec 16, 2024
e95edb6
tests WIP
aphralG Dec 17, 2024
a54b119
added tests
aphralG Dec 18, 2024
47e7b5e
merge v3
aphralG Dec 18, 2024
de29b7a
PR feedback
aphralG Dec 19, 2024
34d7f77
feedback
aphralG Dec 19, 2024
6e22018
PR feedback
aphralG Dec 19, 2024
767441c
add tests
aphralG Dec 19, 2024
611e168
feedback
aphralG Dec 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
802 changes: 533 additions & 269 deletions api/grpc/mpi/v1/command.pb.go

Large diffs are not rendered by default.

477 changes: 477 additions & 0 deletions api/grpc/mpi/v1/command.pb.validate.go

Large diffs are not rendered by default.

23 changes: 22 additions & 1 deletion api/grpc/mpi/v1/command.proto
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,28 @@ message ConfigUploadRequest {
}

// Perform an associated API action on an instance
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add comments to the fields in the new proto messages?

Copy link
Collaborator

@dhurley dhurley Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add comments to all the fields like instance_id, http_upstream_name, servers, etc.

message APIActionRequest {}
message APIActionRequest {
string instance_id = 1;
oneof action {
NGINXPlusAction nginx_plus_action = 2;
}
}

message NGINXPlusAction {
oneof action {
UpdateHTTPUpstreamServers update_http_upstream_servers = 2;
GetHTTPUpstreamServers get_http_upstream_servers = 3;
}
}

message UpdateHTTPUpstreamServers {
string http_upstream_name = 1;
repeated google.protobuf.Struct servers = 2;
}

message GetHTTPUpstreamServers {
string http_upstream_name = 1;
}

// Request an update on a particular command
message CommandStatusRequest {}
Expand Down
56 changes: 56 additions & 0 deletions docs/proto/protos.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
- [CreateConnectionResponse](#mpi-v1-CreateConnectionResponse)
- [DataPlaneResponse](#mpi-v1-DataPlaneResponse)
- [FileServer](#mpi-v1-FileServer)
- [GetHTTPUpstreamServers](#mpi-v1-GetHTTPUpstreamServers)
- [HealthRequest](#mpi-v1-HealthRequest)
- [HostInfo](#mpi-v1-HostInfo)
- [Instance](#mpi-v1-Instance)
Expand All @@ -62,6 +63,7 @@
- [InstanceRuntime](#mpi-v1-InstanceRuntime)
- [ManagementPlaneRequest](#mpi-v1-ManagementPlaneRequest)
- [MetricsServer](#mpi-v1-MetricsServer)
- [NGINXPlusAction](#mpi-v1-NGINXPlusAction)
- [NGINXPlusRuntimeInfo](#mpi-v1-NGINXPlusRuntimeInfo)
- [NGINXRuntimeInfo](#mpi-v1-NGINXRuntimeInfo)
- [ReleaseInfo](#mpi-v1-ReleaseInfo)
Expand All @@ -71,6 +73,7 @@
- [UpdateDataPlaneHealthResponse](#mpi-v1-UpdateDataPlaneHealthResponse)
- [UpdateDataPlaneStatusRequest](#mpi-v1-UpdateDataPlaneStatusRequest)
- [UpdateDataPlaneStatusResponse](#mpi-v1-UpdateDataPlaneStatusResponse)
- [UpdateHTTPUpstreamServers](#mpi-v1-UpdateHTTPUpstreamServers)

- [InstanceHealth.InstanceHealthStatus](#mpi-v1-InstanceHealth-InstanceHealthStatus)
- [InstanceMeta.InstanceType](#mpi-v1-InstanceMeta-InstanceType)
Expand Down Expand Up @@ -601,6 +604,12 @@ and recommendations outlined in https://static.sched.com/hosted_files/kccncna17/
Perform an associated API action on an instance


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| instance_id | [string](#string) | | |
| nginx_plus_action | [NGINXPlusAction](#mpi-v1-NGINXPlusAction) | | |





Expand Down Expand Up @@ -773,6 +782,21 @@ The file settings associated with file server for configurations



<a name="mpi-v1-GetHTTPUpstreamServers"></a>

### GetHTTPUpstreamServers



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| http_upstream_name | [string](#string) | | |






<a name="mpi-v1-HealthRequest"></a>

### HealthRequest
Expand Down Expand Up @@ -943,6 +967,22 @@ The metrics settings associated with origins (sources) of the metrics and destin



<a name="mpi-v1-NGINXPlusAction"></a>

### NGINXPlusAction



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| update_http_upstream_servers | [UpdateHTTPUpstreamServers](#mpi-v1-UpdateHTTPUpstreamServers) | | |
| get_http_upstream_servers | [GetHTTPUpstreamServers](#mpi-v1-GetHTTPUpstreamServers) | | |






<a name="mpi-v1-NGINXPlusRuntimeInfo"></a>

### NGINXPlusRuntimeInfo
Expand Down Expand Up @@ -1080,6 +1120,22 @@ Respond to a UpdateDataPlaneStatusRequest - intentionally empty




<a name="mpi-v1-UpdateHTTPUpstreamServers"></a>

### UpdateHTTPUpstreamServers



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| http_upstream_name | [string](#string) | | |
| servers | [google.protobuf.Struct](#google-protobuf-Struct) | repeated | |








Expand Down
1 change: 1 addition & 0 deletions internal/bus/topics.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ const (
RollbackWriteTopic = "rollback-write"
DataPlaneHealthRequestTopic = "data-plane-health-request"
DataPlaneHealthResponseTopic = "data-plane-health-response"
APIActionRequestTopic = "api-action-request"
)
29 changes: 28 additions & 1 deletion internal/command/command_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,40 @@ func (cp *CommandPlugin) monitorSubscribeChannel(ctx context.Context) {
cp.handleConfigApplyRequest(newCtx, message)
case *mpi.ManagementPlaneRequest_HealthRequest:
cp.handleHealthRequest(newCtx)
case *mpi.ManagementPlaneRequest_ActionRequest:
cp.handleAPIActionRequest(newCtx, message)
default:
slog.DebugContext(newCtx, "Management plane request not implemented yet")
}
}
}
}

func (cp *CommandPlugin) handleAPIActionRequest(ctx context.Context, message *mpi.ManagementPlaneRequest) {
if cp.config.IsFeatureEnabled(pkgConfig.FeatureAPIAction) {
cp.messagePipe.Process(ctx, &bus.Message{Topic: bus.APIActionRequestTopic, Data: message})
} else {
slog.WarnContext(
ctx,
"API Action Request feature disabled. Unable to process API action request",
"request", message,
)

err := cp.commandService.SendDataPlaneResponse(ctx, &mpi.DataPlaneResponse{
MessageMeta: message.GetMessageMeta(),
CommandResponse: &mpi.CommandResponse{
Status: mpi.CommandResponse_COMMAND_STATUS_FAILURE,
Message: "API action failed",
Error: "API action feature is disabled",
},
InstanceId: message.GetActionRequest().GetInstanceId(),
})
if err != nil {
slog.ErrorContext(ctx, "Unable to send data plane response", "error", err)
}
}
}

func (cp *CommandPlugin) handleConfigApplyRequest(newCtx context.Context, message *mpi.ManagementPlaneRequest) {
if cp.config.IsFeatureEnabled(pkgConfig.FeatureConfiguration) {
cp.messagePipe.Process(newCtx, &bus.Message{Topic: bus.ConfigApplyRequestTopic, Data: message})
Expand All @@ -206,7 +233,7 @@ func (cp *CommandPlugin) handleConfigApplyRequest(newCtx context.Context, messag
Message: "Config apply failed",
Error: "Configuration feature is disabled",
},
InstanceId: message.GetConfigUploadRequest().GetOverview().GetConfigVersion().GetInstanceId(),
InstanceId: message.GetConfigApplyRequest().GetOverview().GetConfigVersion().GetInstanceId(),
})
if err != nil {
slog.ErrorContext(newCtx, "Unable to send data plane response", "error", err)
Expand Down
Loading