Bug Fix - Daemonset not reloading
[demo.git] / vnfs / DAaaS / microservices / collectd-operator / pkg / controller / utils / collectdutils.go
index 6a85103..17cad0e 100644 (file)
@@ -5,6 +5,7 @@ import (
        "crypto/sha256"
        "fmt"
        "os"
+       "sort"
        "sync"
 
        "github.com/go-logr/logr"
@@ -30,6 +31,9 @@ const (
 
 var lock sync.Mutex
 
+// ReconcileLock - Used to sync between global and plugin controller
+var ReconcileLock sync.Mutex
+
 // ResourceMap to hold objects to update/reload
 type ResourceMap struct {
        ConfigMap       *corev1.ConfigMap
@@ -195,7 +199,14 @@ func RebuildCollectdConf(rc client.Client, ns string, isDelete bool, delPlugin s
                collectdConf += collectdGlobalConf
        }
 
-       for cpName, cpConf := range loadPlugin {
+       pluginKeys := make([]string, 0, len(loadPlugin))
+       for k := range loadPlugin {
+               pluginKeys = append(pluginKeys, k)
+       }
+       sort.Strings(pluginKeys)
+
+       for _, cpName := range pluginKeys {
+               cpConf := loadPlugin[cpName]
                collectdConf += "LoadPlugin" + " " + cpName + "\n"
                collectdConf += cpConf + "\n"
        }