Skip to content

Commit

Permalink
handle PickFixed CRP in eviction controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Arvindthiru committed Dec 20, 2024
1 parent 96fd96a commit 586914d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const (

evictionInvalidMissingCRPMessage = "Failed to find ClusterResourcePlacement targeted by eviction"
evictionInvalidDeletingCRPMessage = "Found deleting ClusterResourcePlacement targeted by eviction"
evictionInvalidPickFixedCRPMessage = "Found ClusterResourcePlacement with PickFixed placement type targeted by eviction"
evictionInvalidMissingCRBMessage = "Failed to find scheduler decision for placement in cluster targeted by eviction"
evictionInvalidMultipleCRBMessage = "Found more than one scheduler decision for placement in cluster targeted by eviction"
evictionValidMessage = "Eviction is valid"
Expand Down Expand Up @@ -112,6 +113,11 @@ func (r *Reconciler) validateEviction(ctx context.Context, eviction *placementv1
markEvictionInvalid(eviction, evictionInvalidDeletingCRPMessage)
return validationResult, nil
}
if crp.Spec.Policy.PlacementType == placementv1beta1.PickFixedPlacementType {
klog.V(2).InfoS(evictionInvalidPickFixedCRPMessage, "clusterResourcePlacementEviction", eviction.Name, "clusterResourcePlacement", eviction.Spec.PlacementName)
markEvictionInvalid(eviction, evictionInvalidPickFixedCRPMessage)
return validationResult, nil
}
validationResult.crp = &crp

var crbList placementv1beta1.ClusterResourceBindingList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,31 @@ func TestValidateEviction(t *testing.T) {
},
wantErr: nil,
},
{
name: "invalid eviction - pickFixed CRP",
eviction: buildTestEviction(testEvictionName, testCRPName, testClusterName),
crp: &placementv1beta1.ClusterResourcePlacement{
ObjectMeta: metav1.ObjectMeta{
Name: testCRPName,
},
Spec: placementv1beta1.ClusterResourcePlacementSpec{
Policy: &placementv1beta1.PlacementPolicy{
PlacementType: placementv1beta1.PickFixedPlacementType,
},
},
},
wantValidationResult: &evictionValidationResult{
isValid: false,
},
wantEvictionInvalidCondition: &metav1.Condition{
Type: string(placementv1alpha1.PlacementEvictionConditionTypeValid),
Status: metav1.ConditionFalse,
ObservedGeneration: 1,
Reason: clusterResourcePlacementEvictionInvalidReason,
Message: evictionInvalidPickFixedCRPMessage,
},
wantErr: nil,
},
{
name: "invalid eviction - multiple CRBs for same cluster",
eviction: buildTestEviction(testEvictionName, testCRPName, testClusterName),
Expand Down

0 comments on commit 586914d

Please sign in to comment.