@@ -42,14 +42,12 @@ func (Cephfs) GetOrGrantAccesses(args *GrantAccessArgs) ([]shares.AccessRight, e
42
42
}
43
43
}
44
44
45
- var accessToList []string
46
- if args .Options .CephfsClientID == "" {
47
- accessToList = []string {args .Share .Name }
48
- } else {
45
+ accessToList := []string {args .Share .Name }
46
+ if args .Options .CephfsClientID != "" {
49
47
accessToList = strings .Split (args .Options .CephfsClientID , "," )
50
48
}
51
49
52
- modified := false
50
+ created := false
53
51
for _ , at := range accessToList {
54
52
// Try to find the access right
55
53
found := false
@@ -81,31 +79,26 @@ func (Cephfs) GetOrGrantAccesses(args *GrantAccessArgs) ([]shares.AccessRight, e
81
79
wait .ExponentialBackoff (backoff , func () (bool , error ) {
82
80
rights , err := args .ManilaClient .GetAccessRights (args .Share .ID )
83
81
if err != nil {
84
- return false , err
82
+ return false , fmt . Errorf ( "error get access rights for share %s: %v" , args . Share . ID , err )
85
83
}
86
-
87
- var accessRight * shares.AccessRight
88
-
89
- for i := range rights {
90
- if rights [i ].AccessTo == at {
91
- accessRight = & rights [i ]
92
- break
93
- }
94
- }
95
-
96
- if accessRight == nil {
84
+ if len (rights ) == 0 {
97
85
return false , fmt .Errorf ("cannot find the access right we've just created" )
98
86
}
99
-
100
- return accessRight .AccessKey != "" , nil
87
+ for _ , r := range rights {
88
+ if r .AccessTo == at && r .AccessKey != "" {
89
+ return true , nil
90
+ }
91
+ }
92
+ klog .V (4 ).Infof ("Access key for %s is not set yet, retrying..." , at )
93
+ return false , nil
101
94
})
102
95
}
103
- modified = true
96
+ created = true
104
97
}
105
98
}
106
99
107
100
// Search again because access rights have changed
108
- if modified {
101
+ if created {
109
102
rights , err = args .ManilaClient .GetAccessRights (args .Share .ID )
110
103
if err != nil {
111
104
if _ , ok := err .(gophercloud.ErrResourceNotFound ); ! ok {
0 commit comments