rbg
rbg copied to clipboard
fix: prevent updates of RestartInProgress condition be covered by updating role status
Ⅰ. 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
- 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
- Manually delete the created Pod
- Observe the conditions of RBGStatus
- 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
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.
Checklist
- [x] Format your code
make fmt. - [x] Add unit tests or integration tests.
- [x] Update the documentation related to the change.
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:loudspeaker: Thoughts on this report? Let us know!