From a0683941630bc4ca27a084f637e712adef80eed2 Mon Sep 17 00:00:00 2001 From: Alex Demidoff Date: Wed, 18 Sep 2024 09:56:28 +0300 Subject: [PATCH 1/2] PMM-13285 Short agent status in pmm-admin list output (#3123) --- admin/commands/list.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 } From 6d2825b7c4b1e833af99c0b0f19cfe8884b01002 Mon Sep 17 00:00:00 2001 From: Nurlan Moldomurov Date: Wed, 18 Sep 2024 11:48:47 +0300 Subject: [PATCH 2/2] PMM-7 fix SSH key test. (#3203) --- api-tests/Makefile | 3 +++ api-tests/server/settings_test.go | 6 +++--- managed/services/server/server.go | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) 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()) } }