Skip to content

Conversation

@nitishfy
Copy link
Member

Fixes #17694
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 Title of the PR
  • 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).

@bunnyshell
Copy link

bunnyshell bot commented Aug 19, 2025

❌ Preview Environment deleted from Bunnyshell

Available commands (reply to this comment):

  • 🚀 /bns:deploy to deploy the environment

@nitishfy
Copy link
Member Author

nitishfy commented Aug 19, 2025

The problem that I'm stuck at right now is how to get the OpenAPISchema for CRDs in order to use that in my tests. Can anyone provide some hints here?

=== FAIL: controller TestNormalizeTargetResourcesWithList (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered, repanicked]
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x4c08f17]

goroutine 9151 [running]:
testing.tRunner.func1.2({0x511f460, 0x8679a50})
	/opt/hostedtoolcache/go/1.25.0/x64/src/testing/testing.go:1872 +0x237
testing.tRunner.func1()
	/opt/hostedtoolcache/go/1.25.0/x64/src/testing/testing.go:1875 +0x35b
panic({0x511f460?, 0x8679a50?})
	/opt/hostedtoolcache/go/1.25.0/x64/src/runtime/panic.go:783 +0x132
github.com/argoproj/argo-cd/v3/controller.normalizeTargetResources({0x0, 0x0}, 0xc0040ded20)
	/home/runner/work/argo-cd/argo-cd/controller/sync.go:479 +0x3f7
github.com/argoproj/argo-cd/v3/controller.TestNormalizeTargetResourcesWithList.func2(0xc002645dc0)
	/home/runner/work/argo-cd/argo-cd/controller/sync_test.go:605 +0x15e
testing.tRunner(0xc002645dc0, 0xc000eca5b0)
	/opt/hostedtoolcache/go/1.25.0/x64/src/testing/testing.go:1934 +0xea
created by testing.(*T).Run in goroutine 9150
	/opt/hostedtoolcache/go/1.25.0/x64/src/testing/testing.go:1997 +0x465

@alexmt
Copy link
Collaborator

alexmt commented Aug 19, 2025

Here is how open api schema is loaded from real cluster:

https://github.com/argoproj/gitops-engine/blob/15973bc6b42d0b0f376c8cb2b7ee9de7715b1d7a/pkg/utils/kube/ctl.go#L133

	oapiGetter := openapi.NewOpenAPIGetter(disco)
	oapiResources, err := openapi.NewOpenAPIParser(oapiGetter).Parse()

I suggest to create fake implementation of disco. It implements discovery.OpenAPISchemaInterface which is only one method that returns schema document:

type OpenAPISchemaInterface interface {
	// OpenAPISchema retrieves and parses the swagger API schema the server supports.
	OpenAPISchema() (*openapi_v2.Document, error)
}

@codecov
Copy link

codecov bot commented Aug 20, 2025

Codecov Report

❌ Patch coverage is 60.00000% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.34%. Comparing base (f401a0e) to head (fd9e2e8).
⚠️ Report is 45 commits behind head on master.

Files with missing lines Patch % Lines
controller/sync.go 60.00% 11 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #24197      +/-   ##
==========================================
+ Coverage   60.32%   60.34%   +0.01%     
==========================================
  Files         350      350              
  Lines       60047    60072      +25     
==========================================
+ Hits        36224    36250      +26     
+ Misses      20912    20905       -7     
- Partials     2911     2917       +6     

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

@nitishfy nitishfy marked this pull request as ready for review August 20, 2025 11:56
@nitishfy nitishfy requested a review from a team as a code owner August 20, 2025 11:56
@nitishfy nitishfy requested a review from alexmt August 20, 2025 11:59
@nitishfy nitishfy force-pushed the nitish/ignore-differences branch from c749e22 to af54a98 Compare August 21, 2025 08:36
@blakepettersson
Copy link
Member

