Skip to content

Commit

Permalink
placed health check logs in the correct dir
Browse files Browse the repository at this point in the history
  • Loading branch information
XuechunHou committed Jan 31, 2025
1 parent e9ac672 commit 886786f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions cmd/ops_agent_uap_plugin/service_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (ps *OpsAgentPluginServer) Start(ctx context.Context, msg *pb.StartRequest)
}

// Ops Agent config validation
if err := validateOpsAgentConfig(pContext, pluginInstallDir, ps.runCommand); err != nil {
if err := validateOpsAgentConfig(pContext, pluginInstallDir, pluginStateDir, ps.runCommand); err != nil {
log.Printf("Start() failed: %s", err)
ps.cancel()
ps.cancel = nil
Expand Down Expand Up @@ -264,10 +264,11 @@ func runCommand(cmd *exec.Cmd) (string, error) {
return string(out), err
}

func validateOpsAgentConfig(ctx context.Context, pluginInstallDirectory string, runCommand RunCommandFunc) error {
func validateOpsAgentConfig(ctx context.Context, pluginInstallDirectory string, pluginStateDirectory string, runCommand RunCommandFunc) error {
configValidationCmd := exec.CommandContext(ctx,
path.Join(pluginInstallDirectory, ConfGeneratorBinary),
"-in", OpsAgentConfigLocationLinux,
"-logs", path.Join(pluginStateDirectory, LogsDirectory),
)
if output, err := runCommand(configValidationCmd); err != nil {
return fmt.Errorf("failed to validate the Ops Agent config:\ncommand output: %s\ncommand error: %s", output, err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/ops_agent_uap_plugin/service_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func Test_validateOpsAgentConfig(t *testing.T) {
}

ctx := context.Background()
err := validateOpsAgentConfig(ctx, "", mockRunCommand)
err := validateOpsAgentConfig(ctx, "", "", mockRunCommand)
gotSuccess := (err == nil)
if gotSuccess != tc.wantSuccess {
t.Errorf("%s: validateOpsAgentConfig() failed to valide Ops Agent config: %v, want successful config validation: %v, error:%v", tc.name, gotSuccess, tc.wantSuccess, err)
Expand Down

0 comments on commit 886786f

Please sign in to comment.