Skip to content

fix: use correct hash value from label anno manager#32

Merged
ColdsteelRail merged 1 commit intomainfrom
fix/pvc-hash-value
Mar 24, 2026
Merged

fix: use correct hash value from label anno manager#32
ColdsteelRail merged 1 commit intomainfrom
fix/pvc-hash-value

Conversation

@AnnaYue
Copy link
Copy Markdown
Contributor

@AnnaYue AnnaYue commented Mar 24, 2026

修复 IsTargetPvcTmpChanged 方法中 PVC hash 值获取逻辑:

  • 使用 setLabelAnnoMgr.Get() 返回的值而非直接读取 pvc.Labels
  • 移除未使用的 appsv1alpha1 import

1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

  • N
  • Y

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):

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Other

4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

  • N
  • Y

5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

  • Unit test
  • Integration test
  • Benchmark (add benchmark stats below)
  • Manual test (add detailed scripts or steps below)
  • Other

6. Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

修复 IsTargetPvcTmpChanged 方法中 PVC hash 值获取逻辑:
- 使用 setLabelAnnoMgr.Get() 返回的值而非直接读取 pvc.Labels
- 移除未使用的 appsv1alpha1 import
Copy link
Copy Markdown

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 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 appsv1alpha1 import from subresources/pvc_control.go.

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

Comment on lines 342 to +346
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 {
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

@ColdsteelRail ColdsteelRail left a comment

Choose a reason for hiding this comment

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

lgtm

@ColdsteelRail ColdsteelRail merged commit fdcf8c8 into main Mar 24, 2026
8 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Mar 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants