mirror of
https://github.com/open-cluster-management-io/ocm.git
synced 2026-05-24 01:54:12 +00:00
Disable placement scheduling (#80)
* Disable placement scheduling Signed-off-by: clyang82 <chuyang@redhat.com> * Update to use annontation defined in api Signed-off-by: clyang82 <chuyang@redhat.com> * sync to vendor folder Signed-off-by: clyang82 <chuyang@redhat.com> * run go mod tidy Signed-off-by: clyang82 <chuyang@redhat.com> * sync-up deploy/hub Signed-off-by: clyang82 <chuyang@redhat.com> Signed-off-by: clyang82 <chuyang@redhat.com>
This commit is contained in:
@@ -263,6 +263,11 @@ func (c *schedulingController) syncPlacement(ctx context.Context, syncCtx factor
|
||||
return nil
|
||||
}
|
||||
|
||||
// no work if placement has cluster.open-cluster-management.io/experimental-scheduling-disable: "true" annotation
|
||||
if value, ok := placement.GetAnnotations()[clusterapiv1beta1.PlacementDisableAnnotation]; ok && value == "true" {
|
||||
return nil
|
||||
}
|
||||
|
||||
// get all valid clustersetbindings in the placement namespace
|
||||
bindings, err := c.getValidManagedClusterSetBindings(placement.Namespace)
|
||||
if err != nil {
|
||||
|
||||
@@ -176,6 +176,22 @@ func TestSchedulingController_sync(t *testing.T) {
|
||||
},
|
||||
validateActions: testinghelpers.AssertNoActions,
|
||||
},
|
||||
{
|
||||
name: "placement schedule controller is disabled",
|
||||
placement: testinghelpers.NewPlacementWithAnnotations(placementNamespace, placementName,
|
||||
map[string]string{
|
||||
clusterapiv1beta1.PlacementDisableAnnotation: "true",
|
||||
}).Build(),
|
||||
scheduleResult: &scheduleResult{
|
||||
feasibleClusters: []*clusterapiv1.ManagedCluster{
|
||||
testinghelpers.NewManagedCluster("cluster1").Build(),
|
||||
testinghelpers.NewManagedCluster("cluster2").Build(),
|
||||
testinghelpers.NewManagedCluster("cluster3").Build(),
|
||||
},
|
||||
scheduledDecisions: []clusterapiv1beta1.ClusterDecision{},
|
||||
},
|
||||
validateActions: testinghelpers.AssertNoActions,
|
||||
},
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
|
||||
@@ -29,6 +29,18 @@ func NewPlacement(namespace, name string) *placementBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
func NewPlacementWithAnnotations(namespace, name string, annotations map[string]string) *placementBuilder {
|
||||
return &placementBuilder{
|
||||
placement: &clusterapiv1beta1.Placement{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: namespace,
|
||||
Name: name,
|
||||
Annotations: annotations,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (b *placementBuilder) WithUID(uid string) *placementBuilder {
|
||||
b.placement.UID = types.UID(uid)
|
||||
return b
|
||||
|
||||
Reference in New Issue
Block a user