Skip to content
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
2 changes: 1 addition & 1 deletion cmd/csi-provisioner/csi-provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ var (
enableCapacity = flag.Bool("enable-capacity", false, "This enables producing CSIStorageCapacity objects with capacity information from the driver's GetCapacity call.")
capacityImmediateBinding = flag.Bool("capacity-for-immediate-binding", false, "Enables producing capacity information for storage classes with immediate binding. Not needed for the Kubernetes scheduler, maybe useful for other consumers or for debugging.")
capacityPollInterval = flag.Duration("capacity-poll-interval", time.Minute, "How long the external-provisioner waits before checking for storage capacity changes.")
capacityOwnerrefLevel = flag.Int("capacity-ownerref-level", 1, "The level indicates the number of objects that need to be traversed starting from the pod identified by the POD_NAME and POD_NAMESPACE environment variables to reach the owning object for CSIStorageCapacity objects: -1 for no owner, 0 for the pod itself, 1 for a StatefulSet or DaemonSet, 2 for a Deployment, etc.")
capacityOwnerrefLevel = flag.Int("capacity-ownerref-level", 1, "The level indicates the number of objects that need to be traversed starting from the pod identified by the POD_NAME and NAMESPACE environment variables to reach the owning object for CSIStorageCapacity objects: -1 for no owner, 0 for the pod itself, 1 for a StatefulSet or DaemonSet, 2 for a Deployment, etc.")

enableNodeDeployment = flag.Bool("node-deployment", false, "Enables deploying the external-provisioner together with a CSI driver on nodes to manage node-local volumes.")
nodeDeploymentImmediateBinding = flag.Bool("node-deployment-immediate-binding", true, "Determines whether immediate binding is supported when deployed on each node.")
Expand Down
18 changes: 10 additions & 8 deletions pkg/capacity/capacity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1100,10 +1100,18 @@ func TestCapacityController(t *testing.T) {
// that gets cancelled. Therefore we just keep everything running.
ctx := context.Background()

cscCreateReactor := createCSIStorageCapacityReactor()
var initialObjects []runtime.Object
initialObjects = append(initialObjects, makeSCs(tc.initialSCs)...)
for _, testCapacity := range tc.initialCapacities {
csc := makeCapacity(testCapacity)
cscCreateReactor(ktesting.CreateActionImpl{
Object: csc,
})
initialObjects = append(initialObjects, csc)
}
clientSet := fakeclientset.NewSimpleClientset(initialObjects...)
clientSet.PrependReactor("create", "csistoragecapacities", createCSIStorageCapacityReactor())
clientSet.PrependReactor("create", "csistoragecapacities", cscCreateReactor)
clientSet.PrependReactor("update", "csistoragecapacities", updateCSIStorageCapacityReactor())
topo := tc.topology
if topo == nil {
Expand All @@ -1117,13 +1125,6 @@ func TestCapacityController(t *testing.T) {
owner = &defaultOwner
}
c, registry := fakeController(ctx, clientSet, owner, &tc.storage, topo, tc.immediateBinding)
for _, testCapacity := range tc.initialCapacities {
capacity := makeCapacity(testCapacity)
_, err := clientSet.StorageV1beta1().CSIStorageCapacities(ownerNamespace).Create(ctx, capacity, metav1.CreateOptions{})
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
}
c.prepare(ctx)
if err := tc.expectedObjectsPrepared.verify(registry); err != nil {
t.Fatalf("metrics after prepare: %v", err)
Expand Down Expand Up @@ -1632,6 +1633,7 @@ func makeCapacity(in testCapacity) *storagev1beta1.CSIStorageCapacity {
UID: in.uid,
ResourceVersion: in.resourceVersion,
Name: fmt.Sprintf("csisc-%d", capacityCounter),
Namespace: ownerNamespace,
OwnerReferences: owners,
Labels: labels,
},
Expand Down
16 changes: 16 additions & 0 deletions pkg/capacity/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ type provisionWrapper struct {
}

var _ controller.Provisioner = &provisionWrapper{}
var _ controller.BlockProvisioner = &provisionWrapper{}
var _ controller.Qualifier = &provisionWrapper{}

func NewProvisionWrapper(p controller.Provisioner, c *Controller) controller.Provisioner {
return &provisionWrapper{
Expand Down Expand Up @@ -85,3 +87,17 @@ func (p *provisionWrapper) Delete(ctx context.Context, pv *v1.PersistentVolume)
}
return
}

func (p *provisionWrapper) SupportsBlock(ctx context.Context) bool {
if blockProvisioner, ok := p.Provisioner.(controller.BlockProvisioner); ok {
return blockProvisioner.SupportsBlock(ctx)
}
return false
}

func (p *provisionWrapper) ShouldProvision(ctx context.Context, claim *v1.PersistentVolumeClaim) bool {
if qualifier, ok := p.Provisioner.(controller.Qualifier); ok {
return qualifier.ShouldProvision(ctx, claim)
}
return false
}