Hadron / carthage

Carthage is an Infrastructure as Code (IAC) framework
Other
7 stars 4 forks source link

ContainerfileImage:find:created unreliable #38

Closed kdienes closed 1 year ago

kdienes commented 1 year ago

The problem comes up when something triggers container_context_mtime but doesn't end up building a new layer in podman build (due to cache). So the created field stays older than container_context_mtime and it rebuilds the image every time.

The problem is particularly confusing because find() returns False, and so check_completed_func() returns False, and so --tasks-verbose prints "Task Construct Object never run for " leading the user to think something has become horribly confused.

Since this is all in the Podman-specific code --annotation= might be an option.

hartmans commented 1 year ago

I'm not familiar with --annotation; how would you propose to use it here?

kdienes commented 1 year ago

My impression is that you're rejecting a ContainerfileImage if it has a 'Created' field that is older than the newest file timestamp from the context directory. The problem is that 'Created' doesn't always get updated to be newer than the latest timestamp when caching is present.

I think it might be possible to store a separate timestamp specifically for built-from-contextdir-last-modified using --annotation, and to use that in place of 'Created.'

There is also --label. I'd be unable to explain the difference between --annotation and --label without research.

Oh hey cool there is also --timestamp= ... maybe that's even better.

It also might be reasonable to use some kind of hash and make the semantics "reject if not built by the contextdir" instead of "built later than the contextdir"