Skip to content
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

🌱 workspace_reconcile_scheduling: allow for skipping a shard with a special annotation during scheduling #2782

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,13 @@ const (
// WorkspaceShardHashAnnotationKey keeps track on which shard LogicalCluster must be scheduled. The value
// is a base36(sha224) hash of the Shard name.
WorkspaceShardHashAnnotationKey = "internal.tenancy.kcp.io/shard"

// workspaceClusterAnnotationKey keeps track of the logical cluster on the shard.
workspaceClusterAnnotationKey = "internal.tenancy.kcp.io/cluster"

// unschedulableAnnotationKey is the annotation key used to indicate that a shard is unschedulable.
// The annotation is meant to be used by e2e tests that otherwise started a private instance of kcp server.
unschedulableAnnotationKey = "experimental.core.kcp.io/unschedulable"
)

type schedulingReconciler struct {
Expand Down Expand Up @@ -194,6 +199,10 @@ func (r *schedulingReconciler) chooseShardAndMarkCondition(logger klog.Logger, w
reason, message string
}{}
for _, shard := range shards {
if _, ok := shard.Annotations[unschedulableAnnotationKey]; ok {
logger.V(4).Info("Skipping a shard because it is annotated as unschedulable", "shard", shard.Name, "annotation", unschedulableAnnotationKey)
continue
}
if valid, reason, message := isValidShard(shard); valid {
validShards = append(validShards, shard)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,32 @@ func TestReconcileScheduling(t *testing.T) {
},
expectedStatus: reconcileStatusStopAndRequeue,
},
{
name: "only an unschedulable shard is available, the ws is unscheduled",
initialShards: []*corev1alpha1.Shard{func() *corev1alpha1.Shard {
s := shard("amber")
s.Annotations[unschedulableAnnotationKey] = "true"
return s
}()},
targetWorkspace: workspace("foo"),
targetLogicalCluster: &corev1alpha1.LogicalCluster{},
validateWorkspace: func(t *testing.T, initialWS, wsAfterReconciliation *tenancyv1alpha1.Workspace) {
t.Helper()

clearLastTransitionTimeOnWsConditions(wsAfterReconciliation)
initialWS.Status.Conditions = append(initialWS.Status.Conditions, conditionsapi.Condition{
Type: tenancyv1alpha1.WorkspaceScheduled,
Severity: conditionsapi.ConditionSeverityError,
Status: corev1.ConditionFalse,
Reason: tenancyv1alpha1.WorkspaceReasonUnschedulable,
Message: "No available shards to schedule the workspace",
})
if !equality.Semantic.DeepEqual(wsAfterReconciliation, initialWS) {
t.Fatal(fmt.Errorf("unexpected Workspace:\n%s", cmp.Diff(wsAfterReconciliation, initialWS)))
}
},
expectedStatus: reconcileStatusContinue,
},
}
for _, scenario := range scenarios {
t.Run(scenario.name, func(t *testing.T) {
Expand Down