mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Merge pull request #56042 from stewart-yu/kubeadm#554
Automatic merge from submit-queue (batch tested with PRs 56128, 56004, 56083, 55833, 56042). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Automatically opt into dependent feature gates when using kubeadm **What this PR does / why we need it**: There will be a dependency chain between feature gates. kubeadm needs to automatically opt into dependent feature gates of a chosen one. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes # [https://github.com/kubernetes/kubeadm/issues/554](https://github.com/kubernetes/kubeadm/issues/554) **Special notes for your reviewer**: **Release note**: ```release-note NONE ```
This commit is contained in:
commit
630dbedef9
@ -155,5 +155,22 @@ func NewFeatureGate(f *FeatureList, value string) (map[string]bool, error) {
|
||||
featureGate[k] = boolValue
|
||||
}
|
||||
|
||||
ResolveFeatureGateDependencies(featureGate)
|
||||
|
||||
return featureGate, nil
|
||||
}
|
||||
|
||||
// ResolveFeatureGateDependencies resolve dependencies between feature gates
|
||||
func ResolveFeatureGateDependencies(featureGate map[string]bool) {
|
||||
|
||||
// if StoreCertsInSecrets enabled, SelfHosting should enabled
|
||||
if Enabled(featureGate, StoreCertsInSecrets) {
|
||||
featureGate[SelfHosting] = true
|
||||
}
|
||||
|
||||
// if HighAvailability enabled, both StoreCertsInSecrets and SelfHosting should enabled
|
||||
if Enabled(featureGate, HighAvailability) && !Enabled(featureGate, StoreCertsInSecrets) {
|
||||
featureGate[SelfHosting] = true
|
||||
featureGate[StoreCertsInSecrets] = true
|
||||
}
|
||||
}
|
||||
|
@ -156,3 +156,36 @@ func TestValidateVersion(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveFeatureGateDependencies(t *testing.T) {
|
||||
|
||||
var tests = []struct {
|
||||
inputFeatures map[string]bool
|
||||
expectedFeatures map[string]bool
|
||||
}{
|
||||
{ // no flags
|
||||
inputFeatures: map[string]bool{},
|
||||
expectedFeatures: map[string]bool{},
|
||||
},
|
||||
{ // others flags
|
||||
inputFeatures: map[string]bool{"SupportIPVSProxyMode": true},
|
||||
expectedFeatures: map[string]bool{"SupportIPVSProxyMode": true},
|
||||
},
|
||||
{ // just StoreCertsInSecrets flags
|
||||
inputFeatures: map[string]bool{"StoreCertsInSecrets": true},
|
||||
expectedFeatures: map[string]bool{"StoreCertsInSecrets": true, "SelfHosting": true},
|
||||
},
|
||||
{ // just HighAvailability flags
|
||||
inputFeatures: map[string]bool{"HighAvailability": true},
|
||||
expectedFeatures: map[string]bool{"HighAvailability": true, "StoreCertsInSecrets": true, "SelfHosting": true},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
ResolveFeatureGateDependencies(test.inputFeatures)
|
||||
if !reflect.DeepEqual(test.inputFeatures, test.expectedFeatures) {
|
||||
t.Errorf("ResolveFeatureGateDependencies failed, expected: %v, got: %v", test.inputFeatures, test.expectedFeatures)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user