@@ -73,10 +73,11 @@ const (
73
73
)
74
74
75
75
var (
76
- errInsufficientStorage = errors .New ("storage available is less than minimum required" )
77
- errFailedToPullImage = errors .New ("failed to pull image" )
78
- errNotFound = errors .New ("not found" )
79
- errRequeueAfterTimeout = errors .New ("requeue: prefetching images incomplete after timeout" )
76
+ errInsufficientStorage = errors .New ("storage available is less than minimum required" )
77
+ errFailedToPullImage = errors .New ("failed to pull image" )
78
+ errFailedToManifestInspect = errors .New ("failed to execute podman manifest inspect" )
79
+ errNotFound = errors .New ("not found" )
80
+ errRequeueAfterTimeout = errors .New ("requeue: prefetching images incomplete after timeout" )
80
81
)
81
82
82
83
// PinnedImageSetManager manages the prefetching of images.
@@ -1139,12 +1140,27 @@ func (p *PinnedImageSetManager) getImageSize(ctx context.Context, imageName, aut
1139
1140
imageName ,
1140
1141
}
1141
1142
1142
- output , err := exec .CommandContext (ctx , "podman" , args ... ).CombinedOutput ()
1143
- if err != nil && strings .Contains (err .Error (), "manifest unknown" ) {
1144
- return 0 , errNotFound
1145
- }
1143
+ var lastErr error
1144
+ tries := 0
1145
+ var output []byte
1146
+ err := wait .PollUntilContextCancel (ctx , 2 * time .Second , true , func (ctx context.Context ) (bool , error ) {
1147
+ tries ++
1148
+
1149
+ output , err := exec .CommandContext (ctx , "podman" , args ... ).CombinedOutput ()
1150
+ lastErr = err
1151
+ if err != nil && strings .Contains (err .Error (), "manifest unknown" ) {
1152
+ return true , errNotFound
1153
+ }
1154
+ if err != nil {
1155
+ klog .Infof ("%w %q: Output:%s Error:%w" , errFailedToManifestInspect , imageName , output , err )
1156
+ return false , nil
1157
+ }
1158
+
1159
+ return true , nil
1160
+ })
1161
+ // this is only an error if ctx has error or limits are exceeded
1146
1162
if err != nil {
1147
- return 0 , fmt .Errorf ("failed to execute podman manifest inspect for %q: Output:%s Error: %w" , imageName , output , err )
1163
+ return 0 , fmt .Errorf ("%w %q (%d tries): %w: %w" , errFailedToManifestInspect , imageName , tries , err , lastErr )
1148
1164
}
1149
1165
1150
1166
var manifest ocispec.Manifest
0 commit comments