From aa36a3d72b53fdfd618db7524141457dffa1a78d Mon Sep 17 00:00:00 2001 From: r-dilip Date: Mon, 8 Oct 2018 22:10:47 -0700 Subject: [PATCH 1/2] Removing some logs, added more error checking, continue on kube-api error --- source/code/go/src/plugins/oms.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/source/code/go/src/plugins/oms.go b/source/code/go/src/plugins/oms.go index c7fe8eb42..7f5dff16d 100644 --- a/source/code/go/src/plugins/oms.go +++ b/source/code/go/src/plugins/oms.go @@ -133,6 +133,7 @@ func updateContainerImageNameMaps() { pods, err := ClientSet.CoreV1().Pods("").List(metav1.ListOptions{}) if err != nil { Log("Error getting pods %s\nIt is ok to log here and continue, because the logs will be missing image and Name, but the logs will still have the containerID", err.Error()) + continue } for _, pod := range pods.Items { @@ -216,20 +217,12 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int { stringMap["Image"] = val } else { Log("ContainerId %s not present in Map ", containerID) - Log("CurrentMap Snapshot \n") - for k, v := range ImageIDMap { - Log("%s ==> %s", k, v) - } } if val, ok := NameIDMap[containerID]; ok { stringMap["Name"] = val } else { Log("ContainerId %s not present in Map ", containerID) - Log("CurrentMap Snapshot \n") - for k, v := range NameIDMap { - Log("%s ==> %s", k, v) - } } dataItem := DataItem{ @@ -253,6 +246,10 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int { DataItems: dataItems} marshalled, err := json.Marshal(logEntry) + if err != nil { + Log("Error while Marshalling log Entry: %s", err.Error()) + return output.FLB_RETRY + } req, _ := http.NewRequest("POST", OMSEndpoint, bytes.NewBuffer(marshalled)) req.Header.Set("Content-Type", "application/json") From 4fecfa5c1b90d0bb4993d223910755070cc5006b Mon Sep 17 00:00:00 2001 From: r-dilip Date: Tue, 9 Oct 2018 14:35:01 -0700 Subject: [PATCH 2/2] Return FLB OF for json Marshall error, instead of RETRY --- source/code/go/src/plugins/oms.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/code/go/src/plugins/oms.go b/source/code/go/src/plugins/oms.go index 7f5dff16d..d20f11d57 100644 --- a/source/code/go/src/plugins/oms.go +++ b/source/code/go/src/plugins/oms.go @@ -248,7 +248,7 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int { marshalled, err := json.Marshal(logEntry) if err != nil { Log("Error while Marshalling log Entry: %s", err.Error()) - return output.FLB_RETRY + return output.FLB_OK } req, _ := http.NewRequest("POST", OMSEndpoint, bytes.NewBuffer(marshalled)) req.Header.Set("Content-Type", "application/json")