mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	apiserver: fix apf enablement with runtime-config
This commit is contained in:
		@@ -56,7 +56,7 @@ func validateAPIPriorityAndFairness(options *Options) []error {
 | 
				
			|||||||
		// APF is assumed to be turned on. The internal APF controller uses
 | 
							// APF is assumed to be turned on. The internal APF controller uses
 | 
				
			||||||
		// v1 so it should be enabled.
 | 
							// v1 so it should be enabled.
 | 
				
			||||||
		enabledAPIString := options.APIEnablement.RuntimeConfig.String()
 | 
							enabledAPIString := options.APIEnablement.RuntimeConfig.String()
 | 
				
			||||||
		testConfigs := []string{"flowcontrol.apiserver.k8s.io/v1", "api/all"} // in the order of precedence
 | 
							testConfigs := []string{"flowcontrol.apiserver.k8s.io/v1", "api/ga", "api/all"} // in the order of precedence
 | 
				
			||||||
		for _, testConfig := range testConfigs {
 | 
							for _, testConfig := range testConfigs {
 | 
				
			||||||
			if strings.Contains(enabledAPIString, fmt.Sprintf("%s=false", testConfig)) {
 | 
								if strings.Contains(enabledAPIString, fmt.Sprintf("%s=false", testConfig)) {
 | 
				
			||||||
				return []error{fmt.Errorf("--runtime-config=%s=false conflicts with --enable-priority-and-fairness=true and --feature-gates=APIPriorityAndFairness=true", testConfig)}
 | 
									return []error{fmt.Errorf("--runtime-config=%s=false conflicts with --enable-priority-and-fairness=true and --feature-gates=APIPriorityAndFairness=true", testConfig)}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,6 +46,14 @@ func TestValidateAPIPriorityAndFairness(t *testing.T) {
 | 
				
			|||||||
			runtimeConfig:    "api/beta=false",
 | 
								runtimeConfig:    "api/beta=false",
 | 
				
			||||||
			errShouldContain: "",
 | 
								errShouldContain: "",
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								runtimeConfig:    "api/ga=false",
 | 
				
			||||||
 | 
								errShouldContain: conflict,
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								runtimeConfig:    "api/ga=true",
 | 
				
			||||||
 | 
								errShouldContain: "",
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			runtimeConfig:    "flowcontrol.apiserver.k8s.io/v1beta1=false",
 | 
								runtimeConfig:    "flowcontrol.apiserver.k8s.io/v1beta1=false",
 | 
				
			||||||
			errShouldContain: "",
 | 
								errShouldContain: "",
 | 
				
			||||||
@@ -70,6 +78,10 @@ func TestValidateAPIPriorityAndFairness(t *testing.T) {
 | 
				
			|||||||
			runtimeConfig:    "flowcontrol.apiserver.k8s.io/v1=false",
 | 
								runtimeConfig:    "flowcontrol.apiserver.k8s.io/v1=false",
 | 
				
			||||||
			errShouldContain: conflict,
 | 
								errShouldContain: conflict,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								runtimeConfig:    "flowcontrol.apiserver.k8s.io/v1beta3=true,flowcontrol.apiserver.k8s.io/v1=false",
 | 
				
			||||||
 | 
								errShouldContain: conflict,
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for _, test := range tests {
 | 
						for _, test := range tests {
 | 
				
			||||||
@@ -86,9 +98,17 @@ func TestValidateAPIPriorityAndFairness(t *testing.T) {
 | 
				
			|||||||
			if errs := validateAPIPriorityAndFairness(options); len(errs) > 0 {
 | 
								if errs := validateAPIPriorityAndFairness(options); len(errs) > 0 {
 | 
				
			||||||
				errMessageGot = errs[0].Error()
 | 
									errMessageGot = errs[0].Error()
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								switch {
 | 
				
			||||||
 | 
								case len(test.errShouldContain) == 0:
 | 
				
			||||||
 | 
									if len(errMessageGot) > 0 {
 | 
				
			||||||
 | 
										t.Errorf("Expected no error, but got: %q", errMessageGot)
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								default:
 | 
				
			||||||
				if !strings.Contains(errMessageGot, test.errShouldContain) {
 | 
									if !strings.Contains(errMessageGot, test.errShouldContain) {
 | 
				
			||||||
					t.Errorf("Expected error message to contain: %q, but got: %q", test.errShouldContain, errMessageGot)
 | 
										t.Errorf("Expected error message to contain: %q, but got: %q", test.errShouldContain, errMessageGot)
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user