Skip to content

Commit 625d72b

Browse files
author
Moritz Clasmeier
committed
Better error reporting on the OLM-installation path
1 parent 742ca02 commit 625d72b

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

internal/deployer/operator_olm.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ const (
2020
operatorIndexImage = "quay.io/rhacs-eng/stackrox-operator-index"
2121
)
2222

23+
var (
24+
namespacedSubscriptionName = operatorNamespace + "/" + subscriptionName
25+
)
26+
2327
// OperatorDeploymentMode represents how the operator is deployed
2428
type OperatorDeploymentMode bool
2529

@@ -65,7 +69,7 @@ func (d *Deployer) deployOperatorViaOLM(ctx context.Context) error {
6569
}
6670

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

7175
d.logger.Success("🎉 Operator deployed successfully via OLM!")
@@ -226,7 +230,7 @@ func (d *Deployer) createSubscription(ctx context.Context) error {
226230
Stdin: bytes.NewReader(yamlData),
227231
})
228232
if err != nil {
229-
return fmt.Errorf("failed to create Subscription: %w", err)
233+
return fmt.Errorf("failed to create Subscription %s: %w", namespacedSubscriptionName, err)
230234
}
231235

232236
d.logger.Success("✓ Subscription created")
@@ -253,9 +257,7 @@ func (d *Deployer) waitForAndApproveInstallPlan(ctx context.Context) error {
253257
}
254258

255259
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")
260+
return fmt.Errorf("timeout waiting for InstallPlan to be created for Subscription %s", namespacedSubscriptionName)
259261
}
260262

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

270272
currentCSV := strings.TrimSpace(result.Stdout)
271273
if currentCSV != expectedCSV {
272-
return fmt.Errorf("subscription progressing to unexpected CSV '%s', expected '%s'", currentCSV, expectedCSV)
274+
return fmt.Errorf("Subscription %s progressing to unexpected CSV '%s', expected '%s'", namespacedSubscriptionName, currentCSV, expectedCSV)
273275
}
274276

275277
// Get InstallPlan name.
276278
result, err = d.runKubectl(ctx, k8s.KubectlOptions{
277279
Args: []string{"get", "subscription", subscriptionName, "-n", operatorNamespace, "-o", "jsonpath={.status.installPlanRef.name}"},
278280
})
279281
if err != nil {
280-
return fmt.Errorf("failed to get InstallPlan name: %w", err)
282+
return fmt.Errorf("failed to get InstallPlan name from Subscription %s: %w", namespacedSubscriptionName, err)
281283
}
282284

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

298300
d.logger.Success("✓ InstallPlan approved")
@@ -325,8 +327,7 @@ func (d *Deployer) waitForCSVSuccess(ctx context.Context) error {
325327
time.Sleep(5 * time.Second)
326328
}
327329

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

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

0 commit comments

Comments
 (0)