Skip to content

Conversation

@britaniar
Copy link
Collaborator

@britaniar britaniar commented Nov 5, 2025

Description of your changes

Fixes #

I have:

  • Updated UpdateRunSpec API to make ResourceSnapshotIndex optional in staged update run.

  • Updated UpdateRunStatus API to record ResourceSpanpshotIndexUsed.

  • Update the initialization stage of staged update run to check if ResourceSnapshotIndex is defined to find that specific resource snapshot. Otherwise, if not defined it will use the latest resource snapshot.

  • Added an integration test case where relevant.

  • Update e2e and integration tests to include the resource snapshot index used in the update run status check.

  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

  • Integration test
  • e2e test

Special notes for your reviewer

UpdateRun:

apiVersion: placement.kubernetes-fleet.io/v1beta1
kind: ClusterStagedUpdateRun
metadata:
  creationTimestamp: "2025-11-17T20:07:33Z"
  finalizers:
  - kubernetes-fleet.io/stagedupdaterun-finalizer
  generation: 1
  name: cur-1-1
  resourceVersion: "1938"
  uid: 7c2ccb91-f877-4ef4-b88b-b2bbd88093f8
spec:
  placementName: crp-1
  resourceSnapshotIndex: ""
  stagedRolloutStrategyName: curs-1
  state: NotStarted
status:
  appliedStrategy:
    comparisonOption: PartialComparison
    type: ClientSideApply
    whenToApply: Always
    whenToTakeOver: Always
  conditions:
  - lastTransitionTime: "2025-11-17T20:07:33Z"
    message: ClusterStagedUpdateRun initialized successfully
    observedGeneration: 1
    reason: UpdateRunInitializedSuccessfully
    status: "True"
    type: Initialized
  - lastTransitionTime: "2025-11-17T20:08:33Z"
    message: All stages are completed
    observedGeneration: 1
    reason: UpdateRunSucceeded
    status: "False"
    type: Progressing
  - lastTransitionTime: "2025-11-17T20:08:33Z"
    message: All stages are completed successfully
    observedGeneration: 1
    reason: UpdateRunSucceeded
    status: "True"
    type: Succeeded
  deletionStageStatus:
    clusters: []
    conditions:
    - lastTransitionTime: "2025-11-17T20:08:33Z"
      message: All clusters in the stage are updated and after-stage tasks are completed
      observedGeneration: 1
      reason: StageUpdatingSucceeded
      status: "False"
      type: Progressing
    - lastTransitionTime: "2025-11-17T20:08:33Z"
      message: Stage update completed successfully
      observedGeneration: 1
      reason: StageUpdatingSucceeded
      status: "True"
      type: Succeeded
    endTime: "2025-11-17T20:08:33Z"
    stageName: kubernetes-fleet.io/deleteStage
    startTime: "2025-11-17T20:08:33Z"
  policyObservedClusterCount: 3
  policySnapshotIndexUsed: "0"
  resourceSnapshotIndexUsed: "1"
  stagedUpdateStrategySnapshot:
    stages:
    - afterStageTasks:
      - type: Approval
      - type: TimedWait
        waitTime: 5s
      labelSelector:
        matchLabels:
          env: canary
      maxConcurrency: 1
      name: canary
    - labelSelector:
        matchLabels:
          env: prod
      maxConcurrency: 1
      name: prod
  stagesStatus:
  - afterStageTaskStatus:
    - approvalRequestName: cur-1-1-canary
      conditions:
      - lastTransitionTime: "2025-11-17T20:07:48Z"
        message: ApprovalRequest object is created
        observedGeneration: 1
        reason: AfterStageTaskApprovalRequestCreated
        status: "True"
        type: ApprovalRequestCreated
      - lastTransitionTime: "2025-11-17T20:08:03Z"
        message: ApprovalRequest object is approved
        observedGeneration: 1
        reason: AfterStageTaskApprovalRequestApproved
        status: "True"
        type: ApprovalRequestApproved
      type: Approval
    - conditions:
      - lastTransitionTime: "2025-11-17T20:07:53Z"
        message: Wait time elapsed
        observedGeneration: 1
        reason: AfterStageTaskWaitTimeElapsed
        status: "True"
        type: WaitTimeElapsed
      type: TimedWait
    clusters:
    - clusterName: kind-cluster-2
      conditions:
      - lastTransitionTime: "2025-11-17T20:07:33Z"
        message: Cluster update started
        observedGeneration: 1
        reason: ClusterUpdatingStarted
        status: "True"
        type: Started
      - lastTransitionTime: "2025-11-17T20:07:48Z"
        message: Cluster update completed successfully
        observedGeneration: 1
        reason: ClusterUpdatingSucceeded
        status: "True"
        type: Succeeded
    conditions:
    - lastTransitionTime: "2025-11-17T20:07:48Z"
      message: All clusters in the stage are updated and after-stage tasks are completed
      observedGeneration: 1
      reason: StageUpdatingSucceeded
      status: "False"
      type: Progressing
    - lastTransitionTime: "2025-11-17T20:08:03Z"
      message: Stage update completed successfully
      observedGeneration: 1
      reason: StageUpdatingSucceeded
      status: "True"
      type: Succeeded
    endTime: "2025-11-17T20:08:03Z"
    stageName: canary
    startTime: "2025-11-17T20:07:33Z"
  - clusters:
    - clusterName: kind-cluster-1
      conditions:
      - lastTransitionTime: "2025-11-17T20:08:03Z"
        message: Cluster update started
        observedGeneration: 1
        reason: ClusterUpdatingStarted
        status: "True"
        type: Started
      - lastTransitionTime: "2025-11-17T20:08:18Z"
        message: Cluster update completed successfully
        observedGeneration: 1
        reason: ClusterUpdatingSucceeded
        status: "True"
        type: Succeeded
    - clusterName: kind-cluster-3
      conditions:
      - lastTransitionTime: "2025-11-17T20:08:18Z"
        message: Cluster update started
        observedGeneration: 1
        reason: ClusterUpdatingStarted
        status: "True"
        type: Started
      - lastTransitionTime: "2025-11-17T20:08:33Z"
        message: Cluster update completed successfully
        observedGeneration: 1
        reason: ClusterUpdatingSucceeded
        status: "True"
        type: Succeeded
    conditions:
    - lastTransitionTime: "2025-11-17T20:08:33Z"
      message: All clusters in the stage are updated and after-stage tasks are completed
      observedGeneration: 1
      reason: StageUpdatingSucceeded
      status: "False"
      type: Progressing
    - lastTransitionTime: "2025-11-17T20:08:33Z"
      message: Stage update completed successfully
      observedGeneration: 1
      reason: StageUpdatingSucceeded
      status: "True"
      type: Succeeded
    endTime: "2025-11-17T20:08:33Z"
    stageName: prod
    startTime: "2025-11-17T20:08:03Z"

