rbg icon indicating copy to clipboard operation
rbg copied to clipboard

fix: prevent updates of RestartInProgress condition be covered by updating role status

Open ShirleyDing opened this issue 2 months ago • 1 comments

Ⅰ. 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

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

ShirleyDing avatar Nov 06 '25 12:11 ShirleyDing

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests.

:loudspeaker: Thoughts on this report? Let us know!

codecov-commenter avatar Nov 06 '25 12:11 codecov-commenter