X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=vnfs%2FDAaaS%2Fmicroservices%2Fcollectd-operator%2Fpkg%2Fcontroller%2Futils%2Fcollectdutils.go;h=1e73f6968195b33a75d6d6b8897c56b21fa0e5a9;hb=d614d3d6cc1d40664215f79fc2c2f38af03a9996;hp=6a85103cbcad23deecaa11052442d98b7d9c4a97;hpb=b2651f39b6dbe79e05d42f8a3bfbbc11c42c5d4c;p=demo.git diff --git a/vnfs/DAaaS/microservices/collectd-operator/pkg/controller/utils/collectdutils.go b/vnfs/DAaaS/microservices/collectd-operator/pkg/controller/utils/collectdutils.go index 6a85103c..1e73f696 100644 --- a/vnfs/DAaaS/microservices/collectd-operator/pkg/controller/utils/collectdutils.go +++ b/vnfs/DAaaS/microservices/collectd-operator/pkg/controller/utils/collectdutils.go @@ -1,3 +1,16 @@ +/* +Copyright 2019 Intel Corporation. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package utils import ( @@ -5,6 +18,7 @@ import ( "crypto/sha256" "fmt" "os" + "sort" "sync" "github.com/go-logr/logr" @@ -30,6 +44,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,12 +212,19 @@ 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" } - collectdConf += "#Last line (collectd requires ‘\\n’ at the last line)\n" + collectdConf += "#Last line (collectd requires '\\n' at the last line)\n" return collectdConf, nil }