Skip to content

Commit

Permalink
Do not deepcopy, instance can be nil (#1185)
Browse files Browse the repository at this point in the history
  • Loading branch information
alenkacz authored and kensipe committed Dec 16, 2019
1 parent 537dc98 commit ef07673
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions pkg/controller/instance/instance_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,14 @@ func (r *Reconciler) Reconcile(request ctrl.Request) (ctrl.Result, error) {

log.Printf("InstanceController: Received Reconcile request for instance \"%+v\"", request.Name)
instance, err := r.getInstance(request)
oldInstance := instance.DeepCopy()
if err != nil {
if apierrors.IsNotFound(err) { // not retrying if instance not found, probably someone manually removed it?
log.Printf("Instance %s was deleted, nothing to reconcile.", request.NamespacedName)
return reconcile.Result{}, nil
}
return reconcile.Result{}, err
}
oldInstance := instance.DeepCopy()

ov, err := r.getOperatorVersion(instance)
if err != nil {
Expand Down Expand Up @@ -341,7 +341,6 @@ func (r *Reconciler) handleError(err error, instance *kudov1beta1.Instance, oldI
}

// getInstance retrieves the instance by namespaced name
// returns nil, nil when instance is not found (not found is not considered an error)
func (r *Reconciler) getInstance(request ctrl.Request) (instance *kudov1beta1.Instance, err error) {
instance = &kudov1beta1.Instance{}
err = r.Get(context.TODO(), request.NamespacedName, instance)
Expand All @@ -356,7 +355,6 @@ func (r *Reconciler) getInstance(request ctrl.Request) (instance *kudov1beta1.In
}

// getOperatorVersion retrieves operatorversion belonging to the given instance
// not found is treated here as any other error
func (r *Reconciler) getOperatorVersion(instance *kudov1beta1.Instance) (ov *kudov1beta1.OperatorVersion, err error) {
ov = &kudov1beta1.OperatorVersion{}
err = r.Get(context.TODO(),
Expand Down

0 comments on commit ef07673

Please sign in to comment.