Skip to content

fix: postpone base image updates while sessions are running - #56

Open
raphaelcoeffic wants to merge 1 commit into
mainfrom
fix/postpone-base-update
Open

raphaelcoeffic wants to merge 1 commit into
mainfrom
fix/postpone-base-update

Conversation

@raphaelcoeffic

Copy link
Copy Markdown
Owner

New sessions join the shared mount namespace of the running ones, on the current base image. Replacing the base image files under their mounted overlay breaks them (lower layer changes are undefined behavior for overlayfs).

Change

  • When dive sessions are running (dive::cleanup::active_sessions) and the base image would change (new base_image_outdated, sharing the hash comparison with update_base_image), keep the current base image and warn:
    [WARN ] 1 dive session is running: base image update postponed until it exits
    
    The update happens on the first run after the sessions exit.
  • The overlay locks ({rootful,rootless}/lock) are held during the check and the update. A session holds its lock from joining or creating the shared mount until its pid file exists, so it is either seen as running, or starts after the update.

Complements #55: the overlay sync it adds runs when the overlay is mounted, i.e. on the first session after the update.

Testing

End to end, rootful alpine:3.22 container, scratch state directory, base image 0.2.7 installed by the release binary:

  • session A running (release binary); this build with a newer base image (-b with the base image artifact of main run #198) → warning above, runs on the current base image, base image on disk unchanged; A's base image still intact when it exits
  • after A exited → base image updated, new session sees the new base
  • same base image again → no warning, no update
  • cargo check --features embedded_image (the release build's code path)

New sessions join the shared mount of the running ones, on the current
base image, and replacing the base image files under their mounted
overlay breaks them (lower layer changes are undefined for overlayfs).

When dive sessions are running and the base image would change, keep
the current one and warn:

  1 dive session is running: base image update postponed until it exits

The overlay locks are held during the check and the update: a session
holds its lock from joining or creating the shared mount until its pid
file exists, so it is either seen as running or starts after the update.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant