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

Implement cluster status command, fixes #9935 #11171

Merged
merged 1 commit into from
Oct 21, 2016

Conversation

jim-minter
Copy link
Contributor

@jim-minter jim-minter commented Sep 30, 2016

Fixes #9935

Copy link
Contributor

@php-coder php-coder left a 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")
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

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

s/will obtain/obtains/

@jim-minter
Copy link
Contributor Author

@php-coder thanks for the good practice; suggested changes made.

@php-coder
Copy link
Contributor

php-coder commented Sep 30, 2016

@jim-minter Thanks!

Did you see that Travis fails with "FAILURE: Generated completions out of date. Please run hack/update-generated-completions.sh"?

@jim-minter
Copy link
Contributor Author

Oh dear - thanks for pointing that out.

@csrwng
Copy link
Contributor

csrwng commented Sep 30, 2016

Looks like you'll also need to run hack/update-generated-docs.sh

@csrwng
Copy link
Contributor

csrwng commented Sep 30, 2016

@jim-minter if possible we should display additional information when running status:

  • URL to the web console
  • URL to metrics if you decided to add metrics
  • Host dir for config
  • Host dir for volumes
  • Host dir for data (or a message saying that it will be discarded if you didn't specify one)
  • Uptime ? (not that important)

Something like:

The cluster has been running for 30 minutes

Web console URL: https://127.0.0.1:8443/console
Metrics URL:     https://metrics-openshift-infra.1.2.3.4.xip.io/

Config is at host directory /var/lib/origin/openshift.local.config
Volumes are at host directory /var/lib/origin/openshift.local.volumes 
Data will be discarded when cluster is destroyed.

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).

@jim-minter
Copy link
Contributor Author

$ oc cluster status
The OpenShift cluster was started 20 minutes ago

Web console URL: https://192.168.121.57:8443
Metrics URL:     https://metrics-openshift-infra.192.168.121.57.xip.io/hawkular/metrics

Config is at host directory /var/lib/origin/openshift.local.config
Volumes are at host directory /var/lib/origin/openshift.local.volumes
Data will be discarded when cluster is destroyed

Copy link
Contributor

@csrwng csrwng left a 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 {
Copy link
Contributor

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()
Copy link
Contributor

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)

Copy link
Contributor Author

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.

Copy link
Contributor

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)
Copy link
Contributor

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

Copy link
Contributor

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 {
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

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)
Copy link
Contributor

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))
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

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

s/developer/OpenShift/

@jim-minter jim-minter force-pushed the issue9935 branch 3 times, most recently from 20c235d to 1ca3d84 Compare October 12, 2016 11:06
@jim-minter
Copy link
Contributor Author

[test]

@csrwng
Copy link
Contributor

csrwng commented Oct 12, 2016

#8571
[test]

@jim-minter
Copy link
Contributor Author

Rebased.
flake #11240
[test]

@jim-minter
Copy link
Contributor Author

flake #11240 again

@csrwng
Copy link
Contributor

csrwng commented Oct 13, 2016

Hi @jim-minter, please rename your s2i bump commit to follow the bump naming convention:
#9128

@jim-minter
Copy link
Contributor Author

@csrwng done

@csrwng csrwng mentioned this pull request Oct 14, 2016
@csrwng
Copy link
Contributor

csrwng commented Oct 17, 2016

#9548
#9490
[merge]

@csrwng
Copy link
Contributor

csrwng commented Oct 19, 2016

#11438
[merge]

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 19, 2016
@openshift-bot
Copy link
Contributor

openshift-bot commented Oct 20, 2016

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/10377/) (Image: devenv-rhel7_5216)

@csrwng
Copy link
Contributor

csrwng commented Oct 20, 2016

@jim-minter please rebase and regenerate docs and completions

@jim-minter
Copy link
Contributor Author

@bparees @csrwng I have rebased this to sit on top of the s2i bump in #11414 which we're trying to get through.

@PI-Victor
Copy link
Contributor

Looks like you'll also need to run hack/update-generated-docs.sh

or make update that takes care of everything :)

@bparees
Copy link
Contributor

bparees commented Oct 20, 2016

@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
Copy link
Contributor Author

@bparees is that protobuf problem #10696 (which is now closed)?

@bparees
Copy link
Contributor

bparees commented Oct 20, 2016

@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)

@jim-minter
Copy link
Contributor Author

[test]

@jim-minter jim-minter removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 20, 2016
@jim-minter
Copy link
Contributor Author

[test]

@csrwng
Copy link
Contributor

csrwng commented Oct 20, 2016

@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.

@jim-minter
Copy link
Contributor Author

@csrwng I'll be glad once this one's merged! Logging URL code added.

@csrwng
Copy link
Contributor

csrwng commented Oct 20, 2016

@jim-minter me too :) LGTM pending tests passing

@jim-minter
Copy link
Contributor Author

flake #11004
[test]

@bparees
Copy link
Contributor

bparees commented Oct 21, 2016

@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.

@jim-minter
Copy link
Contributor Author

@bparees yes, I rebased yesterday to fix the merge conflicts up front. Now I've rebased again and it should be good to go.

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 66ae0b7

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/10377/) (Base Commit: f60c1df)

@csrwng
Copy link
Contributor

csrwng commented Oct 21, 2016

[merge]

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 66ae0b7

@openshift-bot openshift-bot merged commit 643f3f8 into openshift:master Oct 21, 2016
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.

None yet

6 participants