Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not deepcopy, instance can be nil #1185

Merged
merged 2 commits into from
Dec 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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