Skip to content

Commit 8558349

Browse files
authored
Add checks for helm deployment status (#1349)
Don't allow an update to occur when the deployment is still installing. Signed-off-by: Todd Short <[email protected]>
1 parent 3002efe commit 8558349

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

internal/controllers/clusterextension_controller.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"time"
2626

2727
"github.com/go-logr/logr"
28+
"helm.sh/helm/v3/pkg/release"
2829
"helm.sh/helm/v3/pkg/storage/driver"
2930
"k8s.io/apimachinery/pkg/api/equality"
3031
apimeta "k8s.io/apimachinery/pkg/api/meta"
@@ -246,6 +247,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
246247
Ref: resolvedBundle.Image,
247248
},
248249
}
250+
249251
l.Info("unpacking resolved bundle")
250252
unpackResult, err := r.Unpacker.Unpack(ctx, bundleSource)
251253
if err != nil {
@@ -470,16 +472,26 @@ func (d *DefaultInstalledBundleGetter) GetInstalledBundle(ctx context.Context, e
470472
return nil, err
471473
}
472474

473-
release, err := cl.Get(ext.GetName())
475+
rel, err := cl.Get(ext.GetName())
474476
if err != nil && !errors.Is(err, driver.ErrReleaseNotFound) {
475477
return nil, err
476478
}
477-
if release == nil {
479+
if rel == nil {
478480
return nil, nil
479481
}
480482

483+
switch rel.Info.Status {
484+
case release.StatusUnknown:
485+
return nil, fmt.Errorf("installation status is unknown")
486+
case release.StatusDeployed, release.StatusUninstalled, release.StatusSuperseded, release.StatusFailed:
487+
case release.StatusUninstalling, release.StatusPendingInstall, release.StatusPendingRollback, release.StatusPendingUpgrade:
488+
return nil, fmt.Errorf("installation is still pending: %s", rel.Info.Status)
489+
default:
490+
return nil, fmt.Errorf("unknown installation status: %s", rel.Info.Status)
491+
}
492+
481493
return &ocv1alpha1.BundleMetadata{
482-
Name: release.Labels[labels.BundleNameKey],
483-
Version: release.Labels[labels.BundleVersionKey],
494+
Name: rel.Labels[labels.BundleNameKey],
495+
Version: rel.Labels[labels.BundleVersionKey],
484496
}, nil
485497
}

0 commit comments

Comments
 (0)