-
Notifications
You must be signed in to change notification settings - Fork 100
Remotely configure NGINX Agent log level and path #1382
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
Open
dhurley
wants to merge
8
commits into
main
Choose a base branch
from
remote-configuration-log
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ed33c6a
[skip ci] adding Log configuration option to MPI
sean-breen a8cb72b
Add support for remotely configuring the log level and path
dhurley 204e19c
Clean up
dhurley b5fb1ce
Clean up
dhurley 204c1e3
Clean up
dhurley e708254
Fix integration test
dhurley 5479bcf
Update README
dhurley ba7b248
Update logger so that if a log file does not exist create one
dhurley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,7 @@ type ( | |
| Subscribe(ctx context.Context) | ||
| IsConnected() bool | ||
| CreateConnection(ctx context.Context, resource *mpi.Resource) (*mpi.CreateConnectionResponse, error) | ||
| UpdateAgentConfig(ctx context.Context, request *mpi.AgentConfig) (*config.Config, error) | ||
| } | ||
|
|
||
| CommandPlugin struct { | ||
|
|
@@ -180,6 +181,24 @@ func (cp *CommandPlugin) createConnection(ctx context.Context, resource *mpi.Res | |
| Topic: bus.ConnectionCreatedTopic, | ||
| Data: createConnectionResponse, | ||
| }) | ||
|
|
||
| if createConnectionResponse.GetAgentConfig() != nil { | ||
| newAgentConfig, updateConfigError := cp.commandService.UpdateAgentConfig( | ||
| ctx, | ||
| createConnectionResponse.GetAgentConfig(), | ||
| ) | ||
| if updateConfigError != nil { | ||
| slog.ErrorContext(ctx, "Unable to update agent configuration", "error", updateConfigError) | ||
| } else { | ||
| slog.DebugContext( | ||
aphralG marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ctx, "Notifying other plugins of agent configuration update from create connection response", | ||
| ) | ||
| cp.messagePipe.Process(ctx, &bus.Message{ | ||
| Topic: bus.AgentConfigUpdateTopic, | ||
| Data: newAgentConfig, | ||
| }) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -305,6 +324,9 @@ func (cp *CommandPlugin) monitorSubscribeChannel(ctx context.Context) { | |
| } | ||
| slog.InfoContext(ctx, "Received management plane action request") | ||
| cp.handleAPIActionRequest(newCtx, message) | ||
| case *mpi.ManagementPlaneRequest_UpdateNginxAgentConfigurationRequest: | ||
|
||
| slog.InfoContext(ctx, "Received management plane request - update agent configuration") | ||
aphralG marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| cp.handleAgentConfigUpdateRequest(newCtx, message) | ||
| default: | ||
| slog.DebugContext(newCtx, "Management plane request not implemented yet") | ||
| } | ||
|
|
@@ -408,6 +430,50 @@ func (cp *CommandPlugin) handleInvalidRequest(ctx context.Context, | |
| } | ||
| } | ||
|
|
||
| func (cp *CommandPlugin) handleAgentConfigUpdateRequest(ctx context.Context, request *mpi.ManagementPlaneRequest) { | ||
| newAgentConfig, err := cp.commandService.UpdateAgentConfig( | ||
| ctx, | ||
| request.GetUpdateNginxAgentConfigurationRequest().GetAgentConfig(), | ||
| ) | ||
| if err != nil { | ||
| slog.ErrorContext(ctx, "Command service was unable to update agent configuration", "error", err) | ||
aphralG marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| responseError := cp.commandService.SendDataPlaneResponse(ctx, &mpi.DataPlaneResponse{ | ||
| MessageMeta: &mpi.MessageMeta{ | ||
| MessageId: id.GenerateMessageID(), | ||
| CorrelationId: request.GetMessageMeta().GetCorrelationId(), | ||
| Timestamp: timestamppb.Now(), | ||
| }, | ||
| CommandResponse: &mpi.CommandResponse{ | ||
| Status: mpi.CommandResponse_COMMAND_STATUS_FAILURE, | ||
| Message: "Failed to update agent configuration", | ||
| }, | ||
| }) | ||
|
|
||
| if responseError != nil { | ||
| slog.ErrorContext(ctx, "Unable to send data plane response", "error", responseError) | ||
| } | ||
| } else { | ||
| cp.Process(ctx, &bus.Message{Topic: bus.AgentConfigUpdateTopic, Data: newAgentConfig}) | ||
|
|
||
| responseError := cp.commandService.SendDataPlaneResponse(ctx, &mpi.DataPlaneResponse{ | ||
| MessageMeta: &mpi.MessageMeta{ | ||
| MessageId: id.GenerateMessageID(), | ||
| CorrelationId: request.GetMessageMeta().GetCorrelationId(), | ||
| Timestamp: timestamppb.Now(), | ||
| }, | ||
| CommandResponse: &mpi.CommandResponse{ | ||
| Status: mpi.CommandResponse_COMMAND_STATUS_OK, | ||
| Message: "Successfully updated agent configuration", | ||
| }, | ||
| }) | ||
|
|
||
| if responseError != nil { | ||
| slog.ErrorContext(ctx, "Unable to send data plane response", "error", responseError) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func (cp *CommandPlugin) createDataPlaneResponse(correlationID string, status mpi.CommandResponse_CommandStatus, | ||
| message, err string, | ||
| ) *mpi.DataPlaneResponse { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.