Skip to content

Commit

Permalink
Add checks for helm deployment status
Browse files Browse the repository at this point in the history
Don't allow an update to occur when the deployment is still installing.

Signed-off-by: Todd Short <tshort@redhat.com>
  • Loading branch information
tmshort committed Oct 8, 2024
1 parent 5097435 commit 3501c21
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions internal/controllers/clusterextension_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"time"

"github.com/go-logr/logr"
"helm.sh/helm/v3/pkg/release"
"helm.sh/helm/v3/pkg/storage/driver"
"k8s.io/apimachinery/pkg/api/equality"
apimeta "k8s.io/apimachinery/pkg/api/meta"
Expand Down Expand Up @@ -246,6 +247,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
Ref: resolvedBundle.Image,
},
}

l.Info("unpacking resolved bundle")
unpackResult, err := r.Unpacker.Unpack(ctx, bundleSource)
if err != nil {
Expand Down Expand Up @@ -470,16 +472,26 @@ func (d *DefaultInstalledBundleGetter) GetInstalledBundle(ctx context.Context, e
return nil, err
}

release, err := cl.Get(ext.GetName())
rel, err := cl.Get(ext.GetName())
if err != nil && !errors.Is(err, driver.ErrReleaseNotFound) {
return nil, err
}
if release == nil {
if rel == nil {
return nil, nil
}

switch rel.Info.Status {
case release.StatusUnknown:
return nil, fmt.Errorf("installation status is unknown")
case release.StatusDeployed, release.StatusUninstalled, release.StatusSuperseded, release.StatusFailed:
case release.StatusUninstalling, release.StatusPendingInstall, release.StatusPendingRollback, release.StatusPendingUpgrade:
return nil, fmt.Errorf("installation is still pending: %s", rel.Info.Status)
default:
return nil, fmt.Errorf("unknown installation status: %s", rel.Info.Status)
}

return &ocv1alpha1.BundleMetadata{
Name: release.Labels[labels.BundleNameKey],
Version: release.Labels[labels.BundleVersionKey],
Name: rel.Labels[labels.BundleNameKey],
Version: rel.Labels[labels.BundleVersionKey],
}, nil
}

0 comments on commit 3501c21

Please sign in to comment.