-
Notifications
You must be signed in to change notification settings - Fork 172
CNTRLPLANE-2847: render: Resolve featureSet into individual feature gates during bootstrap #1647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -803,20 +803,32 @@ func getFeatureGatesStatus(installConfig map[string]any) (sets.Set[configv1.Feat | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| necessaryFeatureGates := []configv1.FeatureGateName{"ShortCertRotation"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| disabled.Insert(necessaryFeatureGates...) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| featureGates, found := installConfig["featureGates"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if !found { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return enabled, disabled | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for _, featureGate := range featureGates.([]any) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| key := strings.Split(featureGate.(string), "=")[0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| value := strings.Split(featureGate.(string), "=")[1] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if value == "true" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| enabled = enabled.Insert(configv1.FeatureGateName(key)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| disabled = disabled.Delete(configv1.FeatureGateName(key)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if value == "false" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| enabled = enabled.Delete(configv1.FeatureGateName(key)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| disabled = disabled.Insert(configv1.FeatureGateName(key)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if featureSetRaw, found := installConfig["featureSet"]; found { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| featureSet := configv1.FeatureSet(featureSetRaw.(string)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if resolved := features.FeatureSets(0, features.SelfManaged, featureSet); resolved != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for _, fg := range resolved.Enabled { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| enabled.Insert(fg.FeatureGateAttributes.Name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| disabled.Delete(fg.FeatureGateAttributes.Name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for _, fg := range resolved.Disabled { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if !enabled.Has(fg.FeatureGateAttributes.Name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| disabled.Insert(fg.FeatureGateAttributes.Name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if featureGates, found := installConfig["featureGates"]; found { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for _, featureGate := range featureGates.([]any) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| key := strings.Split(featureGate.(string), "=")[0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could do |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| value := strings.Split(featureGate.(string), "=")[1] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if value == "true" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| enabled = enabled.Insert(configv1.FeatureGateName(key)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| disabled = disabled.Delete(configv1.FeatureGateName(key)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if value == "false" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| enabled = enabled.Delete(configv1.FeatureGateName(key)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| disabled = disabled.Insert(configv1.FeatureGateName(key)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+821
to
833
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win Unbounded index access on
🛡️ Proposed fix using SplitN with a length check for _, featureGate := range featureGates.([]any) {
- key := strings.Split(featureGate.(string), "=")[0]
- value := strings.Split(featureGate.(string), "=")[1]
+ parts := strings.SplitN(featureGate.(string), "=", 2)
+ if len(parts) != 2 {
+ continue
+ }
+ key, value := parts[0], parts[1]
if value == "true" {📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Unchecked type assertion on
featureSetRaw.featureSetRaw.(string)will panic ifinstallConfig["featureSet"]is present but not a string (e.g., malformed YAML producing an int/bool/nil). This runs on the bootstrap render path, so a malformed install-config would crash rendering instead of degrading gracefully.As per path instructions, Go code should "Never ignore error returns"; the same principle applies to unchecked type assertions on values sourced from external config here.
🛡️ Proposed fix using comma-ok assertion
if featureSetRaw, found := installConfig["featureSet"]; found { - featureSet := configv1.FeatureSet(featureSetRaw.(string)) - if resolved := features.FeatureSets(0, features.SelfManaged, featureSet); resolved != nil { + featureSetStr, ok := featureSetRaw.(string) + if !ok { + return enabled, disabled + } + featureSet := configv1.FeatureSet(featureSetStr) + if resolved := features.FeatureSets(0, features.SelfManaged, featureSet); resolved != nil {📝 Committable suggestion
🤖 Prompt for AI Agents
Source: Path instructions