hecate(startup): make flux reconcile non-blocking and fast

This commit is contained in:
Brad Stein 2026-04-04 06:56:56 -03:00
parent a7faf8f09a
commit 08276a3973

View File

@ -445,27 +445,39 @@ func (o *Orchestrator) resumeFluxAndReconcile(ctx context.Context) error {
return err return err
} }
if o.runner.CommandExists("flux") { now := time.Now().UTC().Format(time.RFC3339)
commands := [][]string{ if _, err := o.kubectl(
{"reconcile", "source", "git", "flux-system", "-n", "flux-system", "--timeout=3m"}, ctx,
{"reconcile", "kustomization", "core", "-n", "flux-system", "--with-source", "--timeout=5m"}, 25*time.Second,
{"reconcile", "kustomization", "helm", "-n", "flux-system", "--with-source", "--timeout=5m"}, "-n", "flux-system",
{"reconcile", "kustomization", "traefik", "-n", "flux-system", "--with-source", "--timeout=5m"}, "annotate",
{"reconcile", "kustomization", "vault", "-n", "flux-system", "--with-source", "--timeout=10m"}, "kustomizations.kustomize.toolkit.fluxcd.io",
{"reconcile", "kustomization", "postgres", "-n", "flux-system", "--with-source", "--timeout=10m"}, "--all",
{"reconcile", "kustomization", "gitea", "-n", "flux-system", "--with-source", "--timeout=10m"}, "reconcile.fluxcd.io/requestedAt="+now,
} "--overwrite",
for _, c := range commands { ); err != nil {
if _, err := o.run(ctx, 3*time.Minute, "flux", c...); err != nil { o.log.Printf("warning: annotate kustomizations for reconcile failed: %v", err)
o.log.Printf("warning: flux command failed (%s): %v", strings.Join(c, " "), err) }
} if _, err := o.kubectl(
} ctx,
return nil 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) if o.runner.CommandExists("flux") {
_, err := o.kubectl(ctx, 20*time.Second, "-n", "flux-system", "annotate", "kustomizations.kustomize.toolkit.fluxcd.io", "--all", "reconcile.fluxcd.io/requestedAt="+now, "--overwrite") sourceCmd := []string{"reconcile", "source", "git", "flux-system", "-n", "flux-system", "--timeout=60s"}
return err 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) { func (o *Orchestrator) kubectl(ctx context.Context, timeout time.Duration, args ...string) (string, error) {