trident icon indicating copy to clipboard operation
trident copied to clipboard

tridentControllerPluginNodeSelector/tridentNodePluginNodeSelector won't work with "true" value

Open kmizumar opened this issue 1 year ago • 1 comments

Describe the bug

Trying to use tridentControllerPluginNodeSelector and tridentNodePluginNodeSelector with helm chart setup providing the following values per yaml file would fail:

tridentControllerPluginNodeSelector:
  node-role.kubernetes.io/worker: "true"

tridentNodePluginNodeSelector:
  node-role.kubernetes.io/worker: "true"

This bug is exactly the same one which is reported in new nodeSelectors are not working when label value contains "true".

According to this update https://github.com/NetApp/trident/issues/700#issuecomment-1195891827, it's fixed in Trident 22.07 release, but some users reported it still exists in 23.04.0, 23.07.0, 23.10, and I hit this bug with 24.02 release.

I confirmed that Parajwal V brought in this problem again on 03/06/23 98c0d9ae, which Arnav Srivastava had solved on 06/01/22 a53cf69e.

Environment Provide accurate information about the environment to help us reproduce the issue.

  • Trident version: 24.02
  • Trident installation flags used: helm setup with above custom yaml
  • Container runtime: [e.g. Docker 19.03.1-CE]
  • Kubernetes version: 1.28.3
  • Kubernetes enabled feature gates: -
  • OS: Ubuntu 24.04LTS
  • NetApp backend types: ONTAP NAS
  • Other:
    • Kustomize version: 5.3.0

To Reproduce see above.

Expected behavior node selector handles the value "true" correctly.

kmizumar avatar Apr 05 '24 03:04 kmizumar

Hi @kmizumar , we are using the nodeAffinity and podAffinity with IN operator, which works on the set of strings. You're trying to use node-role.kubernetes.io/worker: "true" which treats it as string and fails.

Could you try to use as below and see if it works? node-role.kubernetes.io/worker: "'true'"

prajwal-venkatanarayan avatar Jul 04 '24 07:07 prajwal-venkatanarayan

Hi @prajwalv-netapp, I also got the same behavior while trying to use a label with value set to "true" in the Helm values. I tried as you mentioned by putting "'true'" in the value for the key used in tridentNodePluginNodeSelector in Helm. This translates to '''true''' in the TridentOrchestrator and the operator correctly patches the deamonSet.

Nevertheless, I don't understand what you mean that the IN operator is working on a set of strings being the problem? I got the following error in the operator when trying to use "true" : json: cannot unmarshal bool into Go struct field NodeSelectorRequirement.spec.template.spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms.matchExpressions.values of type string, requeuing"

This seems like it is the wrong type (as described in the bug mentioned by @kmizumar) and not due to the fact that it is not a list. In the end, I think the value "true" should be usable as is.

E-Zurg avatar Jul 12 '24 16:07 E-Zurg

Hi @prajwalv-netapp, I also got the same behavior while trying to use a label with value set to "true" in the Helm values. I tried as you mentioned by putting "'true'" in the value for the key used in tridentNodePluginNodeSelector in Helm. This translates to '''true''' in the TridentOrchestrator and the operator correctly patches the deamonSet.

Nevertheless, I don't understand what you mean that the IN operator is working on a set of strings being the problem? I got the following error in the operator when trying to use "true" : json: cannot unmarshal bool into Go struct field NodeSelectorRequirement.spec.template.spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms.matchExpressions.values of type string, requeuing"

This seems like it is the wrong type (as described in the bug mentioned by @kmizumar) and not due to the fact that it is not a list. In the end, I think the value "true" should be usable as is.

Hi @E-Zurg , I provided a workaround until the Trident fixes this. If you refer to the below document, it states that IN would treat each value as string but the value true is interpreted as a boolean and hence you see the error.

https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#operators

prajwal-venkatanarayan avatar Jul 15 '24 07:07 prajwal-venkatanarayan

This fix will be in the 24.10 release: https://github.com/NetApp/trident/commit/3550582947e96bba5c6bf151dce416ab77dd0db1

torirevilla avatar Oct 23 '24 16:10 torirevilla