fix: use correct hash value from label anno manager#32
Conversation
修复 IsTargetPvcTmpChanged 方法中 PVC hash 值获取逻辑: - 使用 setLabelAnnoMgr.Get() 返回的值而非直接读取 pvc.Labels - 移除未使用的 appsv1alpha1 import
There was a problem hiding this comment.
Pull request overview
This PR fixes PVC template-hash retrieval in IsTargetPvcTmpChanged by consistently using the XSetLabelAnnotationManager abstraction (instead of reading raw pvc.Labels), and cleans up an unused import.
Changes:
- Read PVC template-hash via
pc.xsetLabelAnnoMgr.Get(..., api.SubResourcePvcTemplateHashLabelKey)and store that value for comparisons. - Remove unused
appsv1alpha1import fromsubresources/pvc_control.go.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| targetId, _ := pc.xsetLabelAnnoMgr.Get(x, api.XInstanceIdLabelKey) | ||
| if pvcId != targetId { | ||
| continue | ||
| } | ||
| if _, exist := pc.xsetLabelAnnoMgr.Get(pvc, api.SubResourcePvcTemplateHashLabelKey); !exist { | ||
| if v, exist := pc.xsetLabelAnnoMgr.Get(pvc, api.SubResourcePvcTemplateHashLabelKey); !exist { |
There was a problem hiding this comment.
IsTargetPvcTmpChanged ignores the exist boolean when reading XInstanceIdLabelKey for both the PVC and the target. If either label is missing, both IDs default to "" and the code can incorrectly treat unrelated PVCs as belonging to the target, leading to wrong hash comparisons. Consider fetching targetId once (with an exist check; if missing, return early) and only comparing PVCs whose instance-id label exists and matches.
修复 IsTargetPvcTmpChanged 方法中 PVC hash 值获取逻辑:
1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):
2. What is the scope of this PR (e.g. component or file name):
3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):
4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):
5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:
6. Release note
Please refer to Release Notes Language Style Guide to write a quality release note.