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

deployment status conditions #889

Merged
merged 1 commit into from
Sep 19, 2019
Merged

deployment status conditions #889

merged 1 commit into from
Sep 19, 2019

Conversation

terinjokes
Copy link
Contributor

What this PR does / why we need it:

Deployments, like Nodes, have status conditions observing the
current state. While the state of Available and Progressing conditions
can likely be inferred by other metrics, the state of ReplicaFailure can
not be inferred.

This changelist adds a new metric kube_deployment_status_condition
that observes all the conditions on a deployment for each condition
status. This is analogous to the status conditions observed by nodes and
horizontal pod autoscalers, and allows kube-state-metrics to observe
status conditions added by third-parties.

As an example, for a deployment that has stalled, the following new
metrics observed would allow an operator to detect the condition:

kube_deployment_status_condition{deployment="example", namespace="default", condition="ReplicaFailure", status="true"} 1
kube_deployment_status_condition{deployment="example", namespace="default", condition="ReplicaFailure", status="false"} 0
kube_deployment_status_condition{deployment="example", namespace="default", condition="ReplicaFailure", status="unknown"} 0

Which issue(s) this PR fixes:
Fixes #886

Deployments, like Nodes, have status conditions observing the
current state. While the state of Available and Progressing conditions
can likely be inferred by other metrics, the state of ReplicaFailure can
not be inferred.

This changelist adds a new metric `kube_deployment_status_condition`
that observes all the conditions on a deployment for each condition
status. This is analogous to the status conditions observed by nodes and
horizontal pod autoscalers, and allows kube-state-metrics to observe
status conditions added by third-parties.

As an example, for a deployment that has stalled, the following new
metrics observed would allow an operator to detect the condition:

    kube_deployment_status_condition{deployment="example", namespace="default", condition="ReplicaFailure", status="true"} 1
    kube_deployment_status_condition{deployment="example", namespace="default", condition="ReplicaFailure", status="false"} 0
    kube_deployment_status_condition{deployment="example", namespace="default", condition="ReplicaFailure", status="unknown"} 0

Bug: #886
Signed-off-by: Terin Stock <terin@cloudflare.com>
@k8s-ci-robot
Copy link
Contributor

Welcome @terinjokes!

It looks like this is your first PR to kubernetes/kube-state-metrics 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kube-state-metrics has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 19, 2019
Copy link
Contributor

@tariq1890 tariq1890 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @terinjokes !

Just some minor comments from me.

GenerateFunc: wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family {
ms := make([]*metric.Metric, len(d.Status.Conditions)*len(conditionStatuses))

// Collect node conditions and while default to false.
Copy link
Contributor

Choose a reason for hiding this comment

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

Hah, did I just spot a copypasta (Man, am I guilty of this!) here :) ? Let's have a more descriptive and accurate comment OR not have a comment at all. Your call.

(I also agree that the comment in internal/store/node.go needs to be better).

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, no, i wouldn't copy and paste and forget to update a comment! 😭

hpa has no comments, and I don't think this one is accurate anyways. I'll remove

{
Name: "kube_deployment_status_condition",
Type: metric.Gauge,
Help: "The condition of a deployment.",
Copy link
Contributor

@tariq1890 tariq1890 Sep 19, 2019

Choose a reason for hiding this comment

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

Suggested change
Help: "The condition of a deployment.",
Help: "Describes the current state of a deployment.",

The equivalent node metric's description isn't that great unfortunately :(. Something that needs to be fixed in the future.

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 attempted to come to a middle ground based on the other help texts for deployments.

@@ -122,6 +122,35 @@ var (
}
}),
},
// This all-in-one metric family contains all conditions for extensibility.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need these comments?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

Copy link
Member

@lilic lilic left a comment

Choose a reason for hiding this comment

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

Thanks!

I have one small nit, otherwise, it looks good to me.

internal/store/deployment.go Show resolved Hide resolved
Copy link
Contributor

@tariq1890 tariq1890 left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 19, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tariq1890, terinjokes

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 Sep 19, 2019
@k8s-ci-robot k8s-ci-robot merged commit d7564d5 into kubernetes:master Sep 19, 2019
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. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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.

deployment condition metrics
4 participants