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 prometheus for pub and deletion protection #1346

Closed
wants to merge 1 commit into from

Conversation

zmberg
Copy link
Member

@zmberg zmberg commented Jul 27, 2023

Ⅰ. Describe what this PR does

Add prometheus for pub and deletion protection.

  • namespace_deletion_protection{name='test-ns', username='kubernetes-admin'}
  • crd_deletion_protection{name='advancedcronjobs.apps.kruise.io', username='kubernetes-admin'}
  • workload_deletion_protection{kind='CloneSet', name='web-server', username='kubernetes-admin'}
  • pod_unavailable_budget{kind='CloneSet', name='web-server', username='kubernetes-admin'}

Add event in pod for pub.

  • Warning PubPreventPodDeletion 7s (x2 over 33m) pub-controller openkruise pub prevents pod deletion

Signed-off-by: liheng.zms <liheng.zms@alibaba-inc.com>
@sonatype-lift
Copy link

sonatype-lift bot commented Jul 27, 2023

Sonatype Lift is retiring

Sonatype Lift will be retiring on Sep 12, 2023, with its analysis stopping on Aug 12, 2023. We understand that this news may come as a disappointment, and Sonatype is committed to helping you transition off it seamlessly. If you’d like to retain your data, please export your issues from the web console.
We are extremely grateful and thank you for your support over the years.

📖 Read about the impacts and timeline

@kruise-bot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from zmberg by writing /assign @zmberg in a comment. For more information see:The Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@kruise-bot kruise-bot added the size/L size/L: 100-499 label Jul 27, 2023
name = pod.Name
}
PodUnavailableBudgetMetrics.WithLabelValues(kind, name, username).Add(1)
recorder.Eventf(pod, corev1.EventTypeWarning, "PubPreventPodDeletion", fmt.Sprintf("openkruise pub prevents pod deletion"))
Copy link

Choose a reason for hiding this comment

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

S1039: unnecessary use of fmt.Sprintf


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.

@@ -55,24 +56,39 @@ const (
PodRelatedPubAnnotation = "kruise.io/related-pub"
)

var (
Copy link
Member

Choose a reason for hiding this comment

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

consider moving metrics related variables and initialization logic into a separate file e.g. pub_control_metrics.go


var (
NamespaceDeletionProtectionMetrics = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Copy link
Member

Choose a reason for hiding this comment

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

consider replacing Gauge with Counter, protection metrics will not be decreased

prometheus.GaugeOpts{
Name: "workload_deletion_protection",
Help: "Workload Deletion Protection",
}, []string{"kind", "name", "username"},
Copy link
Member

Choose a reason for hiding this comment

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

consider combine workload type, namespace, and name into a single label so as to avoid metrics flood.

@@ -133,7 +129,7 @@ func (c *realControl) Update(cs *appsv1alpha1.CloneSet,
for _, idx := range waitUpdateIndexes {
pod := pods[idx]
// Determine the pub before updating the pod
if utilfeature.DefaultFeatureGate.Enabled(features.PodUnavailableBudgetUpdateGate) {
/*if utilfeature.DefaultFeatureGate.Enabled(features.PodUnavailableBudgetUpdateGate) {
Copy link
Member

Choose a reason for hiding this comment

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

why comment out this code block

@kruise-bot
Copy link

@zmberg: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@zmberg zmberg closed this Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase size/L size/L: 100-499
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants