diff --git a/admin/commands/list.go b/admin/commands/list.go index 193bebd3d7..e274d17da7 100644 --- a/admin/commands/list.go +++ b/admin/commands/list.go @@ -61,7 +61,7 @@ func (a listResultAgent) HumanReadableAgentType() string { } func (a listResultAgent) NiceAgentStatus() string { - res := a.Status + res, _ := strings.CutPrefix(a.Status, "AGENT_STATUS_") if res == "" { res = "unknown" //nolint:goconst } diff --git a/api-tests/Makefile b/api-tests/Makefile index 85af0f3609..4cbd6a120c 100644 --- a/api-tests/Makefile +++ b/api-tests/Makefile @@ -15,6 +15,9 @@ run: go test -count=1 -p 1 -v ./... 2>&1 | tee pmm-api-tests-output.txt cat pmm-api-tests-output.txt | bin/go-junit-report > pmm-api-tests-junit-report.xml +run-dev: + go test -count=1 -p 1 -v ./... + run-race: go test -count=1 -p 1 -v -race ./... 2>&1 | tee pmm-api-tests-output.txt cat pmm-api-tests-output.txt | bin/go-junit-report > pmm-api-tests-junit-report.xml diff --git a/api-tests/server/settings_test.go b/api-tests/server/settings_test.go index cae52f07ac..be972eee17 100644 --- a/api-tests/server/settings_test.go +++ b/api-tests/server/settings_test.go @@ -521,7 +521,7 @@ func TestSettings(t *testing.T) { assert.Empty(t, res) }) - t.Run("ChangeSSHKey", func(t *testing.T) { + t.Run("ChangeSSHKey only on AMI and OVF", func(t *testing.T) { defer restoreSettingsDefaults(t) sshKey := "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQClY/8sz3w03vA2bY6mBFgUzrvb2FIoHw8ZjUXGGClJzJg5HC" + @@ -535,8 +535,8 @@ func TestSettings(t *testing.T) { }, Context: pmmapitests.Context, }) - require.NoError(t, err) - assert.Equal(t, sshKey, res.Payload.Settings.SSHKey) + pmmapitests.AssertAPIErrorf(t, err, 500, codes.Internal, `SSH key can be set only on AMI and OVF distributions`) + assert.Empty(t, res) }) t.Run("OK", func(t *testing.T) { diff --git a/managed/services/server/server.go b/managed/services/server/server.go index 2a2a358308..9573164b66 100644 --- a/managed/services/server/server.go +++ b/managed/services/server/server.go @@ -600,7 +600,8 @@ func (s *Server) ChangeSettings(ctx context.Context, req *serverv1.ChangeSetting // absent value means "do not change" if req.SshKey != nil { if err = s.writeSSHKey(pointer.GetString(req.SshKey)); err != nil { - return errors.WithStack(err) + s.l.Error(errors.WithStack(err)) + return status.Errorf(codes.Internal, err.Error()) } }