Skip to content

Commit

Permalink
Workaround CSV resolution issues by restarting OLM pods
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanemerson committed Dec 5, 2023
1 parent 08f59f6 commit 1149f16
Showing 1 changed file with 30 additions and 9 deletions.
39 changes: 30 additions & 9 deletions test/e2e/utils/olm.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,9 @@ func (k TestKubernetes) CleanupOLMTest(t *testing.T, testIdentifier, subName, su
// Print latest Operator logs
k.WriteAllResourcesToFile(dir, subNamespace, "Pod", &corev1.PodList{}, map[string]string{"app.kubernetes.io/name": "infinispan-operator"})
// OLM Operator Logs
var olmNs string
if k.NamespaceExists("olm") {
olmNs = "olm"
} else {
olmNs = "openshift-operator-lifecycle-manager"
}
k.WriteAllResourcesToFile(dir, olmNs, "Pod", &corev1.PodList{}, map[string]string{"app": "olm-operator"})
k.WriteAllResourcesToFile(dir, olmNs, "Pod", &corev1.PodList{}, map[string]string{"app": "catalog-operator"})
olmNamespace := k.OLMNamespace()
k.WriteAllResourcesToFile(dir, olmNamespace, "Pod", &corev1.PodList{}, map[string]string{"app": "olm-operator"})
k.WriteAllResourcesToFile(dir, olmNamespace, "Pod", &corev1.PodList{}, map[string]string{"app": "catalog-operator"})
}

// Cleanup OLM resources
Expand Down Expand Up @@ -358,8 +353,27 @@ func (k TestKubernetes) WaitForSubscription(sub *coreos.Subscription, predicate
for _, condition := range sub.Status.Conditions {
// Delete CSV and retry polling on ResolutionFailed
// https://github.com/operator-framework/operator-lifecycle-manager/issues/2201
// https://issues.redhat.com/browse/OCPBUGS-5080
if condition.Type == "ResolutionFailed" && condition.Status == corev1.ConditionTrue {
k.DeleteCSV(sub.Status.CurrentCSV, sub.Namespace)
// Restart OLM pods to clear the cache
olmNamespace := k.OLMNamespace()
ExpectNoError(
k.Kubernetes.Client.DeleteAllOf(
context.TODO(),
&corev1.Pod{},
client.InNamespace(olmNamespace),
client.MatchingLabels(map[string]string{"app": "olm-operator"}),
),
)

ExpectNoError(
k.Kubernetes.Client.DeleteAllOf(
context.TODO(),
&corev1.Pod{},
client.InNamespace(olmNamespace),
client.MatchingLabels(map[string]string{"app": "catalog-operator"}),
),
)
err = poll()
break
}
Expand All @@ -377,6 +391,13 @@ func (k TestKubernetes) WaitForCSVSucceeded(sub *coreos.Subscription) {
ExpectNoError(err)
}

func (k TestKubernetes) OLMNamespace() string {
if k.NamespaceExists("olm") {
return "olm"
}
return "openshift-operator-lifecycle-manager"
}

func retryOnConflict(update func() error) {
err := wait.Poll(DefaultPollPeriod, MaxWaitTimeout, func() (done bool, err error) {
err = update()
Expand Down

0 comments on commit 1149f16

Please sign in to comment.