From 625d72bbacff95caabff489e8d235ff0d5571f3d Mon Sep 17 00:00:00 2001 From: Moritz Clasmeier Date: Fri, 15 May 2026 10:43:46 +0200 Subject: [PATCH 1/4] Better error reporting on the OLM-installation path --- internal/deployer/operator_olm.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/internal/deployer/operator_olm.go b/internal/deployer/operator_olm.go index 99fc63f5..80e1289a 100644 --- a/internal/deployer/operator_olm.go +++ b/internal/deployer/operator_olm.go @@ -20,6 +20,10 @@ const ( operatorIndexImage = "quay.io/rhacs-eng/stackrox-operator-index" ) +var ( + namespacedSubscriptionName = operatorNamespace + "/" + subscriptionName +) + // OperatorDeploymentMode represents how the operator is deployed type OperatorDeploymentMode bool @@ -65,7 +69,7 @@ func (d *Deployer) deployOperatorViaOLM(ctx context.Context) error { } if err := d.waitForOperatorReady(ctx, operatorNamespace, operatorDeploymentName, 300); err != nil { - return fmt.Errorf("failed waiting for operator: %w", err) + return fmt.Errorf("failed waiting for operator in namespace %s to become ready: %w", operatorNamespace, err) } d.logger.Success("🎉 Operator deployed successfully via OLM!") @@ -226,7 +230,7 @@ func (d *Deployer) createSubscription(ctx context.Context) error { Stdin: bytes.NewReader(yamlData), }) if err != nil { - return fmt.Errorf("failed to create Subscription: %w", err) + return fmt.Errorf("failed to create Subscription %s: %w", namespacedSubscriptionName, err) } d.logger.Success("✓ Subscription created") @@ -253,9 +257,7 @@ func (d *Deployer) waitForAndApproveInstallPlan(ctx context.Context) error { } if time.Since(start) >= timeout { - // TODO(ROX-34499): some more info on what was wrong would be useful: a dump of the - // subscription or at least its name so that the user can investigate - return errors.New("timeout waiting for InstallPlan to be created") + return fmt.Errorf("timeout waiting for InstallPlan to be created for Subscription %s", namespacedSubscriptionName) } // Sanity check:Verify currentCSV matches expected version. @@ -264,12 +266,12 @@ func (d *Deployer) waitForAndApproveInstallPlan(ctx context.Context) error { Args: []string{"get", "subscription", subscriptionName, "-n", operatorNamespace, "-o", "jsonpath={.status.currentCSV}"}, }) if err != nil { - return fmt.Errorf("failed to get current CSV from subscription: %w", err) + return fmt.Errorf("failed to get current CSV from Subscription %s: %w", namespacedSubscriptionName, err) } currentCSV := strings.TrimSpace(result.Stdout) if currentCSV != expectedCSV { - return fmt.Errorf("subscription progressing to unexpected CSV '%s', expected '%s'", currentCSV, expectedCSV) + return fmt.Errorf("Subscription %s progressing to unexpected CSV '%s', expected '%s'", namespacedSubscriptionName, currentCSV, expectedCSV) } // Get InstallPlan name. @@ -277,7 +279,7 @@ func (d *Deployer) waitForAndApproveInstallPlan(ctx context.Context) error { Args: []string{"get", "subscription", subscriptionName, "-n", operatorNamespace, "-o", "jsonpath={.status.installPlanRef.name}"}, }) if err != nil { - return fmt.Errorf("failed to get InstallPlan name: %w", err) + return fmt.Errorf("failed to get InstallPlan name from Subscription %s: %w", namespacedSubscriptionName, err) } installPlanName := strings.TrimSpace(result.Stdout) @@ -292,7 +294,7 @@ func (d *Deployer) waitForAndApproveInstallPlan(ctx context.Context) error { Args: []string{"patch", "installplan", installPlanName, "-n", operatorNamespace, "--type", "merge", "-p", `{"spec":{"approved":true}}`}, }) if err != nil { - return fmt.Errorf("failed to approve InstallPlan: %w", err) + return fmt.Errorf("failed to approve InstallPlan %s for Subscription %s: %w", installPlanName, namespacedSubscriptionName, err) } d.logger.Success("✓ InstallPlan approved") @@ -325,8 +327,7 @@ func (d *Deployer) waitForCSVSuccess(ctx context.Context) error { time.Sleep(5 * time.Second) } - // TODO(ROX-34499): same as above - return fmt.Errorf("timeout waiting for CSV to succeed") + return fmt.Errorf("timeout waiting for CSV %s to succeed", csvName) } // detectOperatorDeploymentMode detects how the operator is currently deployed. From 6e21d87c970a47f87ff68c230a6b9f3a2f135129 Mon Sep 17 00:00:00 2001 From: Moritz Clasmeier Date: Fri, 15 May 2026 10:52:26 +0200 Subject: [PATCH 2/4] Linter exception --- internal/deployer/operator_olm.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/deployer/operator_olm.go b/internal/deployer/operator_olm.go index 80e1289a..77b46b54 100644 --- a/internal/deployer/operator_olm.go +++ b/internal/deployer/operator_olm.go @@ -271,7 +271,7 @@ func (d *Deployer) waitForAndApproveInstallPlan(ctx context.Context) error { currentCSV := strings.TrimSpace(result.Stdout) if currentCSV != expectedCSV { - return fmt.Errorf("Subscription %s progressing to unexpected CSV '%s', expected '%s'", namespacedSubscriptionName, currentCSV, expectedCSV) + return fmt.Errorf("Subscription %s progressing to unexpected CSV '%s', expected '%s'", namespacedSubscriptionName, currentCSV, expectedCSV) //nolint:staticcheck // ST1005: capitalized for Kubernetes resource kind } // Get InstallPlan name. From 01a6f0e85b3970f03be11d6977e1f4b175f31250 Mon Sep 17 00:00:00 2001 From: Moritz Clasmeier <111092021+mclasmeier@users.noreply.github.com> Date: Fri, 15 May 2026 12:00:41 +0200 Subject: [PATCH 3/4] Apply suggestion from @msugakov Co-authored-by: Misha Sugakov <537715+msugakov@users.noreply.github.com> --- internal/deployer/operator_olm.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/deployer/operator_olm.go b/internal/deployer/operator_olm.go index 77b46b54..d6960556 100644 --- a/internal/deployer/operator_olm.go +++ b/internal/deployer/operator_olm.go @@ -271,7 +271,7 @@ func (d *Deployer) waitForAndApproveInstallPlan(ctx context.Context) error { currentCSV := strings.TrimSpace(result.Stdout) if currentCSV != expectedCSV { - return fmt.Errorf("Subscription %s progressing to unexpected CSV '%s', expected '%s'", namespacedSubscriptionName, currentCSV, expectedCSV) //nolint:staticcheck // ST1005: capitalized for Kubernetes resource kind + return fmt.Errorf("detected Subscription %s progressing to unexpected CSV '%s', expected '%s'", namespacedSubscriptionName, currentCSV, expectedCSV) } // Get InstallPlan name. From bbc248fd05bfcc543f9221eba765409a214d7ba6 Mon Sep 17 00:00:00 2001 From: Moritz Clasmeier Date: Fri, 15 May 2026 12:01:20 +0200 Subject: [PATCH 4/4] var -> const --- internal/deployer/operator_olm.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/internal/deployer/operator_olm.go b/internal/deployer/operator_olm.go index 77b46b54..058ab920 100644 --- a/internal/deployer/operator_olm.go +++ b/internal/deployer/operator_olm.go @@ -13,14 +13,11 @@ import ( ) const ( - catalogSourceName = "stackrox-operator-index" - subscriptionName = "stackrox-operator-subscription" - operatorGroupName = "all-namespaces-operator-group" - operatorChannel = "latest" - operatorIndexImage = "quay.io/rhacs-eng/stackrox-operator-index" -) - -var ( + catalogSourceName = "stackrox-operator-index" + subscriptionName = "stackrox-operator-subscription" + operatorGroupName = "all-namespaces-operator-group" + operatorChannel = "latest" + operatorIndexImage = "quay.io/rhacs-eng/stackrox-operator-index" namespacedSubscriptionName = operatorNamespace + "/" + subscriptionName )