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 <dileep.ranganathan@intel.com>
Change-Id: I14807f7b254ccc0636b5cef6d58b4b6cc0c0e375
PROJECTNAME := $(shell basename "$(PWD)")
GOPATH := $(shell realpath "$(PWD)/../../../../../../")
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
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
GOOS=linux GOARCH=amd64
operator-sdk generate k8s --verbose
operator-sdk generate openapi --verbose
# 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.
# 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
deploy: build publish
vendor:
@go mod vendor
apiVersion: onap.org/v1alpha1
kind: CollectdPlugin
metadata:
apiVersion: onap.org/v1alpha1
kind: CollectdPlugin
metadata:
- name: example-collectdplugin
spec:
# Add fields here
pluginName: "cpu"
pluginConf: |
<Plugin "cpu">
spec:
# Add fields here
pluginName: "cpu"
pluginConf: |
<Plugin "cpu">
+ Interval 5
+ ReportByState false
+ ReportByCpu false
+
\ No newline at end of file
--- /dev/null
+apiVersion: onap.org/v1alpha1
+kind: CollectdPlugin
+metadata:
+ name: memory
+spec:
+ # Add fields here
+ pluginName: "memory"
+ pluginConf: |
+ <Plugin "memory">
+ Interval 30
+ ValuesAbsolute false
+ ValuesPercentage true
+ </Plugin>
+
\ No newline at end of file
containers:
- name: collectd-operator
# Replace this with the built image name
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
command:
- collectd-operator
imagePullPolicy: Always
subjects:
- kind: ServiceAccount
name: collectd-operator
subjects:
- kind: ServiceAccount
name: collectd-operator
roleRef:
kind: ClusterRole
name: collectd-operator
roleRef:
kind: ClusterRole
name: collectd-operator
if err := controllerutil.SetControllerReference(instance, cm, r.scheme); err != nil {
return reconcile.Result{}, err
}
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)
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
err = r.client.Update(context.TODO(), cm)
if err != nil {
return reconcile.Result{}, err
}
// Select DaemonSets with label app=collectd
}
// 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]
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]