Skip to content

Commit

Permalink
EVEREST-1182 fix install of everest operator (#461)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
recharte authored Jun 27, 2024
1 parent 622ace2 commit e04e882
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion pkg/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,22 @@ func (k *Kubernetes) getTargetInstallPlanName(ctx context.Context, subscription
}
for _, ip := range ipList.Items {
for _, csv := range ip.Spec.ClusterServiceVersionNames {
if csv == targetCSV {
// If the CSV is the one we are looking for and the InstallPlan is
// waiting for approval, we return it.
// 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 https://github.com/operator-framework/kubectl-operator/issues/13
// for more details on a similar issue.
// We also need to return the InstallPlan if the Phase is Complete
// to ensure the idempotency of the InstallOperator function.
if csv == targetCSV && (ip.Status.Phase == olmv1alpha1.InstallPlanPhaseRequiresApproval || ip.Status.Phase == olmv1alpha1.InstallPlanPhaseComplete) {
return ip.GetName(), nil
}
}
Expand Down

0 comments on commit e04e882

Please sign in to comment.