From 9610eedd1351ede91d417412740b2560525a1fab Mon Sep 17 00:00:00 2001 From: Dileep Ranganathan Date: Mon, 10 Jun 2019 14:23:15 -0700 Subject: Fix the Collectd operator panic issue Fixed the panic issue as the daemonset was used instead of DaemonsetList. Improved the logging to get data from configmap. Filters used to query ConfigMap was wrong. Issue-ID: OPTFRA-461 Signed-off-by: Dileep Ranganathan Change-Id: I14807f7b254ccc0636b5cef6d58b4b6cc0c0e375 --- vnfs/DAaaS/microservices/collectd-operator/Makefile | 12 ++++++------ .../deploy/crds/cpu_collectdplugin_cr.yaml | 14 ++++++++++++++ .../deploy/crds/memory_collectdplugin_cr.yaml | 14 ++++++++++++++ .../deploy/crds/onap_v1alpha1_collectdplugin_cr.yaml | 10 ---------- .../microservices/collectd-operator/deploy/operator.yaml | 2 +- .../collectd-operator/deploy/role_binding.yaml | 1 + .../controller/collectdplugin/collectdplugin_controller.go | 8 ++++---- 7 files changed, 40 insertions(+), 21 deletions(-) create mode 100644 vnfs/DAaaS/microservices/collectd-operator/deploy/crds/cpu_collectdplugin_cr.yaml create mode 100644 vnfs/DAaaS/microservices/collectd-operator/deploy/crds/memory_collectdplugin_cr.yaml delete mode 100644 vnfs/DAaaS/microservices/collectd-operator/deploy/crds/onap_v1alpha1_collectdplugin_cr.yaml diff --git a/vnfs/DAaaS/microservices/collectd-operator/Makefile b/vnfs/DAaaS/microservices/collectd-operator/Makefile index 0b07b4b7..e3269b46 100644 --- a/vnfs/DAaaS/microservices/collectd-operator/Makefile +++ b/vnfs/DAaaS/microservices/collectd-operator/Makefile @@ -13,16 +13,16 @@ BUILD := $(shell git rev-parse --short HEAD) PROJECTNAME := $(shell basename "$(PWD)") GOPATH := $(shell realpath "$(PWD)/../../../../../../") -COP = ${PWD}/build/_output/bin/collectd-operator -IMAGE_NAME = dcr.cluster.local/collectd-operator:latest +COP := ${PWD}/build/_output/bin/collectd-operator +IMAGE_NAME := collectd-operator:latest export GOPATH ... export GO111MODULE=on .PHONY: clean plugins -## all: Generate the k8s and openapi artifacts using operator-sdk -all: clean vendor +## build: Generate the k8s and openapi artifacts using operator-sdk +build: clean vendor GOOS=linux GOARCH=amd64 operator-sdk generate k8s --verbose operator-sdk generate openapi --verbose @@ -33,8 +33,8 @@ all: clean vendor # no need to create a static binary with additional flags. However, for generating binary, additional build flags are necessary. This if used with # mock plugin errors out for unit tests. So the seperation avoids the error. -## build: clean the -build: clean test cover +## all: Delete the image, binary, complete build, test and run coverage +all: build test cover deploy: build publish vendor: @go mod vendor diff --git a/vnfs/DAaaS/microservices/collectd-operator/deploy/crds/cpu_collectdplugin_cr.yaml b/vnfs/DAaaS/microservices/collectd-operator/deploy/crds/cpu_collectdplugin_cr.yaml new file mode 100644 index 00000000..fb168c7a --- /dev/null +++ b/vnfs/DAaaS/microservices/collectd-operator/deploy/crds/cpu_collectdplugin_cr.yaml @@ -0,0 +1,14 @@ +apiVersion: onap.org/v1alpha1 +kind: CollectdPlugin +metadata: + name: cpu +spec: + # Add fields here + pluginName: "cpu" + pluginConf: | + + Interval 5 + ReportByState false + ReportByCpu false + + \ No newline at end of file diff --git a/vnfs/DAaaS/microservices/collectd-operator/deploy/crds/memory_collectdplugin_cr.yaml b/vnfs/DAaaS/microservices/collectd-operator/deploy/crds/memory_collectdplugin_cr.yaml new file mode 100644 index 00000000..ee051ed3 --- /dev/null +++ b/vnfs/DAaaS/microservices/collectd-operator/deploy/crds/memory_collectdplugin_cr.yaml @@ -0,0 +1,14 @@ +apiVersion: onap.org/v1alpha1 +kind: CollectdPlugin +metadata: + name: memory +spec: + # Add fields here + pluginName: "memory" + pluginConf: | + + Interval 30 + ValuesAbsolute false + ValuesPercentage true + + \ No newline at end of file diff --git a/vnfs/DAaaS/microservices/collectd-operator/deploy/crds/onap_v1alpha1_collectdplugin_cr.yaml b/vnfs/DAaaS/microservices/collectd-operator/deploy/crds/onap_v1alpha1_collectdplugin_cr.yaml deleted file mode 100644 index a4684293..00000000 --- a/vnfs/DAaaS/microservices/collectd-operator/deploy/crds/onap_v1alpha1_collectdplugin_cr.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: onap.org/v1alpha1 -kind: CollectdPlugin -metadata: - name: example-collectdplugin -spec: - # Add fields here - pluginName: "cpu" - pluginConf: | - - diff --git a/vnfs/DAaaS/microservices/collectd-operator/deploy/operator.yaml b/vnfs/DAaaS/microservices/collectd-operator/deploy/operator.yaml index 108719ab..b39543ec 100644 --- a/vnfs/DAaaS/microservices/collectd-operator/deploy/operator.yaml +++ b/vnfs/DAaaS/microservices/collectd-operator/deploy/operator.yaml @@ -16,7 +16,7 @@ spec: containers: - name: collectd-operator # Replace this with the built image name - image: dcr.cluster.local:31976/collectd-operator:latest + image: dcr.cluster.local:32644/collectd-operator:latest command: - collectd-operator imagePullPolicy: Always diff --git a/vnfs/DAaaS/microservices/collectd-operator/deploy/role_binding.yaml b/vnfs/DAaaS/microservices/collectd-operator/deploy/role_binding.yaml index 5f425081..09da2923 100644 --- a/vnfs/DAaaS/microservices/collectd-operator/deploy/role_binding.yaml +++ b/vnfs/DAaaS/microservices/collectd-operator/deploy/role_binding.yaml @@ -5,6 +5,7 @@ metadata: subjects: - kind: ServiceAccount name: collectd-operator + namespace: cop roleRef: kind: ClusterRole name: collectd-operator diff --git a/vnfs/DAaaS/microservices/collectd-operator/pkg/controller/collectdplugin/collectdplugin_controller.go b/vnfs/DAaaS/microservices/collectd-operator/pkg/controller/collectdplugin/collectdplugin_controller.go index fd35c6f1..5298258b 100644 --- a/vnfs/DAaaS/microservices/collectd-operator/pkg/controller/collectdplugin/collectdplugin_controller.go +++ b/vnfs/DAaaS/microservices/collectd-operator/pkg/controller/collectdplugin/collectdplugin_controller.go @@ -136,14 +136,14 @@ func (r *ReconcileCollectdPlugin) Reconcile(request reconcile.Request) (reconcil if err := controllerutil.SetControllerReference(instance, cm, r.scheme); err != nil { return reconcile.Result{}, err } - // Set CollectdConf instance as the owner and controller + // Set CollectdPlugin instance as the owner and controller if err := controllerutil.SetControllerReference(instance, ds, r.scheme); err != nil { return reconcile.Result{}, err } // Update the ConfigMap with new Spec and reload DaemonSets reqLogger.Info("Updating the ConfigMap", "ConfigMap.Namespace", cm.Namespace, "ConfigMap.Name", cm.Name) - log.Info("Map: ", cm.Data) + log.Info("ConfigMap Data", "Map: ", cm.Data) err = r.client.Update(context.TODO(), cm) if err != nil { return reconcile.Result{}, err @@ -180,14 +180,14 @@ func findResourceMapForCR(r *ReconcileCollectdPlugin, cr *onapv1alpha1.CollectdP } // Select DaemonSets with label app=collectd - dsList := &extensionsv1beta1.DaemonSet{} + dsList := &extensionsv1beta1.DaemonSetList{} err = r.client.List(context.TODO(), opts, dsList) if err != nil { return rmap, err } rmap.configMap = &cmList.Items[0] - rmap.daemonSet = dsList + rmap.daemonSet = &dsList.Items[0] return rmap, err } -- cgit 1.2.3-korg