Skip to content

Commit

Permalink
Merge pull request kubernetes-csi#134 from gnufied/add-support-for-at…
Browse files Browse the repository at this point in the history
…tach-limits

Add support for attach limits to the mock driver
  • Loading branch information
k8s-ci-robot authored Nov 6, 2018
2 parents 547ebfe + 1fccf8e commit 0c2ff6d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions mock/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func main() {
var config service.Config
flag.BoolVar(&config.DisableAttach, "disable-attach", false, "Disables RPC_PUBLISH_UNPUBLISH_VOLUME capability.")
flag.StringVar(&config.DriverName, "name", service.Name, "CSI driver name.")
flag.Int64Var(&config.AttachLimit, "attach-limit", 0, "number of attachable volumes on a node")
flag.Parse()

endpoint := os.Getenv("CSI_ENDPOINT")
Expand Down
8 changes: 6 additions & 2 deletions mock/service/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,13 @@ func (s *service) NodeGetCapabilities(

func (s *service) NodeGetInfo(ctx context.Context,
req *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error) {
return &csi.NodeGetInfoResponse{
csiNodeResponse := &csi.NodeGetInfoResponse{
NodeId: s.nodeID,
}, nil
}
if s.config.AttachLimit > 0 {
csiNodeResponse.MaxVolumesPerNode = s.config.AttachLimit
}
return csiNodeResponse, nil
}

func (s *service) NodeGetVolumeStats(ctx context.Context,
Expand Down
1 change: 1 addition & 0 deletions mock/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var Manifest = map[string]string{
type Config struct {
DisableAttach bool
DriverName string
AttachLimit int64
}

// Service is the CSI Mock service provider.
Expand Down

0 comments on commit 0c2ff6d

Please sign in to comment.