Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Improve drain script support #10

Merged
merged 19 commits into from
May 12, 2021
Merged

Improve drain script support #10

merged 19 commits into from
May 12, 2021

Commits on May 7, 2021

  1. Unregister subprocesses once they are no longer running

    Signed-off-by: Jan Dubois <[email protected]>
    jandubois committed May 7, 2021
    Configuration menu
    Copy the full SHA
    e2d5ef6 View commit details
    Browse the repository at this point in the history
  2. Don't exit container-run until SIGTERM is received, or the main proce…

    …ss fails
    
    To avoid terminating early and killing a still running drain script it is
    necessary to keep the container-run process running even if the main
    process has already exited.
    
    Once container-run receives the SIGTERM signal it will pass it on to the
    child processes and then wait until all direct children have exited before
    exiting itself. This should allow the processes to terminate cleanly as
    long as the grace period has not yet expired.
    
    container-run will also terminate immediately if the main process terminates
    with an error. This allows the container to fail and be restarted by k8s.
    
    Signed-off-by: Jan Dubois <[email protected]>
    jandubois committed May 7, 2021
    Configuration menu
    Copy the full SHA
    19b5b5d View commit details
    Browse the repository at this point in the history
  3. Add QUIT command to send SIGQUIT to process

    This is used to trigger graceful shutdown of nginx.
    
    Signed-off-by: Jan Dubois <[email protected]>
    jandubois committed May 7, 2021
    Configuration menu
    Copy the full SHA
    f009f41 View commit details
    Browse the repository at this point in the history
  4. Create status indicator on the shared volume while the process is run…

    …ning
    
    Can be used to wait for a process to stop after sending the STOP command.
    
    Signed-off-by: Jan Dubois <[email protected]>
    jandubois committed May 7, 2021
    Configuration menu
    Copy the full SHA
    50be76f View commit details
    Browse the repository at this point in the history
  5. Write /var/vcap/jobs/bpm/bin/bpm script for drain script usage

    It only supports the "start" and "stop" commands from the real bpm,
    but has additional "quit" and "running" commands to help reimplementing
    drain scripts that make use of the pid files.
    
    Signed-off-by: Jan Dubois <[email protected]>
    jandubois committed May 7, 2021
    Configuration menu
    Copy the full SHA
    804b256 View commit details
    Browse the repository at this point in the history

Commits on May 8, 2021

  1. Add --debug option

    Signed-off-by: Jan Dubois <[email protected]>
    jandubois committed May 8, 2021
    Configuration menu
    Copy the full SHA
    484a7fb View commit details
    Browse the repository at this point in the history
  2. Make errors channel unbuffered again

    It is important to process errors synchronously because their handling
    depends on the value of the 'active' flag. To avoid deadlocks any code
    sending errors to the channel must run in a blockable goroutine.
    
    Signed-off-by: Jan Dubois <[email protected]>
    jandubois committed May 8, 2021
    Configuration menu
    Copy the full SHA
    f822405 View commit details
    Browse the repository at this point in the history
  3. Use SIGTERM instead of SIGKILL to STOP processes

    (and give them a chance to notify their child processes). If
    the processes haven't terminated in 20s, send SIGKILL.
    
    Signed-off-by: Jan Dubois <[email protected]>
    jandubois committed May 8, 2021
    Configuration menu
    Copy the full SHA
    2b39e8a View commit details
    Browse the repository at this point in the history
  4. Add some additional debug logging

    Signed-off-by: Jan Dubois <[email protected]>
    jandubois committed May 8, 2021
    Configuration menu
    Copy the full SHA
    6cb69e3 View commit details
    Browse the repository at this point in the history
  5. Unregister process as soon as it quits

    Signed-off-by: Jan Dubois <[email protected]>
    jandubois committed May 8, 2021
    Configuration menu
    Copy the full SHA
    d72b104 View commit details
    Browse the repository at this point in the history
  6. Call stopProcesses on SIGTERM (and SIGINT for testing)

    That way it also starts the timeout trigger if the process
    doesn't stop within 20s.
    
    Signed-off-by: Jan Dubois <[email protected]>
    jandubois committed May 8, 2021
    Configuration menu
    Copy the full SHA
    f4213ce View commit details
    Browse the repository at this point in the history
  7. Only handle SIGINT, SIGQUIT, and SIGTERM signals

    The rest are just confusing the debug output, and passing
    on e.g. SIGCHLD to the child processes is neither correct
    nor useful.
    
    Signed-off-by: Jan Dubois <[email protected]>
    jandubois committed May 8, 2021
    Configuration menu
    Copy the full SHA
    2f616e5 View commit details
    Browse the repository at this point in the history
  8. bpm stop now waits up to 30s for the process to stop

    container-run should send a SIGKILL if the process is still alive
    after 20s, so if it isn't gone after 30, then it probably will not
    stop.
    
    The `bpm running` subcommand will also now print "yes" or "no" in
    addition to setting the exit code.
    
    Signed-off-by: Jan Dubois <[email protected]>
    jandubois committed May 8, 2021
    Configuration menu
    Copy the full SHA
    1029a22 View commit details
    Browse the repository at this point in the history
  9. Make the tests compile again

    (but they no longer pass because they have not been updated
    with the new application logic).
    
    Signed-off-by: Jan Dubois <[email protected]>
    jandubois committed May 8, 2021
    Configuration menu
    Copy the full SHA
    8480c60 View commit details
    Browse the repository at this point in the history
  10. Add bpm term command; same as stop, but don't wait

    Also modify `bpm running` to only print yes/no when stdout is a tty.
    
    Signed-off-by: Jan Dubois <[email protected]>
    jandubois committed May 8, 2021
    Configuration menu
    Copy the full SHA
    f48b916 View commit details
    Browse the repository at this point in the history

Commits on May 10, 2021

  1. Configuration menu
    Copy the full SHA
    a3870a4 View commit details
    Browse the repository at this point in the history

Commits on May 11, 2021

  1. Code review feedback

    Signed-off-by: Jan Dubois <[email protected]>
    jandubois committed May 11, 2021
    Configuration menu
    Copy the full SHA
    3b5b6bb View commit details
    Browse the repository at this point in the history
  2. Run stopProcesses in a goroutine when called from the main goroutine

    The errors channel is unbuffered, so stopProcesses cannot deliver
    errors if it is running from the same goroutine as the receiver.
    
    Signed-off-by: Jan Dubois <[email protected]>
    jandubois committed May 11, 2021
    Configuration menu
    Copy the full SHA
    2776822 View commit details
    Browse the repository at this point in the history
  3. Fix indentation

    Signed-off-by: Jan Dubois <[email protected]>
    jandubois committed May 11, 2021
    Configuration menu
    Copy the full SHA
    87b8fed View commit details
    Browse the repository at this point in the history