Skip to content

Commit 616de96

Browse files
committed
Add --enable-list-snapshots command-line option
This commit introduces the --enable-list-snapshots command-line option, allowing users to explicitly enable or disable the ControllerServiceCapability_RPC_LIST_SNAPSHOTS capability. By default, this option is set to true to preserve existing behavior. Disabling RPC_LIST_SNAPSHOTS is useful for emulating the behavior of CSI drivers that do not support this optional RPC call. Signed-off-by: Leonardo Cecchi <[email protected]>
1 parent 36ce33b commit 616de96

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

cmd/hostpathplugin/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ func main() {
6262
flag.Var(&cfg.AcceptedMutableParameterNames, "accepted-mutable-parameter-names", "Comma separated list of parameter names that can be modified on a persistent volume. This is only used when enable-controller-modify-volume is true. If unset, all parameters are mutable.")
6363
flag.BoolVar(&cfg.DisableControllerExpansion, "disable-controller-expansion", false, "Disables Controller volume expansion capability.")
6464
flag.BoolVar(&cfg.DisableNodeExpansion, "disable-node-expansion", false, "Disables Node volume expansion capability.")
65+
flag.BoolVar(&cfg.EnableListSnapshots, "enable-list-snapshots", true, "Enables ControllerServiceCapability_RPC_LIST_SNAPSHOTS capability. Defaults to true.")
6566
flag.Int64Var(&cfg.MaxVolumeExpansionSizeNode, "max-volume-size-node", 0, "Maximum allowed size of volume when expanded on the node. Defaults to same size as max-volume-size.")
6667

6768
flag.Int64Var(&cfg.AttachLimit, "attach-limit", 0, "Maximum number of attachable volumes on a node. Zero refers to no limit.")

pkg/hostpath/controllerserver.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,6 @@ func (hp *hostPath) getControllerServiceCapabilities() []*csi.ControllerServiceC
877877
csi.ControllerServiceCapability_RPC_GET_VOLUME,
878878
csi.ControllerServiceCapability_RPC_GET_CAPACITY,
879879
csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT,
880-
csi.ControllerServiceCapability_RPC_LIST_SNAPSHOTS,
881880
csi.ControllerServiceCapability_RPC_LIST_VOLUMES,
882881
csi.ControllerServiceCapability_RPC_CLONE_VOLUME,
883882
csi.ControllerServiceCapability_RPC_VOLUME_CONDITION,
@@ -892,6 +891,9 @@ func (hp *hostPath) getControllerServiceCapabilities() []*csi.ControllerServiceC
892891
if hp.config.EnableControllerModifyVolume {
893892
cl = append(cl, csi.ControllerServiceCapability_RPC_MODIFY_VOLUME)
894893
}
894+
if hp.config.EnableListSnapshots {
895+
cl = append(cl, csi.ControllerServiceCapability_RPC_LIST_SNAPSHOTS)
896+
}
895897
}
896898

897899
var csc []*csi.ControllerServiceCapability

pkg/hostpath/hostpath.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ type Config struct {
8888
DisableNodeExpansion bool
8989
MaxVolumeExpansionSizeNode int64
9090
CheckVolumeLifecycle bool
91+
EnableListSnapshots bool
9192
}
9293

9394
var (

0 commit comments

Comments
 (0)