-
Notifications
You must be signed in to change notification settings - Fork 416
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4439 from dkhater-redhat/bootstrap-e2e-test-featu…
…regate OCPBUGS-30603: Bootstrap e2e test featuregate setup does not match the actual code
- Loading branch information
Showing
3 changed files
with
51 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package common | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"time" | ||
|
||
"github.com/openshift/library-go/pkg/operator/configobserver/featuregates" | ||
"k8s.io/klog/v2" | ||
) | ||
|
||
func WaitForFeatureGatesReady(ctx context.Context, featureGateAccess featuregates.FeatureGateAccess) error { | ||
timeout := time.After(1 * time.Minute) | ||
for { | ||
select { | ||
case <-ctx.Done(): | ||
return ctx.Err() | ||
case <-timeout: | ||
return fmt.Errorf("timed out waiting for FeatureGates to be ready") | ||
default: | ||
features, err := featureGateAccess.CurrentFeatureGates() | ||
if err == nil { | ||
enabled, disabled := GetEnabledDisabledFeatures(features) | ||
klog.Infof("FeatureGates initialized: enabled=%v, disabled=%v", enabled, disabled) | ||
return nil | ||
} | ||
klog.Infof("Waiting for FeatureGates to be ready...") | ||
time.Sleep(1 * time.Second) | ||
} | ||
} | ||
} | ||
|
||
// getEnabledDisabledFeatures extracts enabled and disabled features from the feature gate. | ||
func GetEnabledDisabledFeatures(features featuregates.FeatureGate) ([]string, []string) { | ||
var enabled []string | ||
var disabled []string | ||
|
||
for _, feature := range features.KnownFeatures() { | ||
if features.Enabled(feature) { | ||
enabled = append(enabled, string(feature)) | ||
} else { | ||
disabled = append(disabled, string(feature)) | ||
} | ||
} | ||
|
||
return enabled, disabled | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters