Skip to content

Commit

Permalink
Instance Stopped Condition wait for lb Deletion. (#342)
Browse files Browse the repository at this point in the history
In this commit we fix a customer issue that occured when a lb was stopped and then started before the lb had a chance to be deleted. The lb was never created. Now, we wait for the lb to be deleted before setting the instance stopped condition.

Bug: b/288463863
Change-Id: Ic9e5906c355496c98382e72ed4405c2245f603a5

Co-authored-by: Tabatha Lewis <tabathal@google.com>
  • Loading branch information
tabbyl21 and tabbyl21 committed Jul 14, 2023
1 parent 20233ee commit d094968
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions oracle/controllers/instancecontroller/instance_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/google/go-cmp/cmp"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -467,6 +468,13 @@ func (r *InstanceReconciler) reconcileInstanceStop(ctx context.Context, req ctrl
if err := r.Get(ctx, req.NamespacedName, &inst); err != nil {
return ctrl.Result{}, client.IgnoreNotFound(err)
}
ilb := InstanceLB(inst)

if err := r.Get(ctx, client.ObjectKeyFromObject(ilb), ilb); err == nil {
return ctrl.Result{}, nil
} else if !apierrors.IsNotFound(err) {
return ctrl.Result{}, err
}
r.recordEventAndUpdateStatus(ctx, &inst, v1.ConditionTrue, k8s.InstanceStopped, "Instance has been stopped", log)

return ctrl.Result{Requeue: false}, nil
Expand Down

0 comments on commit d094968

Please sign in to comment.