Skip to content

Commit

Permalink
Removing unwanted feature gate(KubeletCredentialProviders) option (#1176
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jhaanvi5 authored Dec 3, 2024
1 parent 3cb6452 commit c12e976
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 31 deletions.
6 changes: 0 additions & 6 deletions credentialproviderpackage/pkg/configurator/linux/linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,6 @@ func (c *linuxOS) createConfig() (string, error) {

func (c *linuxOS) updateKubeletArguments(line string) string {
args := ""
k8sVersion := os.Getenv("K8S_VERSION")
if semver.Compare(k8sVersion, "v1.26") < 0 {
if !strings.Contains(line, "KubeletCredentialProviders") {
args += " --feature-gates=KubeletCredentialProviders=true"
}
}

val, err := c.createConfig()
if err != nil {
Expand Down
30 changes: 5 additions & 25 deletions credentialproviderpackage/pkg/configurator/linux/linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ func Test_linuxOS_updateKubeletArguments(t *testing.T) {
args: args{line: ""},
outputConfigPath: dir + "/" + credProviderFile,
configWantPath: "testdata/expected-config.yaml",
want: fmt.Sprintf(" --feature-gates=KubeletCredentialProviders=true "+
"--image-credential-provider-config=%s%s", dir, credProviderFile),
want: fmt.Sprintf(" --image-credential-provider-config=%s%s", dir, credProviderFile),
},
{
name: "test multiple match patterns",
Expand All @@ -67,27 +66,10 @@ func Test_linuxOS_updateKubeletArguments(t *testing.T) {
args: args{line: ""},
outputConfigPath: dir + "/" + credProviderFile,
configWantPath: "testdata/expected-config-multiple-patterns.yaml",
want: fmt.Sprintf(" --feature-gates=KubeletCredentialProviders=true "+
"--image-credential-provider-config=%s%s", dir, credProviderFile),
},
{
name: "skip credential provider if already provided",
fields: fields{
profile: "eksa-packages",
extraArgsPath: dir,
basePath: dir,
config: constants.CredentialProviderConfigOptions{
ImagePatterns: []string{constants.DefaultImagePattern},
DefaultCacheDuration: constants.DefaultCacheDuration,
},
},
args: args{line: " --feature-gates=KubeletCredentialProviders=true"},
outputConfigPath: dir + "/" + credProviderFile,
configWantPath: "testdata/expected-config.yaml",
want: fmt.Sprintf(" --image-credential-provider-config=%s%s", dir, credProviderFile),
},
{
name: "skip both cred provider and feature gate if provided",
name: "skip credential provider if already provided",
fields: fields{
profile: "eksa-packages",
extraArgsPath: dir,
Expand All @@ -97,7 +79,7 @@ func Test_linuxOS_updateKubeletArguments(t *testing.T) {
DefaultCacheDuration: constants.DefaultCacheDuration,
},
},
args: args{line: " --feature-gates=KubeletCredentialProviders=false --image-credential-provider-config=blah"},
args: args{line: " --image-credential-provider-config=blah"},
outputConfigPath: dir + "/" + credProviderFile,
configWantPath: "",
want: "",
Expand All @@ -117,8 +99,7 @@ func Test_linuxOS_updateKubeletArguments(t *testing.T) {
outputConfigPath: dir + "/" + credProviderFile,
configWantPath: "testdata/expected-config-alpha.yaml",
k8sVersion: "v1.25",
want: fmt.Sprintf(" --feature-gates=KubeletCredentialProviders=true "+
"--image-credential-provider-config=%s%s", dir, credProviderFile),
want: fmt.Sprintf(" --image-credential-provider-config=%s%s", dir, credProviderFile),
},
{
name: "test v1 api 1.27",
Expand All @@ -135,8 +116,7 @@ func Test_linuxOS_updateKubeletArguments(t *testing.T) {
outputConfigPath: dir + "/" + credProviderFile,
configWantPath: "testdata/expected-config.yaml",
k8sVersion: "v1.27",
want: fmt.Sprintf(" --feature-gates=KubeletCredentialProviders=true "+
"--image-credential-provider-config=%s%s", dir, credProviderFile),
want: fmt.Sprintf(" --image-credential-provider-config=%s%s", dir, credProviderFile),
},
}
for _, tt := range tests {
Expand Down

0 comments on commit c12e976

Please sign in to comment.