From 59473394cca1e227ec579236d71ec54deb79b068 Mon Sep 17 00:00:00 2001 From: Yuhang Wei Date: Thu, 10 Aug 2023 20:49:39 +0800 Subject: [PATCH 07/17] KubeOS: add warning log during config add warning log when configuring kv with unknown operation Signed-off-by: Yuhang Wei --- cmd/agent/server/config.go | 4 ++++ cmd/agent/server/config_test.go | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/agent/server/config.go b/cmd/agent/server/config.go index bcd9fde..78dfd01 100644 --- a/cmd/agent/server/config.go +++ b/cmd/agent/server/config.go @@ -382,6 +382,10 @@ func handleAddKey(m map[string]*agent.KeyInfo, isOnlyKeyValid bool) []string { logrus.Warnf("Failed to delete inexistent key %s", key) continue } + if keyInfo.Operation != "" { + logrus.Warnf("Unknown operation %s, adding key %s with value %s by default", + keyInfo.Operation, key, keyInfo.Value) + } k, v := strings.TrimSpace(key), strings.TrimSpace(keyInfo.Value) if keyInfo.Value == "" && isOnlyKeyValid { logrus.Infoln("add configuration ", k) diff --git a/cmd/agent/server/config_test.go b/cmd/agent/server/config_test.go index ae2a2cf..6424885 100644 --- a/cmd/agent/server/config_test.go +++ b/cmd/agent/server/config_test.go @@ -122,7 +122,7 @@ func TestKerSysctlPersist_SetConfig(t *testing.T) { "b": {Value: "2"}, "c": {Value: ""}, "": {Value: "4"}, - "e": {Value: "5"}, + "e": {Value: "5", Operation: "xxx"}, "y=1": {Value: "26"}, "z": {Value: "x=1"}, }, @@ -144,7 +144,7 @@ func TestKerSysctlPersist_SetConfig(t *testing.T) { Contents: map[string]*agent.KeyInfo{ "a": {Value: "2"}, "b": {Value: ""}, - "z": {Value: "x=2"}, + "z": {Value: "x=2", Operation: "zzz"}, }, }, }, -- 2.39.0