@nitishfy looks reasonable to me, apart from the linting issues

}
if lookupPatchMeta != nil {
return strategicpatch.CreateThreeWayMergePatch(modifiedJSON, modifiedJSON, originalJSON, lookupPatchMeta, true)
return strategicpatch.CreateThreeWayMergePatch(originalJSON, modifiedJSON, originalJSON, lookupPatchMeta, true)
Copy link
Member

Choose a reason for hiding this comment

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

Why does this change from modifiedJSON to originalJSON?

Copy link
Member

Choose a reason for hiding this comment

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

I ran the unit tests and they were unaffected when switching it back to the previous impl - so my question remains, why do we need to modify the merge patch?

Can you add a test which needs this (alternatively create a test that fails if this were to be modified)?

Copy link
Member Author

Choose a reason for hiding this comment

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

I can't remember why i modified this field. I looked at it again today and i think it makes sense to keep the field as it was initially.

}
if lookupPatchMeta != nil {
return strategicpatch.CreateThreeWayMergePatch(modifiedJSON, modifiedJSON, originalJSON, lookupPatchMeta, true)
return strategicpatch.CreateThreeWayMergePatch(originalJSON, modifiedJSON, originalJSON, lookupPatchMeta, true)
Copy link
Member

Choose a reason for hiding this comment

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

I ran the unit tests and they were unaffected when switching it back to the previous impl - so my question remains, why do we need to modify the merge patch?

Can you add a test which needs this (alternatively create a test that fails if this were to be modified)?

Signed-off-by: nitishfy <[email protected]>
Signed-off-by: nitishfy <[email protected]>
Signed-off-by: nitishfy <[email protected]>
Signed-off-by: nitishfy <[email protected]>
Signed-off-by: nitishfy <[email protected]>
Signed-off-by: nitishfy <[email protected]>
Signed-off-by: nitishfy <[email protected]>
Signed-off-by: nitishfy <[email protected]>
Signed-off-by: nitishfy <[email protected]>

remove skip statement

Signed-off-by: nitishfy <[email protected]>
Signed-off-by: nitishfy <[email protected]>
@nitishfy nitishfy force-pushed the nitish/ignore-differences branch from 6578fe4 to fd9e2e8 Compare September 11, 2025 06:55
@crenshaw-dev crenshaw-dev merged commit 22d3ef0 into argoproj:master Sep 15, 2025
41 of 43 checks passed
@nitishfy nitishfy deleted the nitish/ignore-differences branch September 15, 2025 14:28
@nitishfy nitishfy added for-release-blog-3-2 PR that should be highlighted in the Release Blog release-blog-3.2rc PRs to be included in Argo CD v3.2 RC labels Sep 15, 2025
blakepettersson added a commit to blakepettersson/argo-cd that referenced this pull request Nov 14, 2025
@blakepettersson blakepettersson mentioned this pull request Nov 14, 2025
14 tasks
alexmt pushed a commit that referenced this pull request Nov 17, 2025
Signed-off-by: Blake Pettersson <[email protected]>
argo-cd-cherry-pick-bot bot pushed a commit that referenced this pull request Nov 17, 2025
Signed-off-by: Blake Pettersson <[email protected]>
blakepettersson added a commit that referenced this pull request Nov 18, 2025
Signed-off-by: Blake Pettersson <[email protected]>
Co-authored-by: Blake Pettersson <[email protected]>
revitalbarletz pushed a commit to revitalbarletz/argo-cd that referenced this pull request Nov 19, 2025
Signed-off-by: Blake Pettersson <[email protected]>
Signed-off-by: Revital Barletz <[email protected]>
FourFifthsCode pushed a commit to FourFifthsCode/argo-cd that referenced this pull request Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

for-release-blog-3-2 PR that should be highlighted in the Release Blog release-blog-3.2rc PRs to be included in Argo CD v3.2 RC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ignoreDifferences and RespectIgnoreDifferences=true does allow ignoring differences in selected array elements

4 participants