Skip to content

Conversation

@ShirleyDing
Copy link
Contributor

@ShirleyDing ShirleyDing commented Nov 6, 2025

Ⅰ. Motivation

Ⅱ. Modifications

Ⅲ. Does this pull request fix one issue?

fixes #87

Ⅳ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.

Ⅴ. Describe how to verify it

  1. Deploy the corresponding YAML
apiVersion: workloads.x-k8s.io/v1alpha1
kind: RoleBasedGroup
metadata:
  name: restart-policy
spec:
  roles:
    - name: sts
      restartPolicy: RecreateRBGOnPodRestart
      replicas: 2
      template:
        metadata:
          labels:
            appVersion: v1
        spec:
          containers:
            - name: sts
              image: anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/nginx:1.14.1-8.6
              ports:
                - containerPort: 80
  1. Manually delete the created Pod
  2. Observe the conditions of RBGStatus
  3. Loop through steps 2 and 3, and observe 'RestartInProgress' status is

VI. Special notes for reviews

Set logLevel=1 and look at "patch content" in pkg/utils/utils.go:30 PatchObjectApplyConfiguration:
After all pod restarted, the condition of RestartInProgress was set to RBGRestartCompleted
image

Then in reconcile cycle of RoleBasedGroup, when updateRoleStatus, it used an outdated condition 'RBGRestart', not 'RBGRestartCompleted'. So the condition of RestartInProgress stayed in 'RBGRestart' forever. When pod restart next time, the restart-policy will not work anymore.
image

Checklist

  • Format your code make fmt.
  • Add unit tests or integration tests.
  • Update the documentation related to the change.

… covering updates from other reconcile logic (sgl-project#87)

Signed-off-by: dingxy <[email protected]>
Co-authored-by: dingxy <[email protected]>
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Syspretor Syspretor self-requested a review November 7, 2025 05:33
@RongGu RongGu requested a review from Copilot November 7, 2025 05:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a refresh of the RoleBasedGroup object before updating its status to ensure the latest version is being modified, preventing potential stale data issues in status updates.

  • Adds a Get call to refresh the rbg object immediately before status modification
  • Ensures status updates are applied to the most current version of the object
  • Improves reliability of status updates in the RoleBasedGroup reconciliation loop

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

[Bug] Condition of RestartInProgress maybe covered sometimes

2 participants