feat: Native DaemonSet Progressive Delivery - Part 1: Core Infrastruc…#314
feat: Native DaemonSet Progressive Delivery - Part 1: Core Infrastruc…#314kruise-bot merged 6 commits intoopenkruise:masterfrom
Conversation
…ture Signed-off-by: Marco Ma <marco.ma@sap.com>
Signed-off-by: Marco Ma <marco.ma@sap.com>
Signed-off-by: Marco Ma <marco.ma@sap.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #314 +/- ##
==========================================
+ Coverage 47.99% 50.60% +2.61%
==========================================
Files 63 64 +1
Lines 9841 8201 -1640
==========================================
- Hits 4723 4150 -573
+ Misses 4559 3478 -1081
- Partials 559 573 +14
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Marco Ma <qingjin_ma@163.com>
| revision := &revisionList.Items[i] | ||
| // Check if this ControllerRevision is owned by the DaemonSet | ||
| if ref := metav1.GetControllerOf(revision); ref != nil { | ||
| if ref.Name == daemonSet.Name && ref.Kind == "DaemonSet" { |
There was a problem hiding this comment.
please also check the apiversion field of the reference. Alternatively, just check the uid of the ref ?
There was a problem hiding this comment.
Good catch! You're right that we should validate the owner reference more strictly.
I'll update the code to check the UID directly, which is more reliable than checking
Name/Kind/APIVersion separately.
pkg/util/controller_finder.go
Outdated
| } | ||
|
|
||
| func (r *ControllerFinder) getStatefulSetLikeWorkload(namespace string, ref *rolloutv1beta1.ObjectRef) (*Workload, error) { | ||
| ok, _ := verifyGroupKind(ref, ControllerKindSts.Kind, []string{ControllerKindSts.Group}) |
There was a problem hiding this comment.
During testing, I discovered that getNativeDaemonSet was never being reached. After adding more logs, I found the reason is that because getStatefulSetLikeWorkload (earlier in the finder chain: return []ControllerFinderFunc{r.getKruiseCloneSet, r.getAdvancedDeployment, r.getStatefulSetLikeWorkload, r.getKruiseDaemonSet, r.getNativeDaemonSet}) was incorrectly entered due to missing validation. Adding these checks ensures each finder only matches its intended workload type, allowing all finders in the chain to function properly.
| if newObj.Annotations == nil { | ||
| newObj.Annotations = map[string]string{} | ||
| } | ||
| newObj.Annotations[util.InRolloutProgressingAnnotation] = string(by) |
There was a problem hiding this comment.
shall we keep the original update strategy of daemonset in annotation
There was a problem hiding this comment.
Good point! I initially thought DaemonSets wouldn't use OnDelete strategy in real scenarios, but that assumption was too optimistic. I'll add the logic to store the strategy type in the annotation to ensure we can properly restore it later.
| // if batchPartition == nil, workload should be promoted to use the original update strategy | ||
| if release.Spec.ReleasePlan.BatchPartition == nil { | ||
| updateStrategy := apps.DaemonSetUpdateStrategy{ | ||
| Type: apps.RollingUpdateDaemonSetStrategyType, |
There was a problem hiding this comment.
what if the original update strategy is already OnDelete?
There was a problem hiding this comment.
Same as above. The logic will be changed to restore update strategy by annotation.
|
/lgtm |
|
@furykerry I'll address these two improvements: |
Signed-off-by: Marco Ma <qingjin_ma@163.com>
Signed-off-by: Marco Ma <qingjin_ma@163.com>
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: furykerry The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Summary
This PR implements the first part of Native DaemonSet Progressive Delivery support. This foundational implementation enables progressive delivery for standard Kubernetes DaemonSets (apps/v1) within the Kruise Rollout framework, which focuses on the core controller logic, ControllerRevision discovery, and BatchRelease integration as defined in the proposal.
Implementation Details
1. Core Controller Infrastructure
pkg/controller/batchrelease/control/partitionstyle/nativedaemonset/Initialize,UpgradeBatch,Finalize,CalculateBatchContextinterface methods2. Workload Discovery and Parsing
pkg/util/controller_finder.gopkg/util/parse_utils.goParseDaemonSetfunction for native DaemonSet workload parsingpkg/util/workloads_utils.go3. BatchRelease Integration
batchrelease_controller.go,batchrelease_event_handler.go, andbatchrelease_executor.goto recognize and process native DaemonSet workloads4. Rollout Controller Integration
rollout_controller.goandrollout_status.gohandling to support native DaemonSet workload references5. Webhook Mutation Support
pkg/webhook/workload/mutating/workload_update_handler.gohandleNativeDaemonSetfunction for DaemonSet template change detection and integration with rollout progression workflowpkg/webhook/workload/mutating/webhooks.go6. Configuration and Permissions
config/rbac/role.yamlconfig/webhook/manifests.yamlpkg/util/constant.goWhat's Next
This is Part 1 of 3 in the Native DaemonSet Progressive Delivery implementation: