Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: resourceTree node duplication caused by having multiple OwnerReferences (#19910) #19911

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DomineCore
Copy link

@DomineCore DomineCore commented Sep 12, 2024

…erences for some resources.

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Toolchain Guide
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.
  • Optional. My organization is added to USERS.md.
  • Optional. For bug fixes, I've indicated what older releases this fix should be cherry-picked into (this may or may not happen depending on risk/complexity).

@DomineCore DomineCore requested a review from a team as a code owner September 12, 2024 12:32
Copy link

bunnyshell bot commented Sep 12, 2024

🔴 Preview Environment stopped on Bunnyshell

See: Environment Details | Pipeline Logs

Available commands (reply to this comment):

  • 🔵 /bns:start to start the environment
  • 🚀 /bns:deploy to redeploy the environment
  • /bns:delete to remove the environment

Copy link

bunnyshell bot commented Sep 12, 2024

✅ Preview Environment created on Bunnyshell but will not be auto-deployed

See: Environment Details

Available commands (reply to this comment):

  • 🚀 /bns:deploy to deploy the environment

…erences for some resources.

Signed-off-by: DomineCore <fengyafei0405@163.com>
Copy link

codecov bot commented Sep 12, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 55.84%. Comparing base (28f424f) to head (4cbc387).
Report is 46 commits behind head on master.

Files with missing lines Patch % Lines
controller/appcontroller.go 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #19911      +/-   ##
==========================================
+ Coverage   55.81%   55.84%   +0.02%     
==========================================
  Files         320      320              
  Lines       44378    44382       +4     
==========================================
+ Hits        24769    24783      +14     
+ Misses      17046    17029      -17     
- Partials     2563     2570       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@DomineCore
Copy link
Author

issue: #19910

@DomineCore DomineCore changed the title fix: resourceTree node duplication caused by having multiple Onwerref… fix: resourceTree node duplication caused by having multiple Onwerrefence: https://github.com/argoproj/argo-cd/issues/19910 Sep 12, 2024
@DomineCore DomineCore changed the title fix: resourceTree node duplication caused by having multiple Onwerrefence: https://github.com/argoproj/argo-cd/issues/19910 fix: resourceTree node duplication caused by having multiple Onwerrefence https://github.com/argoproj/argo-cd/issues/19910 Sep 12, 2024
@DomineCore DomineCore changed the title fix: resourceTree node duplication caused by having multiple Onwerrefence https://github.com/argoproj/argo-cd/issues/19910 fix: resourceTree node duplication caused by having multiple Onwerrefence [ISSUE #19910] Sep 12, 2024
@DomineCore
Copy link
Author

Who can help me review my code?

Comment on lines +570 to 571
nodesMap := make(map[kube.ResourceKey]appv1.ResourceNode)
err = ctrl.stateCache.IterateHierarchyV2(a.Spec.Destination.Server, managedResourcesKeys, func(child appv1.ResourceNode, appName string) bool {
Copy link
Member

@agaudreault agaudreault Sep 19, 2024

Choose a reason for hiding this comment

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

I think this problem is caused by the IterateHierarchyV2 implementation. It is unexpected to have the callback happen twice for the same node. The fix would need to be implemented in https://github.com/argoproj/gitops-engine. I think @andrii-korotkov-verkada can help you figure it out, but you should be able to write a unit tests in that repo and test it when a resource has 2 owner references.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for your analysis. I will take a look at the IterateHierarchyV2 implementation and see if I can address the issue in the https://github.com/argoproj/gitops-engine repository. I also appreciate your suggestion to involve @andrii-korotkov-verkada. I will reach out to him/her for assistance. Additionally, I will work on writing unit tests as you suggested and test when a resource has two owner references. Thank you again for your valuable input.

Copy link
Contributor

Choose a reason for hiding this comment

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

What's the use case for having multiple owner references? My understanding is that this breaks a tree-like structure of the resources and not sure what's the best way to support this. We can pick one of parents, though I thought that's what should be happening based on visited flagging. Do you see a whole sub-tree being added or only the top-most entry?

@agaudreault agaudreault changed the title fix: resourceTree node duplication caused by having multiple Onwerrefence [ISSUE #19910] fix: resourceTree node duplication caused by having multiple OwnerReferences (#19910) Sep 19, 2024
@agaudreault agaudreault marked this pull request as draft September 19, 2024 20:35
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants