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

Added validation for --insecure-registry values #9977

Merged
merged 1 commit into from
Dec 22, 2020

Conversation

kadern0
Copy link
Contributor

@kadern0 kadern0 commented Dec 17, 2020

Fixes 8790

Original reported behavior (slightly summarized):

minikube start --driver=docker --profile=testing3 --insecure-registry=:
πŸ˜„  [testing3] minikube v1.13.0 on Ubuntu 20.04
✨  Using the docker driver based on user configuration
πŸ‘  Starting control plane node testing3 in cluster testing3
πŸ”₯  Creating docker container (CPUs=2, Memory=3900MB) ...
βœ‹  Stopping node "testing3"  ...
πŸ›‘  Powering off "testing3" via SSH ...
πŸ”₯  Deleting "testing3" in docker ...
🀦  StartHost failed, but will try again: creating host: create: provisioning: ssh command error:

...

❌  Exiting due to RT_DOCKER_RESTART: Failed to start host: creating host: create: provisioning: ssh command error:
command : sudo diff -u /lib/systemd/system/docker.service /lib/systemd/system/docker.service.new || { sudo mv /lib/systemd/system/docker.service.new /lib/systemd/system/docker.service; sudo systemctl -f daemon-reload && sudo systemctl -f enable docker && sudo systemctl -f restart docker; }
err     : Process exited with status 1


...

πŸ’‘  Suggestion: Remove the invalid --docker-opt or --insecure-registry flag if one was provided
🍿  Related issue: https://github.com/kubernetes/minikube/issues/7070

New behavior:

minikube start --driver=docker --profile=testingt3 --insecure-registry=:
πŸ˜„  [testingt3] minikube v1.13.0 on Ubuntu 20.04
✨  Using the docker driver based on user configuration

❌  Exiting due to MK_USAGE: Sorry, the address provided with the --insecure-registry flag is invalid: :

Additional validations:

minikube start --driver=docker --profile=testingt --insecure-registry 172.16.23/24
πŸ˜„  [testingt] minikube v1.13.0 on Ubuntu 20.04
✨  Using the docker driver based on existing profile

❌  Exiting due to MK_USAGE: Sorry, the address provided with the --insecure-registry flag is invalid: 172.16.23/24

minikube start --driver=docker --profile=testingt --insecure-registry 172.16.23/24:asdf
πŸ˜„  [testingt] minikube v1.13.0 on Ubuntu 20.04
✨  Using the docker driver based on existing profile

❌  Exiting due to MK_USAGE: Sorry, the address provided with the --insecure-registry flag is invalid: 172.16.23/24:asdf
minikube start --driver=docker --profile=testingt --insecure-registry 172.16.23/24:
πŸ˜„  [testingt] minikube v1.13.0 on Ubuntu 20.04
✨  Using the docker driver based on existing profile

❌  Exiting due to MK_USAGE: Sorry, the address provided with the --insecure-registry flag is invalid: 172.16.23/24:

minikube start --driver=docker --profile=testingt3 --insecure-registry=192.168.100.123
πŸ˜„  [testingt3] minikube v1.13.0 on Ubuntu 20.04
✨  Using the docker driver based on existing profile

❌  Exiting due to MK_USAGE: Sorry, the address provided with the --insecure-registry flag is invalid: 192.168.100.123

minikube start --driver=docker --profile=testingt3 --insecure-registry=localhost
πŸ˜„  [testingt3] minikube v1.13.0 on Ubuntu 20.04
✨  Using the docker driver based on existing profile

❌  Exiting due to MK_USAGE: Sorry, the address provided with the --insecure-registry flag is invalid: localhost

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 17, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @kadern0. 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/test-infra repository.

@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 Dec 17, 2020
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 17, 2020
@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@@ -1060,6 +1064,35 @@ func validateRegistryMirror() {
}
}

// This function validates that the --insecure-registry follows one of the following formats:
// "<ip>:<port>" "<hostname>:<port>" "<network>/<netmask>"
func ValidateInsecureRegistry() {
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be a private function -- and probably moved to start_flags.go.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree with the private function, about the location I've placed it under the "validateRegistryMirror" function since they do pretty much the same. To me it makes sense having both together, what do you think?

cmd/minikube/cmd/start.go Outdated Show resolved Hide resolved
cmd/minikube/cmd/start.go Outdated Show resolved Hide resolved
@@ -71,6 +72,7 @@ var (
insecureRegistry []string
apiServerNames []string
apiServerIPs []net.IP
hostRe = regexp.MustCompile(`[\w\.-]+`)
Copy link
Member

Choose a reason for hiding this comment

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

add a comment here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you still want me to add the comment?

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kadern0, medyagh

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

The pull request process is described 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 approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 22, 2020
@medyagh medyagh merged commit c300a05 into kubernetes:master Dec 22, 2020
@crossdot
Copy link

crossdot commented Feb 3, 2021

Why hostname without port is not allowed? It works fine in previous versions.
Using JFrog Artifactory as image registry and for example localregistry:443/nginx:1.18 in deployment looks terrible.

@kadern0
Copy link
Contributor Author

kadern0 commented Feb 3, 2021

@crossdot we are discussing about this on the issue's URL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants