Skip to content
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

New flag to allow option for passing a config file for addon configure command. #20255

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

panyam
Copy link

@panyam panyam commented Jan 13, 2025

Minor UI Change (Before and After described in the ticket) but tl;dr:

BEFORE

Currently when configuring addons with the command:

minikube addons configure <addon>

eg:

minikube addons configure registry-creds

The user is prompted to input the values one by one, eg:

Do you want to enable AWS Elastic Container Registry? [y/n]:

and so on. This makes it hard to store/load values in a scripted environemnt. Some times it easier to provide a config file containing so that the values can be read from this.

AFTER

Add a "-f" local flag to the addon configure command, eg:

minikube addons configure registry-creds -f ~/.minikube/configs/registry-creds-config.json
minikube addons configure ingress -f ~/.minikube/configs/ingres-config.json

etc

Fixes #20124

@k8s-ci-robot k8s-ci-robot added do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 13, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: panyam
Once this PR has been reviewed and has the lgtm label, please assign medyagh for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jan 13, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @panyam. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jan 13, 2025
@ComradeProgrammer
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 13, 2025
@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@panyam panyam changed the title Addon configuration now takes an optional config file to load from New flag to allow option for passing a config file for addon configure command. Jan 13, 2025
@minikube-pr-bot

This comment has been minimized.

// Processes registry-creds addon config from configFile if it exists otherwise resorts to default behavior
func processRegistryCredsConfig(profile string, configFileData map[string]any) {
// Default values
awsAccessID := "changeme"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there reason for "changeme" default value? seems unconventional, I would prefer either "" or something very explicit that has no chance of clodiing with users real values, like "MINIKUBE_DEFAULT_VALUE"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I like the MINIKUBE_DEFAULT_VALUE as a default. Updated it. PTAL

@minikube-pr-bot

This comment has been minimized.

@minikube-pr-bot

This comment has been minimized.

@minikube-pr-bot

This comment has been minimized.

@minikube-pr-bot

This comment has been minimized.

@k8s-ci-robot
Copy link
Contributor

Keywords which can automatically close issues and at(@) or hashtag(#) mentions are not allowed in commit messages.

The list of commits with invalid commit messages:

  • d105076 Addon configuration now takes an optional config file to load from

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Copy link
Member

@medyagh medyagh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this PR is exciting and its getting closer ! just a few more changes

@@ -38,6 +42,7 @@ import (
"k8s.io/minikube/pkg/minikube/sysinit"
)

var AddonConfigFile = ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets make this private

out.Ln("Reading %s configs from %s", addon, configFilePath)
if confData, err := os.ReadFile(configFilePath); err != nil && errors.Is(err, os.ErrNotExist) {
exit.Message(reason.Usage, "config file does not exist")
return nil, err
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

klog.warnf err before exis

exit.Message(reason.Usage, "config file does not exist")
return nil, err
} else if err != nil {
exit.Message(reason.Kind{ExitCode: reason.ExProgramConfig, Advice: "provide a valid config file"},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

klog.Errof(...)

} else if err != nil {
exit.Message(reason.Kind{ExitCode: reason.ExProgramConfig, Advice: "provide a valid config file"},
fmt.Sprintf("error opening config file: %v", err))
return nil, err
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"wrap" the error

fmt.Sprintf("error opening config file: %v", err))
return nil, err
} else if err = json.Unmarshal(confData, &configFileData); err != nil {
exit.Message(reason.Kind{ExitCode: reason.ExProgramConfig, Advice: "provide a valid config file"},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"ensure the json format of the config file is valid"

return nil, err
} else if err = json.Unmarshal(confData, &configFileData); err != nil {
exit.Message(reason.Kind{ExitCode: reason.ExProgramConfig, Advice: "provide a valid config file"},
fmt.Sprintf("error opening config file: %v", err))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error wrap

errors.Wrapf(err, "addon config %s" ... )

} else if err = json.Unmarshal(confData, &configFileData); err != nil {
exit.Message(reason.Kind{ExitCode: reason.ExProgramConfig, Advice: "provide a valid config file"},
fmt.Sprintf("error opening config file: %v", err))
return nil, err
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if exit no need to return

return nil, err
}

// Make sure the addon specific config exists and it is a map
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make a helper function and put the nested ifs in there

@@ -304,6 +305,64 @@ func validateIngressAddon(ctx context.Context, t *testing.T, profile string) {
}
}

// validateRegistryCredsAddon tests the registry-creds addon by trying to load its configs
func validateRegistryCredsAddon(ctx context.Context, t *testing.T, profile string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets use a struct for the regsitry cred addons so it can be typed checked

@minikube-pr-bot
Copy link

kvm2 driver with docker runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 20255) |
+----------------+----------+---------------------+
| minikube start | 49.9s    | 46.9s               |
| enable ingress | 14.9s    | 14.9s               |
+----------------+----------+---------------------+

Times for minikube start: 49.9s 50.9s 49.9s 48.1s 50.5s
Times for minikube (PR 20255) start: 45.9s 47.4s 45.8s 48.6s 47.1s

Times for minikube (PR 20255) ingress: 14.9s 14.9s 14.9s 14.9s 15.0s
Times for minikube ingress: 15.5s 14.4s 15.0s 14.9s 14.9s

docker driver with docker runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 20255) |
+----------------+----------+---------------------+
| minikube start | 20.8s    | 20.6s               |
| enable ingress | 12.3s    | 12.4s               |
+----------------+----------+---------------------+

Times for minikube start: 21.2s 20.9s 20.2s 21.1s 20.7s
Times for minikube (PR 20255) start: 21.2s 20.1s 20.1s 20.6s 21.2s

Times for minikube ingress: 12.3s 12.2s 12.2s 12.2s 12.7s
Times for minikube (PR 20255) ingress: 12.2s 12.2s 12.7s 12.7s 12.3s

docker driver with containerd runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 20255) |
+----------------+----------+---------------------+
| minikube start | 20.5s    | 20.9s               |
| enable ingress | 29.3s    | 26.1s               |
+----------------+----------+---------------------+

