archied update install verifies the release zip, checks every binary reports the release, pulls the agent image by digest, backs up the database in-process and stages the binaries before handing off to archied update watchdog in its own process. The watchdog restarts units in release order, requires archied healthy for 120s and otherwise rolls back binaries and image policy, restoring the database only when a migration ran. Boot recovery resumes the frozen watchdog. Deletes scripts/archie-update-install, scripts/archie-update-watchdog, the updater's --from-source and --auto, CommandInstaller, ScriptInstaller and the update-image and update-topology subcommands.
45 lines
1.2 KiB
Go
45 lines
1.2 KiB
Go
package archied
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"flag"
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
|
|
"github.com/samcharles93/archie-core/internal/releaseupdate"
|
|
)
|
|
|
|
// runUpdateCheck serves `archied update check`, printing the release snapshot
|
|
// as JSON. The channel defaults to the environment.
|
|
func runUpdateCheck(args []string, out, stderr io.Writer) int {
|
|
flags := flag.NewFlagSet("update check", flag.ContinueOnError)
|
|
flags.SetOutput(stderr)
|
|
channel := flags.String("channel", envOr("ARCHIE_UPDATE_RELEASE_CHANNEL", "stable"), "stable, next, or exact-pin")
|
|
pin := flags.String("pin", os.Getenv("ARCHIE_UPDATE_PIN"), "exact release version")
|
|
if err := flags.Parse(args); err != nil {
|
|
return 2
|
|
}
|
|
catalog := &releaseupdate.GitHubCatalog{Channel: func(context.Context) (string, string, error) { return *channel, *pin, nil }}
|
|
snapshot, err := catalog.Check(context.Background())
|
|
if err != nil {
|
|
fmt.Fprintln(stderr, err)
|
|
return 1
|
|
}
|
|
encoder := json.NewEncoder(out)
|
|
encoder.SetIndent("", " ")
|
|
if err := encoder.Encode(snapshot); err != nil {
|
|
fmt.Fprintln(stderr, err)
|
|
return 1
|
|
}
|
|
return 0
|
|
}
|
|
|
|
func envOr(key, fallback string) string {
|
|
if value := os.Getenv(key); value != "" {
|
|
return value
|
|
}
|
|
return fallback
|
|
}
|