ark backup create --selector somekey!=somevalue is not working for ark but it works for kubectl. I am able to do kubectl get pods -l somekey!=somevalue
I am getting the following error:
ark backup create --selector somekey!=somevalue
...
An error occurred: invalid argument "somekey!=somevalue" for "-l, --selector" flag: "!=" is not a valid label selector operator
@bymafmaf looks like the apimachinery lib has two different functions for parsing label selectors, one of which supports != and one of which doesn't, and we're using the one that doesn't. I'm not exactly sure why there are two, and the comment implies they should be kept in sync, so I'll raise an issue or PR upstream to get that fixed.
In the meantime - I think you should be able to use notin to accomplish want you want, for example:
--selector 'somekey notin (somevalue)'
FYI, found this comment: https://github.com/kubernetes/apimachinery/blob/master/pkg/apis/meta/v1/types.go#L1053-L1057
Which indicates that the old style of label selectors was just a string, which supported != -- this is what e.g. kubectl get uses. The new style is "structured" and does not support != -- instead it supports the notin operator. The newer style is what's used in e.g. ReplicaSets' selection of pods (see https://github.com/kubernetes/api/blob/master/apps/v1/types.go#L723), and is what we use in our Backup/Restore specs.
As such, we're not going to switch to using the old style. Using notin is the correct & standard upstream approach here. Closing this issue out.
Most helpful comment
@bymafmaf looks like the apimachinery lib has two different functions for parsing label selectors, one of which supports
!=and one of which doesn't, and we're using the one that doesn't. I'm not exactly sure why there are two, and the comment implies they should be kept in sync, so I'll raise an issue or PR upstream to get that fixed.In the meantime - I think you should be able to use
notinto accomplish want you want, for example:--selector 'somekey notin (somevalue)'