func (r *ReconcileLocalVolumeDiscovery) Reconcile(request reconcile.Request) (reconcile.Result, error) {
	reqLogger := log.WithValues("Request.Namespace", request.Namespace, "Request.Name", request.Name)
	reqLogger.Info("Reconciling LocalVolumeDiscovery")

	// Fetch the LocalVolumeDiscovery instance
	instance := &localv1alpha1.LocalVolumeDiscovery{}
	err := r.client.Get(context.TODO(), request.NamespacedName, instance)
	if err != nil {
		if errors.IsNotFound(err) {
			// Request object not found, could have been deleted after reconcile request.
			// Owned objects are automatically garbage collected. For additional cleanup logic use finalizers.
			// Return and don't requeue
			return reconcile.Result{}, nil
		}
		// Error reading the object - requeue the request.
		return reconcile.Result{}, err
	}

	diskMakerDSMutateFn := getDiskMakerDiscoveryDSMutateFn(request, instance.Spec.Tolerations, getOwnerRefs(instance), instance.Spec.NodeSelector)
	ds, opResult, err := nodedaemon.CreateOrUpdateDaemonset(r.client, diskMakerDSMutateFn)
	if err != nil {
		message := fmt.Sprintf("failed to create discovery daemonset. Error %+v", err)
		err := r.updateDiscoveryStatus(instance, operatorv1.OperatorStatusTypeDegraded, message,
			operatorv1.ConditionFalse, localv1alpha1.DiscoveryFailed)
		if err != nil {
			return reconcile.Result{}, err
		}
	} else if opResult == controllerutil.OperationResultUpdated || opResult == controllerutil.OperationResultCreated {
		reqLogger.Info("daemonset changed", "daemonset.Name", ds.GetName(), "op.Result", opResult)
	}

	desiredDaemons, readyDaemons, err := r.getDaemonSetStatus(instance.Namespace)
	if err != nil {
		reqLogger.Error(err, "failed to get discovery daemonset")
		return reconcile.Result{}, err
	}

	if desiredDaemons == 0 {
		message := "no discovery daemons are scheduled for running"
		err := r.updateDiscoveryStatus(instance, operatorv1.OperatorStatusTypeDegraded, message,
			operatorv1.ConditionFalse, localv1alpha1.DiscoveryFailed)
		if err != nil {
			return reconcile.Result{}, err
		}
		return waitForRequeueIfDaemonsNotReady, fmt.Errorf(message)

	} else if !(desiredDaemons == readyDaemons) {
		message := fmt.Sprintf("running %d out of %d discovery daemons", readyDaemons, desiredDaemons)
		err := r.updateDiscoveryStatus(instance, operatorv1.OperatorStatusTypeProgressing, message,
			operatorv1.ConditionFalse, localv1alpha1.Discovering)
		if err != nil {
			return reconcile.Result{}, err
		}
		return waitForRequeueIfDaemonsNotReady, fmt.Errorf(message)
	}

	message := fmt.Sprintf("successfully running %d out of %d discovery daemons", desiredDaemons, readyDaemons)
	err = r.updateDiscoveryStatus(instance, operatorv1.OperatorStatusTypeAvailable, message,
		operatorv1.ConditionTrue, localv1alpha1.Discovering)
	if err != nil {
		return reconcile.Result{}, err
	}

	return reconcile.Result{}, nil
}
// Reconcile reads that state of the cluster for a LocalVolumeDiscovery object and makes changes based on the state read
// and what is in the LocalVolumeDiscovery.Spec
// The Controller will requeue the Request to be processed again if the returned error is non-nil or
// Result.Requeue is true, otherwise upon completion it will remove the work from the queue.
Reconcile reads that state of the cluster for a LocalVolumeDiscovery object and makes changes based on the state read
and what is in the LocalVolumeDiscovery.Spec
The Controller will requeue the Request to be processed again if the returned error is non-nil or
Result.Requeue is true, otherwise upon completion it will remove the work from the queue.
// Reconcile reads that state of the cluster for a LocalVolumeDiscovery object and makes changes based on the state read // and what is in the LocalVolumeDiscovery . Spec // The Controller will requeue the Request to be processed again if the returned error is non - nil or // Result . Requeue is true otherwise upon completion it will remove the work from the queue .
func (r *ReconcileLocalVolumeDiscovery) Reconcile(request reconcile.Request) (reconcile.Result, error) {
	reqLogger := log.WithValues("Request.Namespace", request.Namespace, "Request.Name", request.Name)
	reqLogger.Info("Reconciling LocalVolumeDiscovery")
	instance := &localv1alpha1.LocalVolumeDiscovery{}
	err := r.client.Get(context.TODO(), request.NamespacedName, instance)
	if err != nil {
		if errors.IsNotFound(err) {
			return reconcile.Result{}, nil
		}
		return reconcile.Result{}, err
	}
	diskMakerDSMutateFn := getDiskMakerDiscoveryDSMutateFn(request, instance.Spec.Tolerations, getOwnerRefs(instance), instance.Spec.NodeSelector)
	ds, opResult, err := nodedaemon.CreateOrUpdateDaemonset(r.client, diskMakerDSMutateFn)
	if err != nil {
		message := fmt.Sprintf("failed to create discovery daemonset. Error %+v", err)
		err := r.updateDiscoveryStatus(instance, operatorv1.OperatorStatusTypeDegraded, message,
			operatorv1.ConditionFalse, localv1alpha1.DiscoveryFailed)
		if err != nil {
			return reconcile.Result{}, err
		}
	} else if opResult == controllerutil.OperationResultUpdated || opResult == controllerutil.OperationResultCreated {
		reqLogger.Info("daemonset changed", "daemonset.Name", ds.GetName(), "op.Result", opResult)
	}
	desiredDaemons, readyDaemons, err := r.getDaemonSetStatus(instance.Namespace)
	if err != nil {
		reqLogger.Error(err, "failed to get discovery daemonset")
		return reconcile.Result{}, err
	}
	if desiredDaemons == 0 {
		message := "no discovery daemons are scheduled for running"
		err := r.updateDiscoveryStatus(instance, operatorv1.OperatorStatusTypeDegraded, message,
			operatorv1.ConditionFalse, localv1alpha1.DiscoveryFailed)
		if err != nil {
			return reconcile.Result{}, err
		}
		return waitForRequeueIfDaemonsNotReady, fmt.Errorf(message)
	} else if !(desiredDaemons == readyDaemons) {
		message := fmt.Sprintf("running %d out of %d discovery daemons", readyDaemons, desiredDaemons)
		err := r.updateDiscoveryStatus(instance, operatorv1.OperatorStatusTypeProgressing, message,
			operatorv1.ConditionFalse, localv1alpha1.Discovering)
		if err != nil {
			return reconcile.Result{}, err
		}
		return waitForRequeueIfDaemonsNotReady, fmt.Errorf(message)
	}
	message := fmt.Sprintf("successfully running %d out of %d discovery daemons", desiredDaemons, readyDaemons)
	err = r.updateDiscoveryStatus(instance, operatorv1.OperatorStatusTypeAvailable, message,
		operatorv1.ConditionTrue, localv1alpha1.Discovering)
	if err != nil {
		return reconcile.Result{}, err
	}
	return reconcile.Result{}, nil
}
func ( r * ReconcileLocalVolumeDiscovery ) Reconcile ( request reconcile . Request ) ( reconcile . Result , error ) { reqLogger := log . WithValues ( " " , request . Namespace , " " , request . Name ) reqLogger . Info ( " " ) instance := & localv1alpha1 . LocalVolumeDiscovery { } err := r . client . Get ( context . TODO ( ) , request . NamespacedName , instance ) if err != nil { if errors . IsNotFound ( err ) { return reconcile . Result { } , nil } return reconcile . Result { } , err } diskMakerDSMutateFn := getDiskMakerDiscoveryDSMutateFn ( request , instance . Spec . Tolerations , getOwnerRefs ( instance ) , instance . Spec . NodeSelector ) ds , opResult , err := nodedaemon . CreateOrUpdateDaemonset ( r . client , diskMakerDSMutateFn ) if err != nil { message := fmt . Sprintf ( " " , err ) err := r . updateDiscoveryStatus ( instance , operatorv1 . OperatorStatusTypeDegraded , message , operatorv1 . ConditionFalse , localv1alpha1 . DiscoveryFailed ) if err != nil { return reconcile . Result { } , err } } else if opResult == controllerutil . OperationResultUpdated || opResult == controllerutil . OperationResultCreated { reqLogger . Info ( " " , " " , ds . GetName ( ) , " " , opResult ) } desiredDaemons , readyDaemons , err := r . getDaemonSetStatus ( instance . Namespace ) if err != nil { reqLogger . Error ( err , " " ) return reconcile . Result { } , err } if desiredDaemons == 0 { message := " " err := r . updateDiscoveryStatus ( instance , operatorv1 . OperatorStatusTypeDegraded , message , operatorv1 . ConditionFalse , localv1alpha1 . DiscoveryFailed ) if err != nil { return reconcile . Result { } , err } return waitForRequeueIfDaemonsNotReady , fmt . Errorf ( message ) } else if ! ( desiredDaemons == readyDaemons ) { message := fmt . Sprintf ( " " , readyDaemons , desiredDaemons ) err := r . updateDiscoveryStatus ( instance , operatorv1 . OperatorStatusTypeProgressing , message , operatorv1 . ConditionFalse , localv1alpha1 . Discovering ) if err != nil { return reconcile . Result { } , err } return waitForRequeueIfDaemonsNotReady , fmt . Errorf ( message ) } message := fmt . Sprintf ( " " , desiredDaemons , readyDaemons ) err = r . updateDiscoveryStatus ( instance , operatorv1 . OperatorStatusTypeAvailable , message , operatorv1 . ConditionTrue , localv1alpha1 . Discovering ) if err != nil { return reconcile . Result { } , err } return reconcile . Result { } , nil }
Reconcile reads that state of the cluster for a LocalVolumeDiscovery object and makes changes based on the state read
and what is in the LocalVolumeDiscovery.Spec
The Controller will requeue the Request to be processed again if the returned error is non-nil or
Result.Requeue is true, otherwise upon completion it will remove the work from the queue.
Reconcile reads that state of the cluster for a LocalVolumeDiscovery object and makes changes based on the state read and what is in the LocalVolumeDiscovery . Spec The Controller will requeue the Request to be processed again if the returned error is non - nil or Result . Requeue is true otherwise upon completion it will remove the work from the queue .
// Fetch the LocalVolumeDiscovery instance // Request object not found, could have been deleted after reconcile request. // Owned objects are automatically garbage collected. For additional cleanup logic use finalizers. // Return and don't requeue // Error reading the object - requeue the request.