Skip to content
Closed
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 @@ -192,9 +192,11 @@ func (a *managementCPUsOverride) Admit(ctx context.Context, attr admission.Attri
return admission.NewForbidden(attr, err) // can happen due to informer latency
}

// we still need to have nodes under the cluster to decide if the management resource enabled or not
// if the cluster has no nodes yet (e.g. during bootstrap), we cannot determine whether
// CPU partitioning is enabled — allow the pod without mutation rather than blocking it,
// which would prevent the machine-approver from starting and create a deadlock.
if len(nodes) == 0 {
return admission.NewForbidden(attr, fmt.Errorf("%s the cluster does not have any nodes", PluginName))
return nil
}

clusterInfra, err := a.infraConfigLister.Get(infraClusterName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,12 @@ func TestAdmit(t *testing.T) {
infra: testClusterInfraWithoutWorkloadPartitioning(),
},
{
name: "should return admission error when the cluster does not have any nodes",
name: "should allow pod without mutation when the cluster does not have any nodes",
pod: testManagedPod("500m", "250m", "500Mi", "250Mi"),
expectedCpuRequest: resource.MustParse("250m"),
namespace: testManagedNamespace(),
nodes: []*corev1.Node{},
infra: testClusterSNOInfra(),
expectedError: fmt.Errorf("the cluster does not have any nodes"),
},
}

Expand Down