@@ -57,7 +57,7 @@ const (
5757 trustedCABundleKey = "ca-bundle.crt"
5858)
5959
60- // Cluster must have an allowed feature set (e.g. TechPreviewNoUpgrade). TrustManager is deployed and reconciled.
60+ // TrustManager is deployed and reconciled when --unsupported-addon-features=TrustManager=true .
6161var _ = Describe ("TrustManager" , Ordered , Label ("Platform:Generic" , "Feature:TrustManager" , "TechPreview" ), func () {
6262 var (
6363 ctx = context .Background ()
@@ -1464,9 +1464,10 @@ var _ = Describe("TrustManager", Ordered, Label("Platform:Generic", "Feature:Tru
14641464 })
14651465})
14661466
1467- // Cluster has featuregates.config.openshift.io spec.featureSet at Default. TrustManager controller is not enabled; operand should not be deployed.
1468- // TechPreview:Inverted labels test scenarios that invert the TechPreview test suite—validating behavior when Tech Preview feature is not enabled.
1469- var _ = Describe ("TrustManager with Default feature set" , Ordered , Label ("Platform:Generic" , "Feature:TrustManager" , "TechPreview:Inverted" ), func () {
1467+ // TrustManager operator feature gate defaults to disabled (unlike IstioCSR). Creating a TrustManager CR
1468+ // must not deploy the operand when --unsupported-addon-features does not enable TrustManager.
1469+ // TechPreview:Inverted labels test scenarios that invert the main TrustManager suite (feature gate off).
1470+ var _ = Describe ("TrustManager with operator feature gate disabled" , Ordered , Label ("Platform:Generic" , "Feature:TrustManager" , "TechPreview:Inverted" ), func () {
14701471 var (
14711472 ctx = context .Background ()
14721473
@@ -1475,16 +1476,16 @@ var _ = Describe("TrustManager with Default feature set", Ordered, Label("Platfo
14751476 originalOperatorLogLevel string
14761477 )
14771478
1478- BeforeAll (trustManagerBeforeAll (ctx , & clientset , & originalUnsupportedAddonFeatures , & originalOperatorLogLevel ))
1479+ BeforeAll (trustManagerFeatureGateDisabledBeforeAll (ctx , & clientset , & originalUnsupportedAddonFeatures , & originalOperatorLogLevel ))
14791480
14801481 AfterAll (trustManagerAfterAll (ctx , & originalUnsupportedAddonFeatures , & originalOperatorLogLevel ))
14811482
14821483 BeforeEach (trustManagerBeforeEach ())
14831484
14841485 AfterEach (trustManagerAfterEach (ctx ))
14851486
1486- It ("should not create ServiceAccount or populate status when cluster feature set is Default " , func () {
1487- By ("creating TrustManager CR with default settings (same as TechPreview scenario) " )
1487+ It ("should not create ServiceAccount or populate status when operator feature gate is disabled " , func () {
1488+ By ("creating TrustManager CR with default settings" )
14881489 _ , err := trustManagerClient ().Create (ctx , & v1alpha1.TrustManager {
14891490 ObjectMeta : metav1.ObjectMeta {Name : "cluster" },
14901491 Spec : v1alpha1.TrustManagerSpec {
@@ -1497,10 +1498,10 @@ var _ = Describe("TrustManager with Default feature set", Ordered, Label("Platfo
14971498 _ , err = trustManagerClient ().Get (ctx , "cluster" , metav1.GetOptions {})
14981499 Expect (err ).ShouldNot (HaveOccurred ())
14991500
1500- By ("verifying ServiceAccount is not created and TrustManager status stays unset (controller not running for Default feature set )" )
1501+ By ("verifying ServiceAccount is not created and TrustManager status stays unset (controller not running without feature gate )" )
15011502 Consistently (func (g Gomega ) {
15021503 _ , err := clientset .CoreV1 ().ServiceAccounts (trustManagerNamespace ).Get (ctx , trustManagerServiceAccountName , metav1.GetOptions {})
1503- g .Expect (apierrors .IsNotFound (err )).To (BeTrue (), "ServiceAccount %s/%s must not exist when cluster feature set is Default " , trustManagerNamespace , trustManagerServiceAccountName )
1504+ g .Expect (apierrors .IsNotFound (err )).To (BeTrue (), "ServiceAccount %s/%s must not exist when TrustManager feature gate is disabled " , trustManagerNamespace , trustManagerServiceAccountName )
15041505
15051506 tm , err := trustManagerClient ().Get (ctx , "cluster" , metav1.GetOptions {})
15061507 g .Expect (err ).NotTo (HaveOccurred ())
@@ -1620,7 +1621,7 @@ func findSecretRule(rules []rbacv1.PolicyRule, verb string) *rbacv1.PolicyRule {
16201621
16211622// trustManagerRemoveStaleOperandServiceAccount deletes the trust-manager operand ServiceAccount if it
16221623// exists and waits until it is gone. TrustManager CR deletion does not remove this SA today, so a
1623- // prior e2e run or TechPreview block can leave it and break the Default-feature-set scenario .
1624+ // prior e2e run can leave it behind and affect later tests .
16241625//
16251626// TODO: Remove this when TrustManager is GA and operand teardown removes the ServiceAccount (or
16261627// equivalent) when the TrustManager CR is deleted.
@@ -1633,6 +1634,37 @@ func trustManagerRemoveStaleOperandServiceAccount(ctx context.Context, cs *kuber
16331634 }, lowTimeout , fastPollInterval ).Should (BeTrue ())
16341635}
16351636
1637+ func trustManagerFeatureGateDisabledBeforeAll (ctx context.Context , clientset * * kubernetes.Clientset , unsupportedAddonFeatures , operatorLogLevel * string ) func () {
1638+ return func () {
1639+ cs , err := kubernetes .NewForConfig (cfg )
1640+ Expect (err ).Should (BeNil ())
1641+ * clientset = cs
1642+
1643+ trustManagerRemoveStaleOperandServiceAccount (ctx , cs )
1644+
1645+ By ("capturing original UNSUPPORTED_ADDON_FEATURES from subscription before patching" )
1646+ * unsupportedAddonFeatures , err = getSubscriptionEnvVar (ctx , loader , "UNSUPPORTED_ADDON_FEATURES" )
1647+ Expect (err ).NotTo (HaveOccurred ())
1648+
1649+ By ("capturing original OPERATOR_LOG_LEVEL from subscription before patching" )
1650+ * operatorLogLevel , err = getSubscriptionEnvVar (ctx , loader , "OPERATOR_LOG_LEVEL" )
1651+ Expect (err ).NotTo (HaveOccurred ())
1652+
1653+ fmt .Fprintf (GinkgoWriter , "TrustManager feature gate disabled BeforeAll: captured UNSUPPORTED_ADDON_FEATURES=%q OPERATOR_LOG_LEVEL=%q\n " ,
1654+ * unsupportedAddonFeatures , * operatorLogLevel )
1655+
1656+ By ("ensuring TrustManager operator feature gate is not enabled via subscription" )
1657+ err = patchSubscriptionWithEnvVars (ctx , loader , map [string ]string {
1658+ "UNSUPPORTED_ADDON_FEATURES" : "" ,
1659+ })
1660+ Expect (err ).NotTo (HaveOccurred ())
1661+
1662+ By ("waiting for operator deployment to rollout without UNSUPPORTED_ADDON_FEATURES" )
1663+ err = waitForDeploymentEnvVarRemovedAndRollout (ctx , operatorNamespace , operatorDeploymentName , "UNSUPPORTED_ADDON_FEATURES" , lowTimeout )
1664+ Expect (err ).NotTo (HaveOccurred ())
1665+ }
1666+ }
1667+
16361668func trustManagerBeforeAll (ctx context.Context , clientset * * kubernetes.Clientset , unsupportedAddonFeatures , operatorLogLevel * string ) func () {
16371669 return func () {
16381670 cs , err := kubernetes .NewForConfig (cfg )
0 commit comments