Skip to content

Commit 3db8770

Browse files
committed
[controller] Reschedule provisioning if node is missing
GenerateAccessibilityRequirements tries to get the Node and CSINode objects but if they are missing (because they were deleted), then the provisioning will fail with ProvisioningNoChange which means that it will potentially be retried forever if the node never comes back because nothing is removing the selected-node annotation anymore. This commit makes it so that Not Found api errors are properly caught and when it's the case, ProvisioningReschedule is returned to tell the scheduler to try a new node. This matches the previous implementation in the external-provisioner lib (https://github.com/kubernetes-sigs/sig-storage-lib-external-provisioner/pull/194/files#diff-3c5bb5f48211873c58fcba055dcae2ac7b1958969219e06e1508d76d485dace7L1496-L1498) Signed-off-by: Baptiste Girard-Carrabin <[email protected]>
1 parent 1b71152 commit 3db8770

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

pkg/controller/controller.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,10 @@ func (p *csiProvisioner) prepareProvision(ctx context.Context, claim *v1.Persist
701701
p.csiNodeLister,
702702
p.nodeLister,
703703
p.pvcNodeStore)
704-
if err != nil {
704+
if apierrors.IsNotFound(err) {
705+
// The node or CSINode object can't be found, ask the scheduler for a reschedule
706+
return nil, controller.ProvisioningReschedule, err
707+
} else if err != nil {
705708
return nil, controller.ProvisioningNoChange, fmt.Errorf("error generating accessibility requirements: %v", err)
706709
}
707710
req.AccessibilityRequirements = requirements

pkg/controller/controller_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2503,6 +2503,29 @@ func provisionTestcases() (int64, map[string]provisioningTestcase) {
25032503
expectErr: true,
25042504
expectState: controller.ProvisioningFinished,
25052505
},
2506+
"fail with selected node but node doesn't exist": {
2507+
pluginCapabilities: provisionWithTopologyCapabilities,
2508+
volOpts: controller.ProvisionOptions{
2509+
SelectedNodeName: nodeBar.Name,
2510+
StorageClass: &storagev1.StorageClass{
2511+
ObjectMeta: metav1.ObjectMeta{
2512+
Name: fakeSCName,
2513+
},
2514+
ReclaimPolicy: &deletePolicy,
2515+
Parameters: map[string]string{
2516+
"fstype": "ext3",
2517+
},
2518+
},
2519+
PVName: "test-name",
2520+
PVC: func() *v1.PersistentVolumeClaim {
2521+
claim := createFakePVC(requestedBytes)
2522+
claim.Annotations[annSelectedNode] = nodeBar.Name
2523+
return claim
2524+
}(),
2525+
},
2526+
expectErr: true,
2527+
expectState: controller.ProvisioningReschedule,
2528+
},
25062529
}
25072530
}
25082531

0 commit comments

Comments
 (0)