hecate(startup): make flux reconcile non-blocking and fast
This commit is contained in:
parent
a7faf8f09a
commit
08276a3973
@ -445,27 +445,39 @@ func (o *Orchestrator) resumeFluxAndReconcile(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if o.runner.CommandExists("flux") {
|
||||
commands := [][]string{
|
||||
{"reconcile", "source", "git", "flux-system", "-n", "flux-system", "--timeout=3m"},
|
||||
{"reconcile", "kustomization", "core", "-n", "flux-system", "--with-source", "--timeout=5m"},
|
||||
{"reconcile", "kustomization", "helm", "-n", "flux-system", "--with-source", "--timeout=5m"},
|
||||
{"reconcile", "kustomization", "traefik", "-n", "flux-system", "--with-source", "--timeout=5m"},
|
||||
{"reconcile", "kustomization", "vault", "-n", "flux-system", "--with-source", "--timeout=10m"},
|
||||
{"reconcile", "kustomization", "postgres", "-n", "flux-system", "--with-source", "--timeout=10m"},
|
||||
{"reconcile", "kustomization", "gitea", "-n", "flux-system", "--with-source", "--timeout=10m"},
|
||||
}
|
||||
for _, c := range commands {
|
||||
if _, err := o.run(ctx, 3*time.Minute, "flux", c...); err != nil {
|
||||
o.log.Printf("warning: flux command failed (%s): %v", strings.Join(c, " "), err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
now := time.Now().UTC().Format(time.RFC3339)
|
||||
if _, err := o.kubectl(
|
||||
ctx,
|
||||
25*time.Second,
|
||||
"-n", "flux-system",
|
||||
"annotate",
|
||||
"kustomizations.kustomize.toolkit.fluxcd.io",
|
||||
"--all",
|
||||
"reconcile.fluxcd.io/requestedAt="+now,
|
||||
"--overwrite",
|
||||
); err != nil {
|
||||
o.log.Printf("warning: annotate kustomizations for reconcile failed: %v", err)
|
||||
}
|
||||
if _, err := o.kubectl(
|
||||
ctx,
|
||||
25*time.Second,
|
||||
"-A",
|
||||
"annotate",
|
||||
"helmreleases.helm.toolkit.fluxcd.io",
|
||||
"--all",
|
||||
"reconcile.fluxcd.io/requestedAt="+now,
|
||||
"--overwrite",
|
||||
); err != nil {
|
||||
o.log.Printf("warning: annotate helmreleases for reconcile failed: %v", err)
|
||||
}
|
||||
|
||||
now := time.Now().UTC().Format(time.RFC3339)
|
||||
_, err := o.kubectl(ctx, 20*time.Second, "-n", "flux-system", "annotate", "kustomizations.kustomize.toolkit.fluxcd.io", "--all", "reconcile.fluxcd.io/requestedAt="+now, "--overwrite")
|
||||
return err
|
||||
if o.runner.CommandExists("flux") {
|
||||
sourceCmd := []string{"reconcile", "source", "git", "flux-system", "-n", "flux-system", "--timeout=60s"}
|
||||
if _, err := o.run(ctx, 75*time.Second, "flux", sourceCmd...); err != nil {
|
||||
o.log.Printf("warning: flux command failed (%s): %v", strings.Join(sourceCmd, " "), err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *Orchestrator) kubectl(ctx context.Context, timeout time.Duration, args ...string) (string, error) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user