"github.com/go-logr/logr"
"github.com/operator-framework/operator-sdk/pkg/predicate"
- onapv1alpha1 "demo/vnfs/DAaaS/microservices/collectd-operator/pkg/apis/onap/v1alpha1"
- collectdutils "demo/vnfs/DAaaS/microservices/collectd-operator/pkg/controller/utils"
+ onapv1alpha1 "collectd-operator/pkg/apis/onap/v1alpha1"
+ collectdutils "collectd-operator/pkg/controller/utils"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
- extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/util/retry"
var log = logf.Log.WithName("controller_collectdplugin")
-
// Add creates a new CollectdPlugin Controller and adds it to the Manager. The Manager will set fields on the Controller
// and Start it when the Manager is Started.
func Add(mgr manager.Manager) error {
err = c.Watch(
&source.Kind{Type: &appsv1.DaemonSet{}},
&handler.EnqueueRequestsFromMapFunc{
- ToRequests: handler.ToRequestsFunc(func (a handler.MapObject) []reconcile.Request {
+ ToRequests: handler.ToRequestsFunc(func(a handler.MapObject) []reconcile.Request {
labelSelector, err := collectdutils.GetWatchLabels()
labels := strings.Split(labelSelector, "=")
if err != nil {
}
rcp := r.(*ReconcileCollectdPlugin)
// Select the Daemonset with labelSelector (Defautl is app=collectd)
- if a.Meta.GetLabels()[labels[0]] == labels[1] {
+ if a.Meta.GetLabels()[labels[0]] == labels[1] {
var requests []reconcile.Request
cpList, err := collectdutils.GetCollectdPluginList(rcp.client, a.Meta.GetNamespace())
if err != nil {
return nil
}
-
// blank assignment to verify that ReconcileCollectdPlugin implements reconcile.Reconciler
var _ reconcile.Reconciler = &ReconcileCollectdPlugin{}
scheme *runtime.Scheme
}
-
// Reconcile reads that state of the cluster for a CollectdPlugin object and makes changes based on the state read
// and what is in the CollectdPlugin.Spec
// TODO(user): Modify this Reconcile function to implement your Controller logic. This example creates
// Retrieve the latest version of Daemonset before attempting update
// RetryOnConflict uses exponential backoff to avoid exhausting the apiserver
// Select DaemonSets with label
- dsList := &extensionsv1beta1.DaemonSetList{}
+ dsList := &appsv1.DaemonSetList{}
opts := &client.ListOptions{}
labelSelector, err := collectdutils.GetWatchLabels()
if err != nil {