Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions internal/deployer/operator_olm.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ 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"
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
)

// OperatorDeploymentMode represents how the operator is deployed
Expand Down Expand Up @@ -65,7 +66,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!")
Expand Down Expand Up @@ -226,7 +227,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")
Expand All @@ -253,9 +254,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.
Expand All @@ -264,20 +263,20 @@ 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("detected Subscription %s progressing to unexpected CSV '%s', expected '%s'", namespacedSubscriptionName, currentCSV, expectedCSV)
}

// Get InstallPlan name.
result, err = d.runKubectl(ctx, k8s.KubectlOptions{
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)
Expand All @@ -292,7 +291,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")
Expand Down Expand Up @@ -325,8 +324,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.
Expand Down
Loading