Skip to content

Commit b706834

Browse files
mclasmeierMoritz Clasmeiermsugakov
authored
Better error reporting on the OLM-installation path (#185)
Co-authored-by: Moritz Clasmeier <mclasmeier@redhat.com> Co-authored-by: Misha Sugakov <537715+msugakov@users.noreply.github.com>
1 parent a46a9e5 commit b706834

1 file changed

Lines changed: 14 additions & 16 deletions

File tree

internal/deployer/operator_olm.go

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ import (
1313
)
1414

1515
const (
16-
catalogSourceName = "stackrox-operator-index"
17-
subscriptionName = "stackrox-operator-subscription"
18-
operatorGroupName = "all-namespaces-operator-group"
19-
operatorChannel = "latest"
20-
operatorIndexImage = "quay.io/rhacs-eng/stackrox-operator-index"
16+
catalogSourceName = "stackrox-operator-index"
17+
subscriptionName = "stackrox-operator-subscription"
18+
operatorGroupName = "all-namespaces-operator-group"
19+
operatorChannel = "latest"
20+
operatorIndexImage = "quay.io/rhacs-eng/stackrox-operator-index"
21+
namespacedSubscriptionName = operatorNamespace + "/" + subscriptionName
2122
)
2223

2324
// OperatorDeploymentMode represents how the operator is deployed
@@ -65,7 +66,7 @@ func (d *Deployer) deployOperatorViaOLM(ctx context.Context) error {
6566
}
6667

6768
if err := d.waitForOperatorReady(ctx, operatorNamespace, operatorDeploymentName, 300); err != nil {
68-
return fmt.Errorf("failed waiting for operator: %w", err)
69+
return fmt.Errorf("failed waiting for operator in namespace %s to become ready: %w", operatorNamespace, err)
6970
}
7071

7172
d.logger.Success("🎉 Operator deployed successfully via OLM!")
@@ -226,7 +227,7 @@ func (d *Deployer) createSubscription(ctx context.Context) error {
226227
Stdin: bytes.NewReader(yamlData),
227228
})
228229
if err != nil {
229-
return fmt.Errorf("failed to create Subscription: %w", err)
230+
return fmt.Errorf("failed to create Subscription %s: %w", namespacedSubscriptionName, err)
230231
}
231232

232233
d.logger.Success("✓ Subscription created")
@@ -253,9 +254,7 @@ func (d *Deployer) waitForAndApproveInstallPlan(ctx context.Context) error {
253254
}
254255

255256
if time.Since(start) >= timeout {
256-
// TODO(ROX-34499): some more info on what was wrong would be useful: a dump of the
257-
// subscription or at least its name so that the user can investigate
258-
return errors.New("timeout waiting for InstallPlan to be created")
257+
return fmt.Errorf("timeout waiting for InstallPlan to be created for Subscription %s", namespacedSubscriptionName)
259258
}
260259

261260
// Sanity check:Verify currentCSV matches expected version.
@@ -264,20 +263,20 @@ func (d *Deployer) waitForAndApproveInstallPlan(ctx context.Context) error {
264263
Args: []string{"get", "subscription", subscriptionName, "-n", operatorNamespace, "-o", "jsonpath={.status.currentCSV}"},
265264
})
266265
if err != nil {
267-
return fmt.Errorf("failed to get current CSV from subscription: %w", err)
266+
return fmt.Errorf("failed to get current CSV from Subscription %s: %w", namespacedSubscriptionName, err)
268267
}
269268

270269
currentCSV := strings.TrimSpace(result.Stdout)
271270
if currentCSV != expectedCSV {
272-
return fmt.Errorf("subscription progressing to unexpected CSV '%s', expected '%s'", currentCSV, expectedCSV)
271+
return fmt.Errorf("detected Subscription %s progressing to unexpected CSV '%s', expected '%s'", namespacedSubscriptionName, currentCSV, expectedCSV)
273272
}
274273

275274
// Get InstallPlan name.
276275
result, err = d.runKubectl(ctx, k8s.KubectlOptions{
277276
Args: []string{"get", "subscription", subscriptionName, "-n", operatorNamespace, "-o", "jsonpath={.status.installPlanRef.name}"},
278277
})
279278
if err != nil {
280-
return fmt.Errorf("failed to get InstallPlan name: %w", err)
279+
return fmt.Errorf("failed to get InstallPlan name from Subscription %s: %w", namespacedSubscriptionName, err)
281280
}
282281

283282
installPlanName := strings.TrimSpace(result.Stdout)
@@ -292,7 +291,7 @@ func (d *Deployer) waitForAndApproveInstallPlan(ctx context.Context) error {
292291
Args: []string{"patch", "installplan", installPlanName, "-n", operatorNamespace, "--type", "merge", "-p", `{"spec":{"approved":true}}`},
293292
})
294293
if err != nil {
295-
return fmt.Errorf("failed to approve InstallPlan: %w", err)
294+
return fmt.Errorf("failed to approve InstallPlan %s for Subscription %s: %w", installPlanName, namespacedSubscriptionName, err)
296295
}
297296

298297
d.logger.Success("✓ InstallPlan approved")
@@ -325,8 +324,7 @@ func (d *Deployer) waitForCSVSuccess(ctx context.Context) error {
325324
time.Sleep(5 * time.Second)
326325
}
327326

328-
// TODO(ROX-34499): same as above
329-
return fmt.Errorf("timeout waiting for CSV to succeed")
327+
return fmt.Errorf("timeout waiting for CSV %s to succeed", csvName)
330328
}
331329

332330
// detectOperatorDeploymentMode detects how the operator is currently deployed.

0 commit comments

Comments
 (0)