-
Notifications
You must be signed in to change notification settings - Fork 74
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
🐛 fix ClustersPerDecisionGroup as optional field #263
🐛 fix ClustersPerDecisionGroup as optional field #263
Conversation
Signed-off-by: haoqing0110 <qhao@redhat.com>
/assign @serngawy |
@@ -137,7 +137,6 @@ type GroupStrategy struct { | |||
// group SHOULD be less than ClustersPerDecisionGroup. Once the number of items exceeds the ClustersPerDecisionGroup, | |||
// the decisionGroups will also be be divided into multiple decisionGroups with same GroupName but different GroupIndex. | |||
// | |||
// +kubebuilder:validation:Required |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why removing it ? we need to keep the default value 100% exist if the user did not defined the GroupStrategy. With omitempty available it will be empty string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meets below error if this field is required.
➜ placement-strategy git:(master) ✗ cat placement1.yaml
# clusteradm clusterset bind global --namespace default
apiVersion: cluster.open-cluster-management.io/v1beta1
kind: Placement
metadata:
name: placement1
namespace: default
spec:
clusterSets:
- global
tolerations:
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
- key: cluster.open-cluster-management.io/unavailable
operator: Exists
decisionStrategy:
groupStrategy:
decisionGroups:
- groupName: prod-canary-west
groupClusterSelector:
labelSelector:
matchExpressions:
- key: prod-canary-west
operator: Exists
- groupName: prod-canary-east
groupClusterSelector:
labelSelector:
matchExpressions:
- key: prod-canary-east
operator: Exists
➜ placement-strategy git:(master) ✗ kubectl apply -f placement1.yaml
error: error validating "placement1.yaml": error validating data: ValidationError(Placement.spec.decisionStrategy.groupStrategy): missing required field "clustersPerDecisionGroup" in io.open-cluster-management.cluster.v1beta1.Placement.spec.decisionStrategy.groupStrategy; if you choose to ignore these errors, turn validation off with --validate=false
Even remove it, since it has default value 100%
// +kubebuilder:default:="100%"
// +optional
The applied resource will still have a default value 100% generated.
After removing the Required
➜ placement-strategy git:(master) ✗ kubectl apply -f placement1.yaml
placement.cluster.open-cluster-management.io/placement1 created
➜ placement-strategy git:(master) ✗ kubectl get placement placement1 -oyaml | grep spec -A 10
spec:
clusterSets:
- global
decisionStrategy:
groupStrategy:
clustersPerDecisionGroup: 100%
decisionGroups:
- groupClusterSelector:
labelSelector:
matchExpressions:
- key: prod-canary-west
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, then sounds good to me.
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: haoqing0110, qiujian16, serngawy The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
2e8926a
into
open-cluster-management-io:main
Summary
Related issue(s)
Fixes #