Skip to content

Commit

Permalink
Check if HelmRelease exist to update feature status
Browse files Browse the repository at this point in the history
Signed-off-by: Rokibul Hasan <[email protected]>
  • Loading branch information
RokibulHasan7 committed May 14, 2024
1 parent b7422bc commit fe9f5e0
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions pkg/controllers/feature/feature_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ func (r *frReconciler) reconcile(ctx context.Context) error {
return nil
}

enabled := r.isFeatureEnabled(status)
enabled, err := r.isFeatureEnabled(ctx, status)
if err != nil {
return err
}

if !enabled {
r.feature.Status.Enabled = pointer.BoolP(false)
return nil
Expand Down Expand Up @@ -262,8 +266,16 @@ func (r *frReconciler) getHelmRelease(ctx context.Context) (fluxhelm.HelmRelease
}, r.feature.Name)
}

func (r *frReconciler) isFeatureEnabled(status featureStatus) bool {
return isRequiredResourcesExist(status) && isWorkloadOrReleaseExist(status)
func (r *frReconciler) isFeatureEnabled(ctx context.Context, status featureStatus) (bool, error) {
_, err := r.getHelmRelease(ctx)
if err != nil {
if kerr.IsNotFound(err) {
status.managed = false
return isRequiredResourcesExist(status) && isWorkloadOrReleaseExist(status), nil
}
return false, err
}
return true, nil
}

func (r *frReconciler) isFeatureReady(status featureStatus) (bool, string) {
Expand Down

0 comments on commit fe9f5e0

Please sign in to comment.