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 "kubectl validate" command to do a cluster health check. #6597

Merged
merged 2 commits into from Apr 20, 2015

Conversation

fabioy
Copy link
Contributor

@fabioy fabioy commented Apr 8, 2015

This is the first step to resolving issue #5946.

@satnam6502
Copy link
Contributor

I think Zach is in a better position to review this PR.


// ClusterValidationState retrieves and parses the server's self-monitored cluster state.
func (c *Client) ClusterValidationState() (*api.ServerStatusList, error) {
body, err := c.Get().AbsPath("/validate").Do().Raw()
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a TODO to make this hit a versioned validate endpoint?

Copy link
Contributor

Choose a reason for hiding this comment

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

Does this return an api.Status? If not then DoRaw() might be better.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is DoRaw() different from Do().Raw()?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I discovered a bug where Do().Raw() does the wrong thing when the non-apiStatus JSON response includes a status field as is the case with Elasticsearch. I refactored it into two distinct phases which first processes the response without assuming it is an api.Status (this is done by DoRaw()) and then interpret it as an api.Status which is done by Do() which now calls DoRaw(). I think we should replace all occurrences of Do().Raw() with DoRaw() and remove the Raw() method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added TODO and changed to DoRaw().

@roberthbailey
Copy link
Contributor

Since this makes changes to the api and @zmerlynn is out this week, I'm going to bounce this over to @lavalamp for server-side review. @jlowdermilk might also want to take a look at the kubectl changes.

@fabioy
Copy link
Contributor Author

fabioy commented Apr 10, 2015

Rebased and pushed the changes. PTAL. Thank you.

@@ -128,7 +128,7 @@ func TestList(t *testing.T) {
roundTripSame(t, item)
}

var nonRoundTrippableTypes = util.NewStringSet("ContainerManifest", "ContainerManifestList")
var nonRoundTrippableTypes = util.NewStringSet("ContainerManifest", "ContainerManifestList", "ServerStatus")
Copy link
Member

Choose a reason for hiding this comment

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

New objects should never appear in this list. You have a bug in your conversions if you need this.

@lavalamp
Copy link
Member

I have pointed out some problems. Reassigning to @bgrant0607 to approve an API change.

@lavalamp lavalamp assigned bgrant0607 and unassigned lavalamp Apr 10, 2015
@@ -65,6 +65,7 @@ Find more information at https://github.com/GoogleCloudPlatform/kubernetes.`,
cmds.AddCommand(NewCmdClusterInfo(f, out))
cmds.AddCommand(NewCmdApiVersions(f, out))
cmds.AddCommand(NewCmdVersion(f, out))
cmds.AddCommand(NewCmdValidateCluster(f, out))
Copy link
Member

Choose a reason for hiding this comment

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

We have cluster-info. How about cluster-validate? validate is just too generic, and we're likely to want to use that for validating user objects.

Copy link
Member

Choose a reason for hiding this comment

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

I take it back. If this is just component status, we should call it component-status.

If we versioned the APIs, it could be:

kubectl get cs

@bgrant0607
Copy link
Member

More context please? The PR description and cited issue say almost nothing.

@bgrant0607
Copy link
Member

This is going to be a breaking API change. Have you asked on kubernetes-dev whether anyone is using the current /validate API?

@@ -1767,3 +1768,19 @@ func AddToNodeAddresses(addresses *[]NodeAddress, addAddresses ...NodeAddress) {
}
}
}

// ServerStatus (and ServerStatusList) holds the cluster validation info.
type ServerStatus struct {
Copy link
Member

Choose a reason for hiding this comment

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

Please remove the json tags here. This is the internal rep.

@fabioy
Copy link
Contributor Author

fabioy commented Apr 16, 2015

@bgrant0607 Ping. Does the object model seem ok?

@bgrant0607
Copy link
Member

@fabioy Will take a look tonight. In the future, feel free to ping me by direct email. I'm drowning in Github notifications.

// Returns the list of component status. Note that the label and field are both ignored.
// Note that this call doesn't support labels or selectors.
func (rs *REST) List(ctx api.Context, label labels.Selector, field fields.Selector) (runtime.Object, error) {
servers := rs.GetServersToValidate()
Copy link
Member

Choose a reason for hiding this comment

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

Eventually I want the apiserver to be a dumb, CRUDy server. Eventually, a controller would need to implement all the business logic and post status back.

We'll need a registration mechanism for components. Right now, we sort of have a fixed set of components on one node, but that's about to change Real Soon Now. Already we have "add ons" that run on the cluster but which are required, or will be (DNS), and full API plugins are planned. The components are all being converted to static pods as we speak. Others are working on HA, so components will be replicated. Full self-hosting of those components is the eventual goal.

What should this return if there are 5 etcd instances, 3 apiservers, 2 schedulers, and 2 controller managers?

Copy link
Member

Choose a reason for hiding this comment

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

I'm wishing we had the experimental API prefix discussed in #6363 and elsewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"What should this return if there are 5 etcd instances, 3 apiservers, 2 schedulers, and 2 controller managers?"

The call is to the current master api server, which tries it best to return the status of the currently active components. It seems irrelevant to list the "stand-by" components. When HA become available, this "extended" reporting could be done under an option flag.

@fabioy
Copy link
Contributor Author

fabioy commented Apr 17, 2015

Addressed comments, sync'ed, rebased and pushed changes. PTAL. Thank you!

@brendandburns
Copy link
Contributor

LGTM.

This PR has gone on long enough. This looks good enough to merge as a first round (and its certainly an improvement over what was there previously)

To be honest, blocking this PR on making it into a real API seems kind of like Overkill to me, but I was out, and now its done so merge and move on...

brendandburns added a commit that referenced this pull request Apr 20, 2015
Add "kubectl validate" command to do a cluster health check.
@brendandburns brendandburns merged commit e079e23 into kubernetes:master Apr 20, 2015
@bgrant0607
Copy link
Member

AFAICT, this PR had unresolved feedback. Maybe changes weren't pushed?

@bgrant0607
Copy link
Member

It also demonstrates another bug was introduced into verify-description.sh, since this should be failing it:
https://github.com/GoogleCloudPlatform/kubernetes/blob/master/pkg/api/v1beta1/types.go#L1606


type ComponentCondition struct {
Type ComponentConditionType `json:"type" description:"the type of condition"`
Status ConditionStatus `json:"status" description:"the status of this condition"`
Copy link
Member

Choose a reason for hiding this comment

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

This file shouldn't have description tags. Description tags need to be on all non-inline fields in the versioned types.go files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting, I have the standard presubmit hooks. Filed issue #7080 for the "verify-description.sh" error. I'll prepare a separate PR and address these.

@fabioy
Copy link
Contributor Author

fabioy commented Apr 20, 2015

I've created a separate PR to resolve these issues. PR #7082. Thank you.

@fabioy fabioy deleted the kubectl-validate branch April 24, 2015 16:55
@YitongFeng
Copy link

Is this feature still work? how to use kubectl validate? In k8s 1.9.9, kubectl validate command not found

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