@codecov
Copy link

codecov bot commented Nov 6, 2025

Codecov Report

❌ Patch coverage is 80.48780% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/controllers/updaterun/initialization.go 80.00% 6 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@britaniar britaniar marked this pull request as ready for review November 6, 2025 00:37
@Arvindthiru
Copy link
Collaborator

Arvindthiru commented Nov 6, 2025

We also need to account for resourceSnapshotIndex access here https://github.com/britaniar/kubefleet/blob/bff950842f01cab0eb0041401ed4ef7134581848/pkg/controllers/updaterun/execution.go#L99.

I think it's better to populate the ResourceSnapshotIndex field in the spec by a defaulter instead from the latest resource snapshot. Ideally once set ResourceSnapshotIndex should not change in the middle of an updateRun.

Edit: after offline discussion it's better to store resourceSnapshotName as a field on the updateRun status instead we don't want to change spec since it's an user facing object

@britaniar britaniar force-pushed the updateStagedUpdateRunResourceIndex branch from e34c1db to 1c44de9 Compare November 7, 2025 18:21
@Arvindthiru
Copy link
Collaborator

Arvindthiru commented Nov 11, 2025

Can we add a test where we have multiple resource snapshots, index is not specified and ensure the latest resource snapshot is picked for an updateRun ?

@britaniar britaniar force-pushed the updateStagedUpdateRunResourceIndex branch from 7a60a5b to 8e4673e Compare November 12, 2025 02:15
Arvindthiru
Arvindthiru previously approved these changes Nov 12, 2025
…ex is unset

Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
@britaniar britaniar force-pushed the updateStagedUpdateRunResourceIndex branch from 2051ffa to 32bd918 Compare November 13, 2025 19:47
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
Copy link
Contributor

@ryanzhang-oss ryanzhang-oss left a comment

Choose a reason for hiding this comment

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

LGTM

britaniar and others added 2 commits November 18, 2025 11:51
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
@britaniar britaniar merged commit 2fddc1c into kubefleet-dev:main Nov 18, 2025
15 checks passed
@britaniar britaniar deleted the updateStagedUpdateRunResourceIndex branch November 18, 2025 23:12
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.

6 participants