Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cvvz committed Jan 5, 2024
1 parent 12fc088 commit 67cc5d2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 66 deletions.
Binary file modified charts/latest/blob-csi-driver-v0.0.0.tgz
Binary file not shown.
17 changes: 4 additions & 13 deletions pkg/blob/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ func (d *Driver) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolu
context := req.GetVolumeContext()
if context != nil {
// token request
if context[serviceAccountTokenField] != "" && getClientID(context) != "" {
klog.V(2).Infof("NodePublishVolume: volume(%s) mount on %s with service account token, clientID: %s", volumeID, target, getClientID(context))
if context[serviceAccountTokenField] != "" && getValueInMap(context, clientIDField) != "" {
klog.V(2).Infof("NodePublishVolume: volume(%s) mount on %s with service account token, clientID: %s", volumeID, target, getValueInMap(context, clientIDField))
_, err := d.NodeStageVolume(ctx, &csi.NodeStageVolumeRequest{
StagingTargetPath: target,
VolumeContext: context,
Expand Down Expand Up @@ -254,8 +254,8 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe
attrib := req.GetVolumeContext()
secrets := req.GetSecrets()

if getClientID(attrib) != "" && attrib[serviceAccountTokenField] == "" {
klog.V(2).Infof("Skip NodeStageVolume for volume(%s) since clientID %s is provided but service account token is empty", volumeID, getClientID(attrib))
if getValueInMap(attrib, clientIDField) != "" && attrib[serviceAccountTokenField] == "" {
klog.V(2).Infof("Skip NodeStageVolume for volume(%s) since clientID %s is provided but service account token is empty", volumeID, getValueInMap(attrib, clientIDField))
return &csi.NodeStageVolumeResponse{}, nil
}

Expand Down Expand Up @@ -694,15 +694,6 @@ func waitForMount(path string, intervel, timeout time.Duration) error {
}
}

func getClientID(context map[string]string) string {
for k, v := range context {
if strings.EqualFold(k, clientIDField) && v != "" {
return v
}
}
return ""
}

func checkGidPresentInMountFlags(mountFlags []string) bool {
for _, mountFlag := range mountFlags {
if strings.Contains(mountFlag, "gid=") {
Expand Down
53 changes: 0 additions & 53 deletions pkg/blob/nodeserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -832,59 +832,6 @@ func Test_waitForMount(t *testing.T) {
}
}

func Test_getClientID(t *testing.T) {
type args struct {
context map[string]string
}
tests := []struct {
name string
args args
want string
}{
{
name: "get client id",
args: args{
context: map[string]string{
clientIDField: "test-client-id",
},
},
want: "test-client-id",
},
{
name: "case not sensitive client id",
args: args{
context: map[string]string{
"ClientId": "test-client-id",
},
},
want: "test-client-id",
},
{
name: "no client id",
args: args{
context: map[string]string{},
},
want: "",
},
{
name: "client id empty",
args: args{
context: map[string]string{
clientIDField: "",
},
},
want: "",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := getClientID(tt.args.context); got != tt.want {
t.Errorf("getClientID() = %v, want %v", got, tt.want)
}
})
}
}

func TestCheckGidPresentInMountFlags(t *testing.T) {
tests := []struct {
desc string
Expand Down

0 comments on commit 67cc5d2

Please sign in to comment.