Browse Source

default to *not* calling s6-sync (see #244)

John Regan 6 years ago
parent
commit
0baa2015ad
2 changed files with 16 additions and 4 deletions
  1. 1 0
      README.md
  2. 15 4
      builder/overlay-rootfs/etc/s6/init/init-stage3

+ 1 - 0
README.md

@@ -358,6 +358,7 @@ It is possible somehow to tweak `s6` behaviour by providing an already predefine
 * `S6_CMD_WAIT_FOR_SERVICES` (default = 0): In order to proceed executing CMD overlay will wait until services are up. Be aware that up doesn't mean ready. Depending if `notification-fd` was found inside the servicedir overlay will use `s6-svwait -U` or `s6-svwait -u` as the waiting statement.
 * `S6_CMD_WAIT_FOR_SERVICES_MAXTIME` (default = 5000): The maximum time (in milliseconds) the services could take to bring up before proceding to CMD executing.
 * `S6_READ_ONLY_ROOT` (default = 0): When running in a container whose root filesystem is read-only, set this env to **1** to inform init stage 2 that it should copy user-provided initialization scripts from `/etc` to `/var/run/s6/etc` before it attempts to change permissions, etc. See [Read-Only Root Filesystem](#read-only-root-filesystem) for more information.
+* `S6_SYNC_DISKS` (default = 0): Set this env to **1** to inform init stage 3 that it should attempt to sync filesystems before stopping the container. Note: this will likely sync all filesystems on the host.
 
 ## Known issues and workarounds
 

+ 15 - 4
builder/overlay-rootfs/etc/s6/init/init-stage3

@@ -6,6 +6,10 @@ cd /
 # Merge environments from our custom stage into current context
 s6-envdir -I /var/run/s6/env-stage3
 
+# This env decides if we should call s6-sync or not (default no)
+backtick -D 0 -n S6_SYNC_DISKS { printcontenv S6_SYNC_DISKS }
+importas -u S6_SYNC_DISKS S6_SYNC_DISKS
+
 # cont-finish.d: one-time finish scripts
 
 foreground
@@ -48,9 +52,12 @@ foreground
 }
 
 # Sync before TERM'n
-
-foreground { s6-echo "[s6-finish] syncing disks." }
-foreground { s6-sync }
+foreground
+{
+  if { s6-test ${S6_SYNC_DISKS} -eq 1 }
+    foreground { s6-echo "[s6-finish] syncing disks." }
+    foreground { s6-sync }
+}
 
 
 # Kill everything, gently.
@@ -79,7 +86,11 @@ foreground { s6-nuke -k } # foreground is process 1: it survives again
 # Reap all the zombies then sync, and we're done.
 
 wait { }
-foreground { s6-sync }
+foreground
+{
+  if { s6-test ${S6_SYNC_DISKS} -eq 1 }
+    s6-sync
+}
 
 
 # Use CMD exit code defaulting to zero if not present.