Times for minikube (PR 20255) start: 19.2s 23.1s 19.3s 20.2s 22.5s
Times for minikube start: 21.7s 22.0s 19.4s 19.4s 20.0s

Times for minikube ingress: 23.2s 22.7s 38.7s 39.2s 22.7s
Times for minikube (PR 20255) ingress: 23.2s 22.7s 23.2s 22.7s 38.7s

@minikube-pr-bot
Copy link

Here are the number of top 10 failed tests in each environments with lowest flake rate.

Environment Test Name Flake Rate
Docker_Linux (1 failed) TestStartStop/group/no-preload/serial/FirstStart(gopogh) 0.00% (chart)
Docker_Linux_crio_arm64 (5 failed) TestAddons/parallel/LocalPath(gopogh) 2.04% (chart)
Docker_Linux_crio_arm64 (5 failed) TestFunctional/parallel/TunnelCmd/serial/WaitService/Setup(gopogh) 2.17% (chart)
Docker_Linux_crio_arm64 (5 failed) TestFunctional/parallel/TunnelCmd/serial/AccessDirect(gopogh) 2.17% (chart)
Docker_Linux_crio_arm64 (5 failed) TestFunctional/parallel/PersistentVolumeClaim(gopogh) 10.87% (chart)

Besides the following environments also have failed tests:

  • Docker_Cloud_Shell: 3 failed (gopogh)

  • Docker_Linux_containerd_arm64: 1 failed (gopogh)

  • Docker_Linux_crio: 1 failed (gopogh)

  • KVM_Linux_containerd: 2 failed (gopogh)

  • KVM_Linux_crio: 11 failed (gopogh)

To see the flake rates of all tests by environment, click here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Provide an option for passing a config file for addon configure command.
6 participants