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

feat: support resource actions on CRDs that use status subresources #4690

Merged
merged 1 commit into from
Nov 2, 2020

Conversation

jessesuen
Copy link
Member

Resolves #4670

This PR adds support for performing resource actions on CRDs which use the status subresource.

When an action is performed on a resource, and that action modifies status, Argo CD will first split the patch into a non-status patch and a status-only patch. It then tries to apply the status only patch. This will either succeed (if status subresource is enabled), or fail with 404 if status subresource is disabled.

If the status patch was successful, Argo CD will then proceed to applying the non-status patch. Otherwise, if the status patch 404'ed, this indicates status subresources are not enabled for the CRD, and Argo CD will fall back to applying the original full resource action patch.

With this change, Argo CD transparently supports resources that use status subresource, even if this definition changes from one call to another.

@jessesuen jessesuen requested a review from alexmt October 28, 2020 10:14
@@ -2317,7 +2317,7 @@ func filterResources(command *cobra.Command, resources []*argoappv1.ResourceDiff
if resourceName != "" && resourceName != obj.GetName() {
continue
}
if kind != gvk.Kind {
if kind != "" && kind != gvk.Kind {
Copy link
Member Author

Choose a reason for hiding this comment

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

This change makes the following possible:

$ dist/argocd --plaintext --server localhost:8080 app actions list test-crd-status-subresource-action
GROUP        KIND                  NAME                    ACTION         DISABLED
argoproj.io  StatusSubResource     status-subresource      update-both    false
argoproj.io  StatusSubResource     status-subresource      update-spec    false
argoproj.io  StatusSubResource     status-subresource      update-status  false
argoproj.io  NonStatusSubResource  non-status-subresource  update-status  false
argoproj.io  NonStatusSubResource  non-status-subresource  update-both    false
argoproj.io  NonStatusSubResource  non-status-subresource  update-spec    false

@codecov-io
Copy link

Codecov Report

Merging #4690 into master will decrease coverage by 0.26%.
The diff coverage is 36.11%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4690      +/-   ##
==========================================
- Coverage   41.37%   41.11%   -0.27%     
==========================================
  Files         126      127       +1     
  Lines       17154    17397     +243     
==========================================
+ Hits         7097     7152      +55     
- Misses       9042     9216     +174     
- Partials     1015     1029      +14     
Impacted Files Coverage Δ
cmd/argocd/commands/app.go 6.08% <0.00%> (ø)
cmd/argocd/commands/app_actions.go 0.00% <ø> (ø)
server/application/application.go 29.53% <37.14%> (+0.43%) ⬆️
util/helm/cmd.go 25.69% <0.00%> (-13.44%) ⬇️
util/helm/client.go 45.03% <0.00%> (-11.01%) ⬇️
util/argo/argo.go 59.32% <0.00%> (-5.37%) ⬇️
pkg/apis/application/v1alpha1/types.go 57.92% <0.00%> (-0.37%) ⬇️
cmd/argocd-util/commands/projects.go 34.48% <0.00%> (-0.30%) ⬇️
util/settings/settings.go 40.65% <0.00%> (ø)
cmd/argocd/commands/repo.go 0.00% <0.00%> (ø)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3bf9deb...3433315. Read the comment docs.

Copy link
Collaborator

@alexmt alexmt left a comment

Choose a reason for hiding this comment

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

LGTM

@jessesuen jessesuen merged commit b9954e5 into argoproj:master Nov 2, 2020
@jessesuen jessesuen deleted the status-subresource branch November 2, 2020 10:09
terrycorley pushed a commit to terrycorley/argo-cd that referenced this pull request Nov 3, 2020
…zation-generators

* 'master' of github.com:argoproj/argo-cd:
  fix: RevisionFormField component crashes in 'refs' API returns no tags (argoproj#4735)
  docs: add Opensurvey to USERS.md (argoproj#4727)
  docs: correct parameters usage in CLI (argoproj#4725)
  fix: Repo-server has silent unmarshalling errors leading to empty applications (argoproj#4423) (argoproj#4708)
  fix: inject artificial delay between sync waves to better support health assessments (argoproj#4715)
  fix: exclude files listed under exclusions (argoproj#4686)
  feat: support resource actions on CRDs that use status subresources (argoproj#4690)
  feat: Add autocomplete for repo Revisions (argoproj#4645) (argoproj#4713)
  fix: webhook don't refresh apps pointing to HEAD (argoproj#4717)
  feat: Add support for ExecProvider cluster auth (argoproj#4600) (argoproj#4710)
  fix: adding helm values file in New App (argoproj#4635)
  docs: Instructions on `make verify-kube-connect` step when using k3d (argoproj#4687)
  feat:  Annotation based app paths detection in webhooks (argoproj#4699)
  fix: adding commonAnnotations for Kustomize (argoproj#4613)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support actions for CRDs that use status subresource
3 participants