Skip to content

Commit 0db4568

Browse files
Praveenrajmaniwlan0
authored andcommitted
Fix loglevel flag
1 parent 0d00d79 commit 0db4568

File tree

7 files changed

+28
-11
lines changed

7 files changed

+28
-11
lines changed

cmd/direct-csi/cmd.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ var (
4545
conversionWebhook = false
4646
conversionWebhookURL = ""
4747
loopBackOnly = false
48+
showVersion = false
4849
)
4950

5051
var driverCmd = &cobra.Command{
@@ -59,18 +60,20 @@ For more information, use '%s man [sched | examples | ...]'
5960
`, os.Args[0]),
6061
SilenceUsage: true,
6162
RunE: func(c *cobra.Command, args []string) error {
63+
if showVersion {
64+
fmt.Println(Version)
65+
return nil
66+
}
6267
if !controller && !driver && !conversionWebhook {
6368
return fmt.Errorf("one among [--controller, --driver, --conversion-webhook] should be set")
6469
}
65-
6670
return run(c.Context(), args)
6771
},
68-
Version: Version,
6972
}
7073

7174
func init() {
72-
if driverCmd.Version == "" {
73-
driverCmd.Version = "dev"
75+
if Version == "" {
76+
Version = "dev"
7477
}
7578

7679
viper.AutomaticEnv()
@@ -81,11 +84,13 @@ func init() {
8184

8285
// parse the go default flagset to get flags for glog and other packages in future
8386
driverCmd.PersistentFlags().AddGoFlagSet(flag.CommandLine)
87+
driverCmd.PersistentFlags().AddGoFlagSet(kflags)
8488
// defaulting this to true so that logs are printed to console
8589
flag.Set("logtostderr", "true")
8690

8791
driverCmd.PersistentFlags().StringVarP(&kubeconfig, "kubeconfig", "k", kubeconfig, "path to kubeconfig")
8892
driverCmd.Flags().StringVarP(&identity, "identity", "i", identity, "identity of this direct-csi")
93+
driverCmd.Flags().BoolVarP(&showVersion, "version", "", showVersion, "version of direct-csi")
8994
driverCmd.Flags().StringVarP(&endpoint, "endpoint", "e", endpoint, "endpoint at which direct-csi is listening")
9095
driverCmd.Flags().StringVarP(&nodeID, "node-id", "n", nodeID, "identity of the node in which direct-csi is running")
9196
driverCmd.Flags().StringVarP(&rack, "rack", "", rack, "identity of the rack in which this direct-csi is running")

cmd/kubectl-direct_csi/cmd.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ var (
3434
identity = "direct.csi.min.io"
3535
dryRun = false
3636
dryRunFlagName = "dry-run"
37+
showVersion = false
3738
)
3839

3940
var pluginCmd = &cobra.Command{
4041
Use: "direct-csi",
4142
Short: "Plugin for managing Direct CSI drives and volumes",
4243
SilenceUsage: true,
4344
SilenceErrors: false,
44-
Version: Version,
4545
}
4646

4747
func init() {
48-
if pluginCmd.Version == "" {
49-
pluginCmd.Version = "dev"
48+
if Version == "" {
49+
Version = "dev"
5050
}
5151

5252
viper.AutomaticEnv()
@@ -57,6 +57,7 @@ func init() {
5757

5858
// parse the go default flagset to get flags for glog and other packages in future
5959
pluginCmd.PersistentFlags().AddGoFlagSet(flag.CommandLine)
60+
pluginCmd.PersistentFlags().AddGoFlagSet(kflags)
6061
// defaulting this to true so that logs are printed to console
6162
flag.Set("logtostderr", "true")
6263

@@ -84,5 +85,6 @@ func init() {
8485
}
8586

8687
func Execute(ctx context.Context) error {
88+
8789
return pluginCmd.ExecuteContext(ctx)
8890
}

minio.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -65,29 +65,29 @@ spec:
6565
# - {key: direct.csi.min.io/access-tier, operator: In, values: [Hot]}
6666
resources:
6767
requests:
68-
storage: 2Gi
68+
storage: 512Mi
6969
storageClassName: direct-csi-min-io # This field references the existing StorageClass
7070
- metadata:
7171
name: minio-data-2
7272
spec:
7373
accessModes: [ "ReadWriteOnce" ]
7474
resources:
7575
requests:
76-
storage: 2Gi
76+
storage: 512Mi
7777
storageClassName: direct-csi-min-io # This field references the existing StorageClass
7878
- metadata:
7979
name: minio-data-3
8080
spec:
8181
accessModes: [ "ReadWriteOnce" ]
8282
resources:
8383
requests:
84-
storage: 2Gi
84+
storage: 512Mi
8585
storageClassName: direct-csi-min-io # This field references the existing StorageClass
8686
- metadata:
8787
name: minio-data-4
8888
spec:
8989
accessModes: [ "ReadWriteOnce" ]
9090
resources:
9191
requests:
92-
storage: 2Gi
92+
storage: 512Mi
9393
storageClassName: direct-csi-min-io # This field references the existing StorageClass

pkg/controller/controller.go

+1
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ func (c *ControllerServer) ValidateVolumeCapabilities(ctx context.Context, req *
164164

165165
// CreateVolume - Creates a DirectCSI Volume
166166
func (c *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) {
167+
klog.V(4).Infof("CreateVolumeRequest: %v", req)
167168
name := req.GetName()
168169
if name == "" {
169170
return nil, status.Error(codes.InvalidArgument, "volume name cannot be empty")

pkg/node/publish_unpublish.go

+2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func parseVolumeContext(volumeContext map[string]string) (name, ns string, err e
6363
}
6464

6565
func (n *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) {
66+
klog.V(3).Infof("NodePublishVolumeRequest: %v", req)
6667
vID := req.GetVolumeId()
6768
if vID == "" {
6869
return nil, status.Error(codes.InvalidArgument, "volume ID missing in request")
@@ -158,6 +159,7 @@ func (n *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublish
158159
}
159160

160161
func (n *NodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error) {
162+
klog.V(3).Infof("NodeUnPublishVolumeRequest: %v", req)
161163
vID := req.GetVolumeId()
162164
if vID == "" {
163165
return nil, status.Error(codes.InvalidArgument, "volume ID missing in request")

pkg/node/stage_unstage.go

+3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ import (
3131
"github.com/container-storage-interface/spec/lib/go/csi"
3232
"google.golang.org/grpc/codes"
3333
"google.golang.org/grpc/status"
34+
"k8s.io/klog"
3435
)
3536

3637
func (n *NodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRequest) (*csi.NodeStageVolumeResponse, error) {
38+
klog.V(3).Infof("NodeStageVolumeRequest: %v", req)
3739
vID := req.GetVolumeId()
3840
if vID == "" {
3941
return nil, status.Error(codes.InvalidArgument, "volume ID missing in request")
@@ -97,6 +99,7 @@ func (n *NodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolu
9799
}
98100

99101
func (n *NodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstageVolumeRequest) (*csi.NodeUnstageVolumeResponse, error) {
102+
klog.V(3).Infof("NodeUnStageVolumeRequest: %v", req)
100103
vID := req.GetVolumeId()
101104
if vID == "" {
102105
return nil, status.Error(codes.InvalidArgument, "volume ID missing in request")

pkg/utils/installer/install.go

+4
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ func CreateDaemonSet(ctx context.Context, identity string, directCSIContainerIma
366366
Name: nodeDriverRegistrarContainerName,
367367
Image: filepath.Join(registry, org, nodeDriverRegistrarContainerImage),
368368
Args: []string{
369+
fmt.Sprintf("--v=%d", logLevel),
369370
"--csi-address=unix:///csi/csi.sock",
370371
fmt.Sprintf("--kubelet-registration-path=%s",
371372
newDirectCSIPluginsSocketDir(kubeletDirPath, name)+"/csi.sock"),
@@ -394,6 +395,7 @@ func CreateDaemonSet(ctx context.Context, identity string, directCSIContainerIma
394395
Args: func() []string {
395396
args := []string{
396397
fmt.Sprintf("--identity=%s", name),
398+
fmt.Sprintf("-v=%d", logLevel),
397399
fmt.Sprintf("--endpoint=$(%s)", endpointEnvVarCSI),
398400
fmt.Sprintf("--node-id=$(%s)", kubeNodeNameEnvVar),
399401
fmt.Sprintf("--conversion-webhook-url=%s", conversionWebhookURL),
@@ -635,6 +637,7 @@ func CreateDeployment(ctx context.Context, identity string, directCSIContainerIm
635637
Name: csiProvisionerContainerName,
636638
Image: filepath.Join(registry, org, csiProvisionerContainerImage),
637639
Args: []string{
640+
fmt.Sprintf("--v=%d", logLevel),
638641
"--timeout=300s",
639642
fmt.Sprintf("--csi-address=$(%s)", endpointEnvVarCSI),
640643
"--leader-election",
@@ -673,6 +676,7 @@ func CreateDeployment(ctx context.Context, identity string, directCSIContainerIm
673676
Name: directCSIContainerName,
674677
Image: filepath.Join(registry, org, directCSIContainerImage),
675678
Args: []string{
679+
fmt.Sprintf("-v=%d", logLevel),
676680
fmt.Sprintf("--identity=%s", name),
677681
fmt.Sprintf("--endpoint=$(%s)", endpointEnvVarCSI),
678682
fmt.Sprintf("--conversion-webhook-url=%s", conversionWebhookURL),

0 commit comments

Comments
 (0)