-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Implement cluster status command, fixes #9935 #11171
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, it's a good practice to not put the GitHub issue number in the commit's comment because it can appears in the original issue many times if you're changing commit. Instead you can refer to the issue in the PR (also with keywords "Fixes"/"Closes" that will also close the issue when PR gets merged).
} | ||
} | ||
|
||
return errors.NewError("OpenShift cluster is not running") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks inconsistent that in case of success we're printing "container is running" and otherwise we're printing "cluster is not running". Let's use "cluster" in the success message too.
if len(c.DockerMachine) > 0 { | ||
glog.V(2).Infof("Getting client for Docker machine %q", c.DockerMachine) | ||
c.dockerClient, c.engineAPIClient, err = getDockerMachineClient(c.DockerMachine, out) | ||
// getDockerClient will obtain a new Docker client from the environment or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/will obtain/obtains/
1bcc603
to
b601d08
Compare
@php-coder thanks for the good practice; suggested changes made. |
@jim-minter Thanks! Did you see that Travis fails with "FAILURE: Generated completions out of date. Please run hack/update-generated-completions.sh"? |
b601d08
to
8ce8f13
Compare
Oh dear - thanks for pointing that out. |
Looks like you'll also need to run hack/update-generated-docs.sh |
8ce8f13
to
adae020
Compare
@jim-minter if possible we should display additional information when running status:
Something like:
Mount and uptime information can be obtained by inspecting the origin container. URL and metrics info can be obtained from the master-config.yaml (you can get a copy by copying it from the origin container). |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jim-minter some comments... overall it looks nice. I like the downloader/uploader code. I would think that could be useful outside of this context, so in the future we may want to move it to a package outside of the bootstrap package.
func StreamFileFromContainer(client *docker.Client, container, src string) (io.ReadCloser, error) { | ||
downloader := newContainerDownloader(client, container, src) | ||
|
||
for { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the for loop is not needed
// container. | ||
func DownloadDirFromContainer(client *docker.Client, container, src, dst string) error { | ||
downloader := newContainerDownloader(client, container, src) | ||
defer downloader.Close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should call the code to untar from here:
/~https://github.com/openshift/origin/blob/master/vendor/github.com/openshift/source-to-image/pkg/tar/tar.go
(to help with maintenance)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main reason I didn't was that I'm stripping off the leading directory name when writing files from the incoming tar file, e.g. foo/bar/baz -> bar/baz. The s2i tar code doesn't currently allow this, and I was hoping to avoid the extract to temporary directory and moving files around alternative.
I could add the relevant functionality into source-to-image and pull it through, but I think it implies bit of refactoring to make it sit well. Adding a "strip leading directory" flag to ExtractTarStreamWithLogging didn't feel like a great option, and breaking the function apart to abstractions seemed like overkill. So I made a copy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the reason I suggested reuse is that this extract/compress code will need to work on Windows/Mac. We've already fixed an issue or 2 around that on the s2i code. My preference would be to still keep that as the one place where we do this. We should change it and make it more flexible if needed.
return nil, err | ||
} | ||
if header.Name != filepath.Base(src) || (header.Typeflag != tar.TypeReg && header.Typeflag != tar.TypeRegA) { | ||
return nil, errors.New("unexpected tar file content " + header.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also include the TypeFlag in the error message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also use the same tar code for the uploader below if possible.
// CopyFromHost copies a set of files from the Docker host to the local file system | ||
func (h *HostHelper) CopyFromHost(sourceDir, destDir string) error { | ||
// DownloadDirFromContainer copies a set of files from the Docker host to the local file system | ||
func (h *HostHelper) DownloadDirFromContainer(sourceDir, destDir string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're going to always mount the config dir from the container, then the function name should reflect that ... like DownloadConfigDir
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was hoping to leave these names more broad to signpost a single path for down/uploading arbitrary files from the container, if required in the future for whatever reason. If necessary this may entail adding in the other bind mounts up top, but I left those out for now. What's best to do here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Can we pass the bindmounts in and have a wrapper function that passes the config one in?
bind := fmt.Sprintf("%s:/var/lib/origin/openshift.local.config:z", destDir) | ||
// UploadFileToContainer copies a local file to the Docker host | ||
func (h *HostHelper) UploadFileToContainer(src, dst string) error { | ||
bind := fmt.Sprintf("%s:/var/lib/origin/openshift.local.config:z", h.configDir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, if we're always mounting the local config, then the function name should reflect that.
Long: cmdStatusLong, | ||
Example: fmt.Sprintf(cmdStatusExample, fullName), | ||
Run: func(c *cobra.Command, args []string) { | ||
kcmdutil.CheckErr(config.Status(f, out)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should reuse the code to print the error that we have here:
/~https://github.com/openshift/origin/blob/master/pkg/bootstrap/docker/printer.go#L71
(otherwise additional error details like the cause don't get printed out)
return err | ||
} | ||
if !healthy { | ||
return notRunning |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the container is running but not healthy, we should say so
DockerMachine string | ||
} | ||
|
||
// Status prints the developer cluster status |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/developer/OpenShift/
20c235d
to
1ca3d84
Compare
[test] |
#8571 |
Rebased. |
flake #11240 again |
Hi @jim-minter, please rename your s2i bump commit to follow the bump naming convention: |
@csrwng done |
#11438 |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/10377/) (Image: devenv-rhel7_5216) |
@jim-minter please rebase and regenerate docs and completions |
or |
@PI-Victor careful w/ make update. it'll regen your protobufs and if you're on go1.7, it'll generate them wrong. |
@jim-minter no. different issue. go1.7 and go 1.6 protogen produce different outputs (both valid, but the verification check will complain that they are not the same) |
[test] |
[test] |
@jim-minter the PR for the logging flag did merge. I'll leave it up to you if you want to add the code to display the logging URL in this PR or we just create a new one after this one merges. |
@csrwng I'll be glad once this one's merged! Logging URL code added. |
@jim-minter me too :) LGTM pending tests passing |
flake #11004 |
@jim-minter well the s2i bump went in but your commits from that bump in this PR don't seem to have gone away like i would have expected. I think you may need to do another rebase and/or drop those commits from your branch. |
@bparees yes, I rebased yesterday to fix the merge conflicts up front. Now I've rebased again and it should be good to go. |
Evaluated for origin test up to 66ae0b7 |
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/10377/) (Base Commit: f60c1df) |
[merge] |
Evaluated for origin merge up to 66ae0b7 |
Fixes #9935