-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow resource settings with empty values.
When the policy is used in the Rancher UI the policy settings are sent with empty values when the user does not want to validate a resource type (memory/cpu). This is causing issues because the policy does not allow empty values in the settings. This commit fix that by allowing only a single resource settings to be empty. Not both. Therefore, we fix the issue in the Rancher UI and does not broken the policy usage. The Rancher UI cannot be fixed in the questions.yaml file because it does not have a feature that allow us to remove the boolean flag when user does not enabled it. Therefore, the settings always sent empty values. Signed-off-by: José Guilherme Vanz <jguilhermevanz@suse.com>
- Loading branch information
Showing
6 changed files
with
248 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
{ | ||
"uid": "1299d386-525b-4032-98ae-1949f69f9cfc", | ||
"kind": { | ||
"group": "", | ||
"version": "v1", | ||
"kind": "Pod" | ||
}, | ||
"resource": { | ||
"group": "", | ||
"version": "v1", | ||
"resource": "pods" | ||
}, | ||
"requestKind": { | ||
"group": "", | ||
"version": "v1", | ||
"kind": "Pod" | ||
}, | ||
"requestResource": { | ||
"group": "", | ||
"version": "v1", | ||
"resource": "pods" | ||
}, | ||
"name": "nginx", | ||
"namespace": "default", | ||
"operation": "CREATE", | ||
"userInfo": { | ||
"username": "kubernetes-admin", | ||
"groups": [ | ||
"system:masters", | ||
"system:authenticated" | ||
] | ||
}, | ||
"object": { | ||
"kind": "Pod", | ||
"apiVersion": "v1", | ||
"metadata": { | ||
"name": "nginx", | ||
"namespace": "default", | ||
"uid": "04dc7a5e-e1f1-4e34-8d65-2c9337a43e64", | ||
"labels": { | ||
"env": "test" | ||
}, | ||
"annotations": { | ||
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Pod\",\"metadata\":{\"annotations\":{},\"labels\":{\"env\":\"test\"},\"name\":\"nginx\",\"namespace\":\"default\"},\"spec\":{\"containers\":[{\"image\":\"nginx\",\"imagePullPolicy\":\"IfNotPresent\",\"name\":\"nginx\"}],\"tolerations\":[{\"effect\":\"NoSchedule\",\"key\":\"example-key\",\"operator\":\"Exists\"}]}}\n" | ||
} | ||
}, | ||
"spec": { | ||
"containers": [ | ||
{ | ||
"name": "pause", | ||
"image": "registry.k8s.io/pause", | ||
"resources": { | ||
"limits": { | ||
"cpu": "3m", | ||
"memory": "1Gi" | ||
}, | ||
"requests": { | ||
"cpu": "3m", | ||
"memory": "1Gi" | ||
} | ||
} | ||
}, | ||
{ | ||
"name": "mycontainer", | ||
"image": "image:latest", | ||
"resources": { | ||
"limits": { | ||
"cpu": "2m", | ||
"memory": "1Gi" | ||
}, | ||
"requests": { | ||
"cpu": "2m", | ||
"memory": "1Gi" | ||
} | ||
} | ||
} | ||
], | ||
"restartPolicy": "Always", | ||
"terminationGracePeriodSeconds": 30, | ||
"dnsPolicy": "ClusterFirst", | ||
"serviceAccountName": "default", | ||
"serviceAccount": "default", | ||
"securityContext": {}, | ||
"schedulerName": "default-scheduler" | ||
} | ||
}, | ||
"oldObject": null, | ||
"dryRun": false, | ||
"options": { | ||
"kind": "CreateOptions", | ||
"apiVersion": "meta.k8s.io/v1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
{ | ||
"uid": "1299d386-525b-4032-98ae-1949f69f9cfc", | ||
"kind": { | ||
"group": "", | ||
"version": "v1", | ||
"kind": "Pod" | ||
}, | ||
"resource": { | ||
"group": "", | ||
"version": "v1", | ||
"resource": "pods" | ||
}, | ||
"requestKind": { | ||
"group": "", | ||
"version": "v1", | ||
"kind": "Pod" | ||
}, | ||
"requestResource": { | ||
"group": "", | ||
"version": "v1", | ||
"resource": "pods" | ||
}, | ||
"name": "nginx", | ||
"namespace": "default", | ||
"operation": "CREATE", | ||
"userInfo": { | ||
"username": "kubernetes-admin", | ||
"groups": [ | ||
"system:masters", | ||
"system:authenticated" | ||
] | ||
}, | ||
"object": { | ||
"kind": "Pod", | ||
"apiVersion": "v1", | ||
"metadata": { | ||
"name": "nginx", | ||
"namespace": "default", | ||
"uid": "04dc7a5e-e1f1-4e34-8d65-2c9337a43e64", | ||
"labels": { | ||
"env": "test" | ||
}, | ||
"annotations": { | ||
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Pod\",\"metadata\":{\"annotations\":{},\"labels\":{\"env\":\"test\"},\"name\":\"nginx\",\"namespace\":\"default\"},\"spec\":{\"containers\":[{\"image\":\"nginx\",\"imagePullPolicy\":\"IfNotPresent\",\"name\":\"nginx\"}],\"tolerations\":[{\"effect\":\"NoSchedule\",\"key\":\"example-key\",\"operator\":\"Exists\"}]}}\n" | ||
} | ||
}, | ||
"spec": { | ||
"containers": [ | ||
{ | ||
"name": "pause", | ||
"image": "registry.k8s.io/pause", | ||
"resources": { | ||
"limits": { | ||
"cpu": "1m", | ||
"memory": "3Gi" | ||
}, | ||
"requests": { | ||
"cpu": "1m", | ||
"memory": "3Gi" | ||
} | ||
} | ||
}, | ||
{ | ||
"name": "mycontainer", | ||
"image": "image:latest", | ||
"resources": { | ||
"limits": { | ||
"cpu": "1m", | ||
"memory": "2Gi" | ||
}, | ||
"requests": { | ||
"cpu": "1m", | ||
"memory": "2Gi" | ||
} | ||
} | ||
} | ||
], | ||
"restartPolicy": "Always", | ||
"terminationGracePeriodSeconds": 30, | ||
"dnsPolicy": "ClusterFirst", | ||
"serviceAccountName": "default", | ||
"serviceAccount": "default", | ||
"securityContext": {}, | ||
"schedulerName": "default-scheduler" | ||
} | ||
}, | ||
"oldObject": null, | ||
"dryRun": false, | ||
"options": { | ||
"kind": "CreateOptions", | ||
"apiVersion": "meta.k8s.io/v1" | ||
} | ||
} |