@@ -292,7 +292,11 @@ func (r *CachedImageResource) Read(ctx context.Context, req resource.ReadRequest
292292 // If the previous state is that Image == BuilderImage, then we previously did
293293 // not find the image. We will need to run another cache probe.
294294 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+ ))
296300 resp .State .RemoveResource (ctx )
297301 return
298302 }
@@ -301,12 +305,22 @@ func (r *CachedImageResource) Read(ctx context.Context, req resource.ReadRequest
301305 img , err := getRemoteImage (data .Image .ValueString ())
302306 if err != nil {
303307 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+ ))
305315 return
306316 }
307317 // Image does not exist any longer! Remove the resource so we can re-create
308318 // 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+ ))
310324 resp .State .RemoveResource (ctx )
311325 return
312326 }
@@ -365,7 +379,11 @@ func (r *CachedImageResource) Create(ctx context.Context, req resource.CreateReq
365379 // FIXME: there are legit errors that can crop up here.
366380 // We should add a sentinel error in Kaniko for uncached layers, and check
367381 // 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+ ))
369387 data .Image = data .BuilderImage
370388 } else if digest , err := cachedImg .Digest (); err != nil {
371389 // There's something seriously up with this image!
0 commit comments