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

Add DNS check to bootstrap #164

Closed
wants to merge 6 commits into from
Closed

Add DNS check to bootstrap #164

wants to merge 6 commits into from

Conversation

lilic
Copy link
Contributor

@lilic lilic commented Apr 9, 2018

Sometimes DNS is not configured correctly, but during the launcher
process, DNS is required to setup all the needed resources. This creates
a check by creating a pod where nslookup is performed.

Closes #158.

Note: Opened as more of a preview PR, if we agree on this implementation will add a test or two to this PR. :)

Sometimes DNS is not configured correctly, but during the launcher
process DNS is required to setup all the needed resources. This creates
a check by creating a pod where nslookup is performed.
@lilic lilic mentioned this pull request Apr 9, 2018
@@ -111,6 +111,21 @@ func mainImpl() {
}
}

// TODO: Should we check always?

This comment was marked as abuse.

This comment was marked as abuse.

// able to connect to the server to correctly setup the needed resources.
if !ok {
fmt.Println("DNS is not working in this Kubernetes cluster. We require correct DNS setup in the Kubernetes cluster.")
os.Exit(1)

This comment was marked as abuse.

ns := "weave"

// Create weave namespace, as this happens before any resources are created.
_, err := CreateNamespace(c, ns)

This comment was marked as abuse.

This comment was marked as abuse.

}

// Create pod to perform nslookup on a passed domain to check DNS is working.
_, err = Execute(c, "run", "-n", "weave", "--image", "busybox", "--command", podName, "nslookup --timeout=10", domain, "--restart=Never", "--pod-running-timeout=10s")

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

@leth
Copy link
Contributor

leth commented Apr 9, 2018

Looks good! Just some minor questions!

Copy link
Contributor

@dlespiau dlespiau left a comment

Choose a reason for hiding this comment

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

Approach looks to me, a couple of additional comment.

}

// Create pod to perform nslookup on a passed domain to check DNS is working.
_, err = Execute(c, "run", "-n", "weave", "--image", "busybox", "--command", podName, "nslookup --timeout=10", domain, "--restart=Never", "--pod-running-timeout=10s")

This comment was marked as abuse.

}

// Get fresh pod data.
podJSON, err = Execute(c, "get", "pod", podName, "-ojson", "-n", ns)

This comment was marked as abuse.

// ExecuteJSON execute kubectl <args> and returns the combined json stdout and err output.
func ExecuteJSON(c client, args ...string) (string, error) {
return c.Execute(append(args, "-ojson"))
}

This comment was marked as abuse.

@lilic
Copy link
Contributor Author

lilic commented Apr 10, 2018

@dlespiau @leth PTALA, thanks!

  • Not sure if we want add a note to the STDOUT saying we are performing checks or not. The last one right now before the DNS check is Installing Weave Cloud agents on minikube..., which might be slightly misleading or confusing when we then error out with There was an error while performing DNS check. DNS check failed. Timed out during DNS check. Thoughts, ideas, suggestions?
  • As mentioned elsewhere, the timeout cannot be set for nslookup, so right now we wait for 1 minute and timeout during the check. IMO if we can find a better way, or when we add other pre flight checks in the future we can use a different image rather then busybox, or build our own tool to do that. For now I would leave it as is, but am open for suggestions.

@lilic
Copy link
Contributor Author

lilic commented Apr 10, 2018

BTW not sure what's up with tests not running? :/ Could it be because I have this branch on my fork, did not have a look at circle ci setup yet in this project.

@dlespiau
Copy link
Contributor

Ah yes, we push branches on the same repo. The reason is that we don't want anyone being able to start a test run by just opening a pull request (it could be a pull request with a commit changing what the tests will be running). The "Build forked pull requests" option in CircleCI is turned off for this project.

This way we make sure that only people with the rights to push to this repository can run test code in CI.

@dlespiau
Copy link
Contributor

Adding a line on stdout saying that we're doing a pre-flight check sounds really useful "Checking the Kubernetes installation" or similar. It'll be especially useful for people having to wait for that 1 minute timeout, making it not awful!

@lilic lilic mentioned this pull request Apr 10, 2018
@lilic
Copy link
Contributor Author

lilic commented Apr 10, 2018

Closing in favor of #166 to let the tests run.

@lilic lilic closed this Apr 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants