Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix(app): use jsonpatch to check for changes in status field (#15126) #15227

Closed
wants to merge 337 commits into from

Conversation

vladfr
Copy link
Contributor

@vladfr vladfr commented Aug 24, 2023

This PR changes the way patches are computed for annotations and status. Because Helm source can have unstructured fields in helm.valuesObject, the strategic patching gives unpredictable behaviour. It was never meant to be used without a struct (see Helm Issue). So we use jsonpatch instead. This should yield the same results, and the library is already present in Argo as a dependency.

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? No
  • I've updated documentation as required by this PR. N/A
  • Optional. My organization is added to USERS.md.
  • 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.

Fixes #15126

@vladfr vladfr force-pushed the 15126-jsonpatch branch 2 times, most recently from 50f7680 to 3f533d8 Compare August 25, 2023 06:23
@vladfr
Copy link
Contributor Author

vladfr commented Aug 25, 2023

I couldn't really find a good spot for the utility function. It should be moved in gitops-engine at some point.

Copy link
Member

@jannfis jannfis left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for fixing this!

I agree that it should move into gitops-engine later on. We probably need to revive lifecycle management between gitops-engine and Argo CD before, or migrate gitops-engine back into Argo CD though.

For now, I'm fine with this code living in the application controller.

Just for clarification and my understanding, this only affects valuesObject introduced in 2.8, right?

@crenshaw-dev
Copy link
Member

@jannfis this fixes a problem with the new field, but it changes how we calculate the app status for every field, so it's pretty darn central.

@jannfis
Copy link
Member

jannfis commented Aug 25, 2023

@crenshaw-dev Yes, I was rather referring to the bug it fixes. So the bug is only in 2.8, and we need to cherry-pick only into that?

@crenshaw-dev
Copy link
Member

@jannfis yep!

@jannfis
Copy link
Member

jannfis commented Aug 25, 2023

And I would assume that since every test, including end-to-end, pass without changes that the change itself is fine. The only concern might be a performance impact of CreateTwoWayMergePatch (which is part of the Kubernetes distribution) and the JSON merge patch we pull in from github.com/evanphx/json-patch (and we seem to pull a pretty outdated version).

@vladfr
Copy link
Contributor Author

vladfr commented Aug 27, 2023

@jannfis the helm.valuesObject field was added in 2.8.0, so I can confirm that the bugfix is meant only for 2.8.x

You have valid points about adding changes to a critical point. I figured it's safe since jsonpatch is so widely used, and it's already a dep, and tests pass :) We could definitely do a series of benches to see how performance looks.

I can dig a bit to see if there's another way to handle this fix. It seems the problem lies in how the object is being stored in status, so we can look at the way it's stored; or perhaps transform valuesObject before the patching is done (load it up and marshal again).

PS: I'm out next week, but I can take another approach after I'm back, or if someone else has input until then, feel free.

@jannfis
Copy link
Member

jannfis commented Aug 29, 2023

@vladfr I think a good first step would be to use a recent version of jsonpatch, e.g. github.com/evanphx/json-patch/v5

@Zeratoxx
Copy link

Zeratoxx commented Dec 6, 2023

Hi, is this PR still watched? :)

@vladfr vladfr requested a review from a team as a code owner December 13, 2023 11:32
@vladfr
Copy link
Contributor Author

vladfr commented Dec 13, 2023

Hi, sorry for my big delay here.

I've looked for a different way to address this. Unfortunately, it's not really clear how I can change the logic to store the valuesObject field separately; besides which, I'm not really sure what's causing the issue with the quotes.

So I've modified the patching code to:

  • ignore valuesObject when computing the strategic merge patch
  • compute diff on valuesObject using jsonpatch
  • apply two patches if needed

PS: I'd like to add an e2e test for this, but I'm still struggling a bit with running these locally.

crenshaw-dev and others added 15 commits December 13, 2023 13:49
…oproj#15583)

Bumps library/node from 20.6.1 to 20.7.0.

---
updated-dependencies:
- dependency-name: library/node
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…er (argoproj#15585)

Bumps library/node from 20.6.1 to 20.7.0.

---
updated-dependencies:
- dependency-name: library/node
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: pasha-codefresh <[email protected]>
…oproj#15595)

* feat: added patch_ms to reconciliation logs

Signed-off-by: Soumya Ghosh Dastidar <[email protected]>

* feat: added patch_ms and setop_ms timings to logs

Signed-off-by: Soumya Ghosh Dastidar <[email protected]>

---------

Signed-off-by: Soumya Ghosh Dastidar <[email protected]>
* chore(action): add newlines at eof

Signed-off-by: Josh Soref <[email protected]>

* chore(action): fix whitespace indentation

Signed-off-by: Josh Soref <[email protected]>

* chore(action): use local annotations

Signed-off-by: Josh Soref <[email protected]>

---------

Signed-off-by: Josh Soref <[email protected]>
…rting API-Server (argoproj#15574)

* feat: auto configure extensions

Signed-off-by: Leonardo Luz Almeida <[email protected]>

* feat: auto-reload extension configs without restarting api-server

Signed-off-by: Leonardo Luz Almeida <[email protected]>

* clean unused gorilla mux

Signed-off-by: Leonardo Luz Almeida <[email protected]>

* update docs

Signed-off-by: Leonardo Luz Almeida <[email protected]>

* Address review comments

Signed-off-by: Leonardo Luz Almeida <[email protected]>

* Add more test cases

Signed-off-by: Leonardo Luz Almeida <[email protected]>

* refactoring to reduce unnecessary function

Signed-off-by: Leonardo Luz Almeida <[email protected]>

* Add log

Signed-off-by: Leonardo Luz Almeida <[email protected]>

* fix bugs found during manual tests

Signed-off-by: Leonardo Luz Almeida <[email protected]>

---------

Signed-off-by: Leonardo Luz Almeida <[email protected]>
…oc (argoproj#15619)

The supported version policy mentioned in the operator manual installation document diverges from the official policy that is mentioned in the security policy and the release cadence.

This change brings the version policy in line by referring the readers to the release and cadence documentation to check the specified policy.

Signed-off-by: Muhammad Mooneeb Hussain <[email protected]>
…rollback for tree view (argoproj#15572)

* app sync and app wait tree view changes

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

* documentation changes

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

* included the json,yaml and wide formats and removed the value assignment to the flag

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

* Reoved extra spaces

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

* removed extra spaces

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

* refactored the code

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

* better log statements

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

---------

Signed-off-by: schakrad <[email protected]>
* Migrate Application Controller from Statefulset to Deployment

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

* Add sharding deployment logic

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

* Update sharding logic and add comments

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

* Add heartbeat as an environment variable

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

* Add retry logic, heartbeat timeout environment variable

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

* use the logic of pre-specified shard number on application controller pod

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

* fix manifests

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

* fix lint and e2e tests

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

* comment out failing e2e test

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

* increase readiness probe interval period

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

* "comment out readiness probe to see if e2e tests succeed"

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

* revert commented readiness probe

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

* revert commented test case

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

* read environment variable for application controller deployment name

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

* Add nil check on replica count for deployment of application controller

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

* Address comments

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

* Add Informer, Update documentation, add unit tests

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

* update godoc

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

* remove unwanted code and logs

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

* Add more documentation

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

* revert ApplicationController manifest to StatefulSet

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

* reverting updated docs

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

* Add documentation for the new dynamic distribution feature

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

* update documentation

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

* Add an overlay for application controller deployment and update documentation

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

* fix nit

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

* Marking the feature as alpha

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

* Add feature status link

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

* revert go,mod changes

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

* update docs to avoid focusing on StatefulSet/Deployment (argoproj#26)

* update docs to avoid focusing on StatefulSet/Deployment

Signed-off-by: Michael Crenshaw <[email protected]>

---------

Signed-off-by: Michael Crenshaw <[email protected]>

* minor update to the doc

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

---------

Signed-off-by: ishitasequeira <[email protected]>
Signed-off-by: Michael Crenshaw <[email protected]>
Co-authored-by: Michael Crenshaw <[email protected]>
* chore(deps): bump node version

Signed-off-by: Michael Crenshaw <[email protected]>

* fix version

Signed-off-by: Michael Crenshaw <[email protected]>

* update lockfile

Signed-off-by: Michael Crenshaw <[email protected]>

---------

Signed-off-by: Michael Crenshaw <[email protected]>
mayzhang2000 and others added 22 commits December 13, 2023 13:52
* self service notification

Signed-off-by: May Zhang <[email protected]>

* revert back the changes for redis-ha

Signed-off-by: May Zhang <[email protected]>

* revert back the changes for redis-ha

Signed-off-by: May Zhang <[email protected]>

* update notification engine

Signed-off-by: May Zhang <[email protected]>

* re-trigger build

Signed-off-by: May Zhang <[email protected]>

* self service notification

Signed-off-by: May Zhang <[email protected]>

* revert back the changes for redis-ha

Signed-off-by: May Zhang <[email protected]>

* revert back the changes for redis-ha

Signed-off-by: May Zhang <[email protected]>

* update notification engine

Signed-off-by: May Zhang <[email protected]>

* re-trigger build

Signed-off-by: May Zhang <[email protected]>

* fix conflict

Signed-off-by: May Zhang <[email protected]>

* fix conflict

Signed-off-by: May Zhang <[email protected]>

* fix conflict

Signed-off-by: May Zhang <[email protected]>

* fix conflict

Signed-off-by: May Zhang <[email protected]>

* update notification enginer version

Signed-off-by: May Zhang <[email protected]>

* update notification enginer version

Signed-off-by: May Zhang <[email protected]>

* fixing go tidy

Signed-off-by: May Zhang <[email protected]>

* fixing go tidy

Signed-off-by: May Zhang <[email protected]>

* fixing go tidy

Signed-off-by: May Zhang <[email protected]>

* fixing go tidy

Signed-off-by: May Zhang <[email protected]>

* fixing go tidy

Signed-off-by: May Zhang <[email protected]>

* add back checkAppNotInAdditionalNamespaces

Signed-off-by: May Zhang <[email protected]>

* add cm and secret to clusterRole

Signed-off-by: May Zhang <[email protected]>

* if applicationNamespaces is not used, then use namespaced appClient

Signed-off-by: May Zhang <[email protected]>

* fix merge conflict

Signed-off-by: May Zhang <[email protected]>

* fix doc and test based on review

Signed-off-by: May Zhang <[email protected]>

* self service notification

Signed-off-by: May Zhang <[email protected]>

* revert back the changes for redis-ha

Signed-off-by: May Zhang <[email protected]>

* revert back the changes for redis-ha

Signed-off-by: May Zhang <[email protected]>

* update notification engine

Signed-off-by: May Zhang <[email protected]>

* re-trigger build

Signed-off-by: May Zhang <[email protected]>

* fix conflict

Signed-off-by: May Zhang <[email protected]>

* self service notification

Signed-off-by: May Zhang <[email protected]>

* revert back the changes for redis-ha

Signed-off-by: May Zhang <[email protected]>

* revert back the changes for redis-ha

Signed-off-by: May Zhang <[email protected]>

* update notification engine

Signed-off-by: May Zhang <[email protected]>

* re-trigger build

Signed-off-by: May Zhang <[email protected]>

* fix conflict

Signed-off-by: May Zhang <[email protected]>

* fix conflict

Signed-off-by: May Zhang <[email protected]>

* fix conflict

Signed-off-by: May Zhang <[email protected]>

* update notification enginer version

Signed-off-by: May Zhang <[email protected]>

* update notification enginer version

Signed-off-by: May Zhang <[email protected]>

* fixing go tidy

Signed-off-by: May Zhang <[email protected]>

* fixing go tidy

Signed-off-by: May Zhang <[email protected]>

* fixing go tidy

Signed-off-by: May Zhang <[email protected]>

* fixing go tidy

Signed-off-by: May Zhang <[email protected]>

* fixing go tidy

Signed-off-by: May Zhang <[email protected]>

* add back checkAppNotInAdditionalNamespaces

Signed-off-by: May Zhang <[email protected]>

* add cm and secret to clusterRole

Signed-off-by: May Zhang <[email protected]>

* if applicationNamespaces is not used, then use namespaced appClient

Signed-off-by: May Zhang <[email protected]>

* fix doc and test based on review

Signed-off-by: May Zhang <[email protected]>

* disable defining and using secrets within notification templates for self-service

Signed-off-by: May Zhang <[email protected]>

* tweaks

Signed-off-by: Michael Crenshaw <[email protected]>

* fix docs formatting

Signed-off-by: Michael Crenshaw <[email protected]>

* more docs and Procfile update for local run convenience

Signed-off-by: Michael Crenshaw <[email protected]>

---------

Signed-off-by: May Zhang <[email protected]>
Signed-off-by: Michael Crenshaw <[email protected]>
Co-authored-by: Michael Crenshaw <[email protected]>
* fix: Tooltips point in wrong direction#11935

Signed-off-by: Teng, Jessie <[email protected]>

* fix: Tooltips point in wrong direction#11935

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

---------

Signed-off-by: Teng, Jessie <[email protected]>
Signed-off-by: Teng <[email protected]>
Co-authored-by: Teng, Jessie <[email protected]>
* fix(11164): Advanced templating using patchTemplate

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

* small changes

Signed-off-by: Michael Crenshaw <[email protected]>

---------

Signed-off-by: gmuselli <[email protected]>
Signed-off-by: Michael Crenshaw <[email protected]>
Co-authored-by: Michael Crenshaw <[email protected]>
…sInAnyNamespaceEnabled flag is set (argoproj#16249)

Signed-off-by: Eilers, Jonas <[email protected]>
…rgoproj#16062) (argoproj#16241)

* fix(appset): store sha from webhook to get latest change during reconcile (argoproj#16062)

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

* fix(appset): Don't use revision cache when reconciling after webhook(argoproj#16062)

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

---------

Signed-off-by: dhruvang1 <[email protected]>
…ssue argoproj#16523) (argoproj#16520)

* Update cert-manager.opcertificate health.lua

Signed-off-by: Chris Murray <[email protected]>

* adding test case for cert issuing

Signed-off-by: Chris Murray <[email protected]>

* fixing typo

Signed-off-by: Chris Murray <[email protected]>

---------

Signed-off-by: Chris Murray <[email protected]>
Wrongly placed horizontal line (`----`) was formatting code-block as a header. Fixed it with a necessary line break

Signed-off-by: Elouan Keryell-Even <[email protected]>
… allow app's deletion (argoproj#12172) (argoproj#16506)

* fix(appset): remove unnecessary condition

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

* docs: update explanation about policy

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

---------

Signed-off-by: mikutas <[email protected]>
…oj#16581)

* chore: upgrade kubernetes dependencies from 0.26.4 to 0.26.11

Fixes some vulnerabilities trivy is reporting on (not necessarily
vulnerabe, trivy tends to have a lot of false positives when it comes to
golang projects):

* CVE-2023-3676
* CVE-2023-3955
* CVE-2023-5528
* CVE-2023-2431
* CVE-2023-2727
* CVE-2023-2728

Signed-off-by: Zoltán Reegn <[email protected]>

* go mod tidy

Signed-off-by: Zoltán Reegn <[email protected]>

* Add go mod tidy to kubernetes updater script

Signed-off-by: Zoltán Reegn <[email protected]>

---------

Signed-off-by: Zoltán Reegn <[email protected]>
when applying a patch, the rawextenstion object used for valuesObject
needs to be diffed with jsonpatch instead of the default strategic merge

Signed-off-by: Vlad Fratila <[email protected]>
@vladfr vladfr requested review from a team as code owners December 13, 2023 15:09
@vladfr
Copy link
Contributor Author

vladfr commented Dec 13, 2023

@crenshaw-dev The new code now uses jsonpatch only for valuesObject. I've managed to arrive at a workable solution, not very happy on how it looks. Pointers appreciated!

PS: Sorry about this, I've mistakenly ran a rebase. We can cut another PR once this is closer to being merged. (i.e. add tests)

@PaulSonOfLars
Copy link
Contributor

Thanks for the hard work @vladfr, I think that should work!

I added some tests on the my branch on #16602. Wasn't sure how you wanted to go forward regarding merging - feel free to cherry pick my changes here if you'd prefer the merge attribution in your name for finding the "fix" itself.

@vladfr
Copy link
Contributor Author

vladfr commented Mar 25, 2024

Closing in favor of #16602

@vladfr vladfr closed this Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment