Airlock custom patch for pre-reboot tasks execution

To quickly introduce it, airlock is a reboot manager that manages the possibility for a server to request its auto reboot in order to apply an update. It is able to manage a lock on a fleet of machines and give the green light (or not), to Zincati, Airlock is developed by the Coreos team. Here is a little homemade patch to add some logic to do before a reboot. here we run a homemade script to drain the containers of a nomad node before triggering the reboot of the Fedora CoreOS Host.

--- a/internal/server/pre_reboot.go
+++ b/internal/server/pre_reboot.go
@@ -4,7 +4,6 @@ import (
        "context"
        "fmt"
        "net/http"
+       "os/exec"
 
        "github.com/prometheus/client_golang/prometheus"
        "github.com/sirupsen/logrus"
@@ -45,14 +44,6 @@ func (a *Airlock) preRebootHandler(req *http.Request) *herrors.HTTPError {
        preRebootIncomingReqs.Inc()
        logrus.Debug("got pre-reboot request")
 
+       // Run external os command before reboot
+       logrus.Debug("running external script /usr/local/bin/airlockcustomscript.sh")
+       cmd := exec.Command("/usr/local/bin/airlockcustomscript.sh")
+       errcmd := cmd.Run()
+       if errcmd != nil {
+               logrus.Errorln(errcmd)
+       }
+
        if a == nil {
                return &errNilAirlockServer
        }


Let’s hope that it will help someone in future.


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *