@@ -122,6 +122,7 @@ TimeoutLoop:
122
122
deletedContainers := make (map [string ]bool )
123
123
deletedNetworks := make (map [string ]bool )
124
124
deletedVolumes := make (map [string ]bool )
125
+ deletedImages := make (map [string ]bool )
125
126
126
127
for param := range deathNote {
127
128
log .Printf ("Deleting %s\n " , param )
@@ -166,7 +167,20 @@ TimeoutLoop:
166
167
}
167
168
return shouldRetry , err
168
169
})
170
+
171
+ try .Do (func (attempt int ) (bool , error ) {
172
+ imagesPruneReport , err := cli .ImagesPrune (context .Background (), args )
173
+ for _ , image := range imagesPruneReport .ImagesDeleted {
174
+ deletedImages [image .Deleted ] = true
175
+ }
176
+ shouldRetry := attempt < 10
177
+ if err != nil && shouldRetry {
178
+ log .Printf ("Images pruning has failed, retrying(%d/%d). The error was: %v" , attempt , 10 , err )
179
+ time .Sleep (1 * time .Second )
180
+ }
181
+ return shouldRetry , err
182
+ })
169
183
}
170
184
171
- log .Printf ("Removed %d container(s), %d network(s), %d volume(s)" , len (deletedContainers ), len (deletedNetworks ), len (deletedVolumes ))
185
+ log .Printf ("Removed %d container(s), %d network(s), %d volume(s) %d image(s) " , len (deletedContainers ), len (deletedNetworks ), len (deletedVolumes ), len ( deletedImages ))
172
186
}
0 commit comments