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:
Chunlin Yang
2022-09-10 22:50:11 +08:00
committed by GitHub
parent 91f6c49630
commit dff2347502
12 changed files with 58 additions and 13 deletions

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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