From b882f3e4840989efa79a36a40d293e94078d49f3 Mon Sep 17 00:00:00 2001 From: Shireesh Anjal <355479+anjalshireesh@users.noreply.github.com> Date: Thu, 11 Nov 2021 20:19:13 +0530 Subject: [PATCH] Better message on reset of dynamic config (#3861) When a dynamic config is reset, the minio api response has `true` as value of the header `x-minio-config-applied`. In such cases, mc should not show the message asking the user to restart `minio`. --- cmd/admin-config-reset.go | 13 +++++++++---- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/cmd/admin-config-reset.go b/cmd/admin-config-reset.go index 19b306a4..7a7e7b3b 100644 --- a/cmd/admin-config-reset.go +++ b/cmd/admin-config-reset.go @@ -61,6 +61,7 @@ EXAMPLES: type configResetMessage struct { Status string `json:"status"` targetAlias string + restart bool } // String colorized service status message. @@ -68,8 +69,11 @@ func (u configResetMessage) String() (msg string) { msg += console.Colorize("ResetConfigSuccess", "Key is successfully reset.\n") suggestion := fmt.Sprintf("mc admin service restart %s", u.targetAlias) - msg += console.Colorize("ResetConfigSuccess", - fmt.Sprintf("Please restart your server with `%s`.\n", suggestion)) + if u.restart { + msg += console.Colorize("ResetConfigSuccess", + fmt.Sprintf("Please restart your server with `%s`.\n", suggestion)) + + } return } @@ -123,12 +127,13 @@ func mainAdminConfigReset(ctx *cli.Context) error { // Call reset config API input := strings.Join(args.Tail(), " ") - fatalIf(probe.NewError(client.DelConfigKV(globalContext, input)), - "Unable to reset '%s' on the server", input) + restart, e := client.DelConfigKV(globalContext, input) + fatalIf(probe.NewError(e), "Unable to reset '%s' on the server", input) // Print set config result printMsg(configResetMessage{ targetAlias: aliasedURL, + restart: restart, }) return nil diff --git a/go.mod b/go.mod index e5879224..8cf02eb9 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/minio/cli v1.22.0 github.com/minio/colorjson v1.0.1 github.com/minio/filepath v1.0.0 - github.com/minio/madmin-go v1.1.11-0.20211102182201-e51fd3d6b104 + github.com/minio/madmin-go v1.1.13 github.com/minio/md5-simd v1.1.2 // indirect github.com/minio/minio-go/v7 v7.0.15-0.20211004160302-3b57c1e369ca github.com/minio/pkg v1.1.3 diff --git a/go.sum b/go.sum index 756637aa..6ff1a7e8 100644 --- a/go.sum +++ b/go.sum @@ -273,8 +273,8 @@ github.com/minio/colorjson v1.0.1/go.mod h1:oPM3zQQY8Gz9NGtgvuBEjQ+gPZLKAGc7T+kj github.com/minio/filepath v1.0.0 h1:fvkJu1+6X+ECRA6G3+JJETj4QeAYO9sV43I79H8ubDY= github.com/minio/filepath v1.0.0/go.mod h1:/nRZA2ldl5z6jT9/KQuvZcQlxZIMQoFFQPvEXx9T/Bw= github.com/minio/madmin-go v1.0.12/go.mod h1:BK+z4XRx7Y1v8SFWXsuLNqQqnq5BO/axJ8IDJfgyvfs= -github.com/minio/madmin-go v1.1.11-0.20211102182201-e51fd3d6b104 h1:/N0JW/1+vbxdDgCI8+tac7GXKkis6rh8kVsLNejN6Ug= -github.com/minio/madmin-go v1.1.11-0.20211102182201-e51fd3d6b104/go.mod h1:Iu0OnrMWNBYx1lqJTW+BFjBMx0Hi0wjw8VmqhiOs2Jo= +github.com/minio/madmin-go v1.1.13 h1:uIY5q88TGOx10iDsLvPT4ylTe8Nw8vctn9hRvk9z91A= +github.com/minio/madmin-go v1.1.13/go.mod h1:Iu0OnrMWNBYx1lqJTW+BFjBMx0Hi0wjw8VmqhiOs2Jo= github.com/minio/md5-simd v1.1.0/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw= github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=