Skip to content

Commit 96970e9

Browse files
[v1.3.x] Bug 1921458: run bundle-upgrade should handle error gracefully when a previous operator version doesn't exist (#4451)
* `run bundle-upgrade` command will handle error gracefully if the previous operator version doesn't exist in the cluster Signed-off-by: rashmigottipati <[email protected]>
1 parent 4bee54f commit 96970e9

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
entries:
2+
- description: >
3+
`run bundle-upgrade` handles error gracefully when a previous operator version doesn't exist
4+
kind: bugfix

internal/olm/operator/registry/operator_installer.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package registry
1616

1717
import (
1818
"context"
19+
"errors"
1920
"fmt"
2021
"time"
2122

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

112+
// If there are no subscriptions found, then the previous operator version doesn't exist, so return error
113+
if len(subList.Items) == 0 {
114+
return nil, errors.New("no existing operator found in the cluster to upgrade")
115+
}
116+
111117
var subscription *v1alpha1.Subscription
112118
for i := range subList.Items {
113119
s := subList.Items[i]

0 commit comments

Comments
 (0)