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

auto patch webhook objectSelector label on workload #158

Merged

Conversation

zmberg
Copy link
Member

@zmberg zmberg commented Jul 4, 2023

Ⅰ. Describe what this PR does

Rollout patch webhook label on workload

Currently rollout will webhook all workloads update requests, include Deployment, StatefulSet, CloneSet, Advanced StatefulSet. But not all workloads have to be rollout released, and if kruise rollout crashes will lead to workload update failed. So we can add configuration in MutatingWebhookConfiguration yaml.

apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
...
  objectSelector:
      matchExpressions:
        - key: rollouts.kruise.io/workload-type
          operator: Exists

And the rollout controller patches the above label to the workload according to the Rollout objectRef.

@kruise-bot kruise-bot requested review from FillZpp and veophi July 4, 2023 08:11
@zmberg zmberg force-pushed the patch_webhook_label_on_workload branch from 5e6d7bd to 1e0d1b7 Compare July 4, 2023 08:57
@codecov-commenter
Copy link

codecov-commenter commented Jul 4, 2023

Codecov Report

Merging #158 (082e0a5) into master (88e4bb7) will decrease coverage by 0.37%.
The diff coverage is 0.00%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##           master     #158      +/-   ##
==========================================
- Coverage   43.74%   43.38%   -0.37%     
==========================================
  Files          50       50              
  Lines        5301     5352      +51     
==========================================
+ Hits         2319     2322       +3     
- Misses       2588     2634      +46     
- Partials      394      396       +2     
Flag Coverage Δ
unittests 43.38% <0.00%> (-0.37%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/controller/rollout/rollout_controller.go 10.95% <0.00%> (-0.31%) ⬇️
pkg/controller/rollout/rollout_status.go 20.96% <0.00%> (-3.57%) ⬇️

... and 5 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

case util.ControllerKruiseKindDS.Kind:
workloadType = util.DaemonSetType
}
if workload.Annotations[util.WorkloadTypeLabel] == "" && workloadType != "" {
Copy link
Member

Choose a reason for hiding this comment

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

can we move this code block to a separate func ? e.g. updateRolloutWorkload, since it has nothing to do with the rollout object. updateRolloutWorkload can be placed before handleFinalizer

@zmberg zmberg force-pushed the patch_webhook_label_on_workload branch from 1e0d1b7 to 7c52ee5 Compare July 5, 2023 11:30
@@ -19,6 +19,7 @@ package rollout
import (
"context"
"fmt"
"k8s.io/apimachinery/pkg/runtime/schema"
Copy link

Choose a reason for hiding this comment

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

23% of developers fix this issue

goimports: File is not goimports-ed


ℹ️ 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.

@zmberg zmberg force-pushed the patch_webhook_label_on_workload branch from 7c52ee5 to 728afb9 Compare July 6, 2023 02:25
@zmberg zmberg force-pushed the patch_webhook_label_on_workload branch 2 times, most recently from 8d71bd5 to 34d2989 Compare July 10, 2023 03:23
@zmberg zmberg force-pushed the patch_webhook_label_on_workload branch from 34d2989 to 082e0a5 Compare July 10, 2023 08:07
Copy link
Member

@furykerry furykerry left a comment

Choose a reason for hiding this comment

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

/lgtm

@zmberg
Copy link
Member Author

zmberg commented Jul 11, 2023

/approve

@kruise-bot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: zmberg

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

@kruise-bot kruise-bot merged commit e99c529 into openkruise:master Jul 11, 2023
17 checks passed
@zmberg zmberg deleted the patch_webhook_label_on_workload branch July 11, 2023 06:24
Kuromesi pushed a commit to Kuromesi/rollouts that referenced this pull request Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants