Skip to content

Commit 738cd76

Browse files
committed
Fix InstallPlan stale variable issue
Signed-off-by: Vu Dinh <[email protected]>
1 parent 8b81a70 commit 738cd76

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

pkg/controller/operators/catalog/operator.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -928,8 +928,10 @@ func (o *Operator) ensureInstallPlan(logger *logrus.Entry, namespace string, sub
928928
for _, sub := range subs {
929929
ownerWasAdded = ownerWasAdded || !ownerutil.EnsureOwner(installPlan, sub)
930930
}
931+
932+
out := installPlan.DeepCopy()
931933
if ownerWasAdded {
932-
_, err := o.client.OperatorsV1alpha1().InstallPlans(installPlan.GetNamespace()).Update(installPlan)
934+
out, err = o.client.OperatorsV1alpha1().InstallPlans(installPlan.GetNamespace()).Update(installPlan)
933935
if err != nil {
934936
return nil, err
935937
}
@@ -938,19 +940,18 @@ func (o *Operator) ensureInstallPlan(logger *logrus.Entry, namespace string, sub
938940
// Use provided `installPlanApproval` to determine the appropreciate
939941
// phase
940942
if installPlanApproval == v1alpha1.ApprovalAutomatic {
941-
installPlan.Status.Phase = v1alpha1.InstallPlanPhaseInstalling
943+
out.Status.Phase = v1alpha1.InstallPlanPhaseInstalling
942944
} else {
943-
logger.Info("Testing")
944-
installPlan.Status.Phase = v1alpha1.InstallPlanPhaseRequiresApproval
945+
out.Status.Phase = v1alpha1.InstallPlanPhaseRequiresApproval
945946
}
946-
for _, step := range installPlan.Status.Plan {
947+
for _, step := range out.Status.Plan {
947948
step.Status = v1alpha1.StepStatusUnknown
948949
}
949-
_, err = o.client.OperatorsV1alpha1().InstallPlans(namespace).UpdateStatus(installPlan)
950+
res, err := o.client.OperatorsV1alpha1().InstallPlans(namespace).UpdateStatus(out)
950951
if err != nil {
951952
return nil, err
952953
}
953-
return reference.GetReference(installPlan)
954+
return reference.GetReference(res)
954955
}
955956
}
956957
logger.Warn("no installplan found with matching manifests, creating new one")

test/e2e/util_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import (
4040

4141
const (
4242
pollInterval = 1 * time.Second
43-
pollDuration = 2 * time.Minute
43+
pollDuration = 5 * time.Minute
4444

4545
olmConfigMap = "olm-operators"
4646
// sync name with scripts/install_local.sh

0 commit comments

Comments
 (0)