@@ -293,6 +293,11 @@ func (a *App) pollImageAccessEnabled(groupID int, stateDesired bool) {
293
293
}
294
294
295
295
func (a * App ) directAccess (t Task ) error {
296
+
297
+ pollDelay := 10 // seconds
298
+ pollCount := 0 // iteration counter
299
+ pollMax := 30 // max times to poll before breaking the poll loop
300
+
296
301
operationName := "Disabling"
297
302
operation := "disable_direct_access"
298
303
if t .Enable == true {
@@ -304,10 +309,16 @@ func (a *App) directAccess(t Task) error {
304
309
t .GroupUID , t .ClusterUID , t .CopyUID , operation )
305
310
if ! a .Config .CheckMode {
306
311
body , statusCode := a .apiRequest ("PUT" , endpoint , nil )
307
- if statusCode != 204 {
312
+ for statusCode != 204 {
308
313
log .Debugf ("Expected status code '204' and received: %d\n " , statusCode )
309
- log .Warnf ("Error enabling Direct Access for Group %s Copy %s\n " , t .GroupName , t .CopyName )
310
- return errors .New (string (body ))
314
+ time .Sleep (time .Duration (pollDelay ) * time .Second )
315
+ body , statusCode = a .apiRequest ("PUT" , endpoint , nil )
316
+ if pollCount > pollMax {
317
+ fmt .Println ("Maximum poll count reached while waiting for direct access" )
318
+ log .Warnf ("Error %s Direct Access for Group %s Copy %s\n " , operationName , t .GroupName , t .CopyName )
319
+ return errors .New (string (body ))
320
+ }
321
+ pollCount ++
311
322
}
312
323
}
313
324
fmt .Printf ("%s Direct Access for Group %s Copy %s\n " , operationName , t .GroupName , t .CopyName )
0 commit comments