Skip to content

Commit

Permalink
Merge pull request openshift#1628 from alvaroaleman/handle-empty
Browse files Browse the repository at this point in the history
Self image lookup: Retry on empty string
  • Loading branch information
openshift-ci[bot] authored Aug 4, 2022
2 parents 8b84dee + b54e5ff commit 260f0fe
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
16 changes: 14 additions & 2 deletions control-plane-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/discovery"
"sigs.k8s.io/controller-runtime/pkg/cache"
crclient "sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -266,8 +267,19 @@ func NewStartCommand() *cobra.Command {
}
return "", fmt.Errorf("couldn't locate operator container on deployment")
}
hostedClusterConfigOperatorImage, err = lookupOperatorImage(hostedClusterConfigOperatorImage)
if err != nil {

if err := wait.PollImmediate(5*time.Second, 30*time.Second, func() (bool, error) {
hostedClusterConfigOperatorImage, err = lookupOperatorImage(hostedClusterConfigOperatorImage)
if err != nil {
return false, err
}
// Apparently this is occasionally set to an empty string
if hostedClusterConfigOperatorImage == "" {
setupLog.Info("hosted cluster config operator image is empty, retrying")
return false, nil
}
return true, nil
}); err != nil {
setupLog.Error(err, fmt.Sprintf("failed to find operator image: %s", err), "controller", "hosted-control-plane")
os.Exit(1)
}
Expand Down
21 changes: 18 additions & 3 deletions hypershift-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/discovery"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down Expand Up @@ -196,10 +197,24 @@ func run(ctx context.Context, opts *StartOptions, log logr.Logger) error {
}
return "", fmt.Errorf("couldn't locate operator container on deployment")
}
operatorImage, err := lookupOperatorImage(opts.ControlPlaneOperatorImage)
if err != nil {
return fmt.Errorf("failed to find operator image: %w", err)
var operatorImage string
if err := wait.PollImmediate(5*time.Second, 30*time.Second, func() (bool, error) {
operatorImage, err = lookupOperatorImage(opts.ControlPlaneOperatorImage)
if err != nil {
return false, err
}
// Apparently this is occasionally set to an empty string
if operatorImage == "" {
log.Info("operator image is empty, retrying")
return false, nil
}
return true, nil
}); err != nil {
if err != nil {
return fmt.Errorf("failed to find operator image: %w", err)
}
}

log.Info("using hosted control plane operator image", "operator-image", operatorImage)

createOrUpdate := upsert.New(opts.EnableCIDebugOutput)
Expand Down

0 comments on commit 260f0fe

Please sign in to comment.