Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -209,7 +209,7 @@ func (r *Reconciler) executeEviction(ctx context.Context, validationResult *evic
}

// handle special case for PickAll CRP.
if crp.Spec.Policy.PlacementType == placementv1beta1.PickAllPlacementType {
if crp.Spec.Policy == nil || crp.Spec.Policy.PlacementType == placementv1beta1.PickAllPlacementType {
if db.Spec.MaxUnavailable != nil || (db.Spec.MinAvailable != nil && db.Spec.MinAvailable.Type == intstr.String) {
markEvictionNotExecuted(eviction, evictionBlockedMisconfiguredPDBSpecifiedMessage)
return nil
Expand Down Expand Up @@ -271,7 +271,12 @@ func isEvictionAllowed(bindings []placementv1beta1.ClusterResourceBinding, crp p
}

var desiredBindings int
placementType := crp.Spec.Policy.PlacementType
var placementType placementv1beta1.PlacementType
if crp.Spec.Policy != nil {
placementType = crp.Spec.Policy.PlacementType
} else {
placementType = placementv1beta1.PickAllPlacementType
}
switch placementType {
case placementv1beta1.PickNPlacementType:
desiredBindings = int(*crp.Spec.Policy.NumberOfClusters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,18 +536,14 @@ func TestExecuteEviction(t *testing.T) {
wantErr: nil,
},
{
name: "PickAll CRP, Misconfigured PDB MinAvailable specified as percentage - eviction not executed",
name: "PickAll CRP policy not specified, Misconfigured PDB MinAvailable specified as percentage - eviction not executed",
validationResult: &evictionValidationResult{
crb: availableBinding,
crp: &placementv1beta1.ClusterResourcePlacement{
ObjectMeta: metav1.ObjectMeta{
Name: testCRPName,
},
Spec: placementv1beta1.ClusterResourcePlacementSpec{
Policy: &placementv1beta1.PlacementPolicy{
PlacementType: placementv1beta1.PickAllPlacementType,
},
},
Spec: placementv1beta1.ClusterResourcePlacementSpec{},
},
},
eviction: buildTestEviction(testEvictionName, testCRPName, testClusterName),
Expand Down Expand Up @@ -1361,8 +1357,13 @@ func TestIsEvictionAllowed(t *testing.T) {
wantAvailableBindings: 3,
},
{
name: "MinAvailable specified as Integer zero, available binding, PickAll CRP - allow eviction",
crp: buildTestPickAllCRP(testCRPName),
name: "MinAvailable specified as Integer zero, available binding, PickAll CRP, no policy specified - allow eviction",
crp: placementv1beta1.ClusterResourcePlacement{
ObjectMeta: metav1.ObjectMeta{
Name: testCRPName,
},
Spec: placementv1beta1.ClusterResourcePlacementSpec{},
},
bindings: []placementv1beta1.ClusterResourceBinding{boundAvailableBinding},
disruptionBudget: placementv1alpha1.ClusterResourcePlacementDisruptionBudget{
ObjectMeta: metav1.ObjectMeta{
Expand Down
Loading