Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v1.3.x] Bug 1921458: run bundle-upgrade should handle error gracefully when a previous operator version doesn't exist #4451

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog/fragments/bugfix-run-bundle-upgrade.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
entries:
- description: >
`run bundle-upgrade` handles error gracefully when a previous operator version doesn't exist
kind: bugfix
6 changes: 6 additions & 0 deletions internal/olm/operator/registry/operator_installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package registry

import (
"context"
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -108,6 +109,11 @@ func (o OperatorInstaller) UpgradeOperator(ctx context.Context) (*v1alpha1.Clust
return nil, fmt.Errorf("error getting list of subscriptions: %v", err)
}

// If there are no subscriptions found, then the previous operator version doesn't exist, so return error
if len(subList.Items) == 0 {
return nil, errors.New("no existing operator found in the cluster to upgrade")
}

var subscription *v1alpha1.Subscription
for i := range subList.Items {
s := subList.Items[i]
Expand Down