@@ -292,7 +292,11 @@ func (r *CachedImageResource) Read(ctx context.Context, req resource.ReadRequest
292
292
// If the previous state is that Image == BuilderImage, then we previously did
293
293
// not find the image. We will need to run another cache probe.
294
294
if data .Image .Equal (data .BuilderImage ) {
295
- tflog .Debug (ctx , "Image previously not found. Recreating." , map [string ]any {"ref" : data .Image .ValueString ()})
295
+ resp .Diagnostics .AddWarning (
296
+ "Re-running cache probe due to previous miss." ,
297
+ fmt .Sprintf (`The previous state specifies image == builder_image %q, which indicates a previous cache miss.` ,
298
+ data .Image .ValueString (),
299
+ ))
296
300
resp .State .RemoveResource (ctx )
297
301
return
298
302
}
@@ -301,12 +305,22 @@ func (r *CachedImageResource) Read(ctx context.Context, req resource.ReadRequest
301
305
img , err := getRemoteImage (data .Image .ValueString ())
302
306
if err != nil {
303
307
if ! strings .Contains (err .Error (), "MANIFEST_UNKNOWN" ) {
304
- resp .Diagnostics .AddError ("Error checking remote image" , err .Error ())
308
+ // Explicitly not making this an error diag.
309
+ resp .Diagnostics .AddWarning ("Unable to check remote image." ,
310
+ fmt .Sprintf ("The repository %q returned the following error while checking for a cached image %q: %q" ,
311
+ data .CacheRepo .ValueString (),
312
+ data .Image .ValueString (),
313
+ err .Error (),
314
+ ))
305
315
return
306
316
}
307
317
// Image does not exist any longer! Remove the resource so we can re-create
308
318
// it next time.
309
- tflog .Debug (ctx , "Remote image does not exist any longer. Recreating." , map [string ]any {"ref" : data .Image .ValueString ()})
319
+ resp .Diagnostics .AddWarning ("Previously built image not found, recreating." ,
320
+ fmt .Sprintf ("The repository %q does not contain the cached image %q. It will be rebuilt in the next apply." ,
321
+ data .CacheRepo .ValueString (),
322
+ data .Image .ValueString (),
323
+ ))
310
324
resp .State .RemoveResource (ctx )
311
325
return
312
326
}
@@ -365,7 +379,11 @@ func (r *CachedImageResource) Create(ctx context.Context, req resource.CreateReq
365
379
// FIXME: there are legit errors that can crop up here.
366
380
// We should add a sentinel error in Kaniko for uncached layers, and check
367
381
// it here.
368
- tflog .Info (ctx , "cached image not found" , map [string ]any {"err" : err .Error ()})
382
+ resp .Diagnostics .AddWarning ("Cached image not found." , fmt .Sprintf (
383
+ "Failed to find cached image in repository %q. It will be rebuilt in the next apply. Error: %s" ,
384
+ data .CacheRepo .ValueString (),
385
+ err .Error (),
386
+ ))
369
387
data .Image = data .BuilderImage
370
388
} else if digest , err := cachedImg .Digest (); err != nil {
371
389
// There's something seriously up with this image!
0 commit comments