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

Proposal: Allow negative/inverse selection for label and resource selectors #10548

Closed
jgn-epp opened this issue Sep 8, 2022 · 9 comments · Fixed by #10893
Closed

Proposal: Allow negative/inverse selection for label and resource selectors #10548

jgn-epp opened this issue Sep 8, 2022 · 9 comments · Fixed by #10893
Labels
component:cli Affects the Argo CD CLI good first issue Good for newcomers hacktoberfest

Comments

@jgn-epp
Copy link

jgn-epp commented Sep 8, 2022

Summary

When using the argocd app wait and argo app sync commands, it is possible to use the -l / --selector parameter filter based on labels and their values. It is also possible to use the --resource filter to only target certain types of resources. Unfortunately it is (as far as I can tell) not possible to do negative/inverse selection on these - for example so that you could filter out resources with a certain label or of a certain type.

Motivation

As part of our deployment pipeline, we have a step where we use argocd app wait <appname> --health --sync, but the process sometimes gets stuck because of objects in the deployment that continually mark their health as Progressing and are not always necessary to wait for. I would like to be able to easily filter these objects out of the argocd app wait call, but as only positive selection is possible, I would have to either:

  • Tag everything that I want to wait for and use the -l parameter to select those resources. I would like to avoid this since that means adding a label to every single resource besides that particular one that I am trying to avoid.
  • Use the --resource parameter for every possible resource that is NOT the type of resource that I want to filter out. I would like to avoid this since that means I would have to include every type of resource in use now and it would need to be updated if custom resources are introduced to make sure they are included.

Proposal

I would like the -l / --selector to allow negative/inverse selection, example:

  • argocd app wait <appname> -l label_example!=hello

Additionally/alternatively it would also be nice if the --resource parameter allowed some kind of negative/inverse selection, example:

  • argocd app wait <appname> --resource :!ResourceToFilterOut:
@crenshaw-dev
Copy link
Collaborator

Looks like kubectl supports this. It would be nice to have feature-parity with kubectl. https://stackoverflow.com/a/58936877/684776

@crenshaw-dev crenshaw-dev added good first issue Good for newcomers component:cli Affects the Argo CD CLI GraceHopperOSD2022 Good for 2022 Grace Hopper Celebration Open Source Day labels Sep 14, 2022
@maheshbaliga
Copy link
Contributor

maheshbaliga commented Sep 19, 2022

Hi @crenshaw-dev. I would like to attempt this one. Could you please assign this to me? I'm working on -l / --selector part of this issue and the fix is ready, will submit a PR very soon.

@maheshbaliga
Copy link
Contributor

Hi @crenshaw-dev, can you please review PR #10729 and let me know if any changes are required.

@maheshbaliga
Copy link
Contributor

Hi @crenshaw-dev. Are we looking at implementing the --resource filtering as well? If yes, which wildcard characters should be supported apart from ! negation?

Currently, looks like the resources are selected only if it matches all the criteria - Group, Kind & Name (Namespace, if specified). Filtering based on apps:Deployment:guestbook-ui works, but :Deployment: or :Deployment:guestbook-ui doesn't. Should a blank value be supported in Kind & Name as well?

@crenshaw-dev
Copy link
Collaborator

crenshaw-dev commented Oct 3, 2022

@maheshbaliga I think that could make an excellent follow-up PR! I think just supporting a negate-able glob pattern would be fine (similar to what's available for destinations in the AppProject CRD). Maybe a negate-able glob pattern with : as the separator. So @jgn-epp's pattern would be !*:ResourceToFilterOut:*.

crenshaw-dev pushed a commit that referenced this issue Oct 3, 2022
… for list, sync, delete and wait App commands (#10548)

Signed-off-by: maheshbaliga <mahesh.baliga@infracloud.io>

Signed-off-by: maheshbaliga <mahesh.baliga@infracloud.io>
@crenshaw-dev crenshaw-dev added hacktoberfest and removed GraceHopperOSD2022 Good for 2022 Grace Hopper Celebration Open Source Day labels Oct 4, 2022
@maheshbaliga
Copy link
Contributor

Hi @crenshaw-dev. Since --resource can be specified repeatedly, they currently act as OR conditions. The resource has to satisfy one of the filters.

Is the same behaviour expected with the inclusion of ! too? If yes, argocd app wait guestbook --resource '!*:Deployment:*' --resource '!*:Service:*', will wait for both Deployment & Service. Is this behaviour OK?

@crenshaw-dev
Copy link
Collaborator

That seems like the most intuitive behavior to me. :-)

ashutosh16 pushed a commit to ashutosh16/argo-cd that referenced this issue Oct 7, 2022
… for list, sync, delete and wait App commands (argoproj#10548)

Signed-off-by: maheshbaliga <mahesh.baliga@infracloud.io>

Signed-off-by: maheshbaliga <mahesh.baliga@infracloud.io>
@maheshbaliga
Copy link
Contributor

Hi. I've almost completed --resource part of this issue, will submit a PR very soon.

@maheshbaliga
Copy link
Contributor

Hi @crenshaw-dev, can you please review PR #10893 and let me know if any changes are required.

crenshaw-dev pushed a commit that referenced this issue Jan 5, 2023
… wait app commands (#10548)

Signed-off-by: maheshbaliga <mahesh.baliga@infracloud.io>

Signed-off-by: maheshbaliga <mahesh.baliga@infracloud.io>
emirot pushed a commit to emirot/argo-cd that referenced this issue Jan 27, 2023
… wait app commands (argoproj#10548)

Signed-off-by: maheshbaliga <mahesh.baliga@infracloud.io>

Signed-off-by: maheshbaliga <mahesh.baliga@infracloud.io>
Signed-off-by: emirot <emirot.nolan@gmail.com>
schakrad pushed a commit to schakrad/argo-cd that referenced this issue Mar 14, 2023
… wait app commands (argoproj#10548)

Signed-off-by: maheshbaliga <mahesh.baliga@infracloud.io>

Signed-off-by: maheshbaliga <mahesh.baliga@infracloud.io>
Signed-off-by: schakrad <chakradari.sindhu@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:cli Affects the Argo CD CLI good first issue Good for newcomers hacktoberfest
Projects
None yet
3 participants