Skip to content

Commit 27f0ca1

Browse files
committed
EVEREST-1182 fix install of everest operator (#461)
* EVEREST-1182 fix install of everest operator We introduced this phase check because OLM has a bug where it sometimes creates duplicate InstallPlans for the same CSV and we found a few cases where the duplicate InstallPlan wasn't reconciled correctly and abandoned by OLM. This abandoned InstallPlan was missing the status field meaning it was also missing the necessary plan to install the operator. Approving this InstallPlan would cause the operator to never be installed. By checking the phase we make sure we will be approving an InstallPlan that is actually ready to be approved. See operator-framework/kubectl-operator#13 for more details on a similar issue. * EVEREST-1182 fix idempotency of the install command
1 parent ca9074a commit 27f0ca1

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

pkg/kubernetes/kubernetes.go

+16-1
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,22 @@ func (k *Kubernetes) getTargetInstallPlanName(ctx context.Context, subscription
586586
}
587587
for _, ip := range ipList.Items {
588588
for _, csv := range ip.Spec.ClusterServiceVersionNames {
589-
if csv == targetCSV {
589+
// If the CSV is the one we are looking for and the InstallPlan is
590+
// waiting for approval, we return it.
591+
// We introduced this phase check because OLM has a bug where it
592+
// sometimes creates duplicate InstallPlans for the same CSV and we
593+
// found a few cases where the duplicate InstallPlan wasn't
594+
// reconciled correctly and abandoned by OLM. This abandoned
595+
// InstallPlan was missing the status field meaning it was also
596+
// missing the necessary plan to install the operator. Approving
597+
// this InstallPlan would cause the operator to never be installed.
598+
// By checking the phase we make sure we will be approving an
599+
// InstallPlan that is actually ready to be approved.
600+
// See https://github.com/operator-framework/kubectl-operator/issues/13
601+
// for more details on a similar issue.
602+
// We also need to return the InstallPlan if the Phase is Complete
603+
// to ensure the idempotency of the InstallOperator function.
604+
if csv == targetCSV && (ip.Status.Phase == olmv1alpha1.InstallPlanPhaseRequiresApproval || ip.Status.Phase == olmv1alpha1.InstallPlanPhaseComplete) {
590605
return ip.GetName(), nil
591606
}
592607
}

0 commit comments

Comments
 (0)