Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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