Repository navigation
Say what agyn local is doing while it does it - #70
Merged
Merged
Conversation
A first `agyn local start` ended with an error and exit 0. Credential provisioning ran the moment the three endpoints answered, which is before the platform has provisioned its own system organization, so the step failed, printed a recovery command, and the run carried on to print endpoints and succeed. The condition the wait tested was not the condition the next step needed, so readiness gains a second signal -- the system organization declaration carrying an assigned id, the same read `agyn local credentials` already performs, moved from a step that fails when early into the thing being waited for. Provisioning then reuses the id the wait read rather than asking again. Everything else in the group reported itself as the tooling underneath phrased it: eight identical AuthorizationPolicy warnings, klog lines with a PID in them, a Helm release listing, a raw byte counter, and three silent minutes that are indistinguishable from a hang. So the long operations are steps now -- animated on a TTY with what they are waiting on, printed once on completion anywhere else -- and limactl, helm and kubectl write to ~/.agyn/local/last-run.log, whose tail a failing step prints. --debug still streams them, and turns the animation off rather than redrawing over it. The upgrade script's stdout becomes a marker protocol and everything else it runs goes to stderr, which is what makes that split possible from inside the VM. It also learns the version it is moving to before it moves, so a release already at the newest chart is reported as such instead of upgraded to itself and reported as a new revision -- and the ingress-port repair is skipped with it, since nothing reverted the port when nothing was upgraded. Its namespace default was still the pre-rename `platform`. Preflight becomes one set of checks with an install offer behind it, reached from `start` and from `doctor --fix`. Two of the checks are new because both are failures the presence check let through: a tool older than the image's lima.yaml needs, which fails later inside limactl naming neither the version nor the fix, and free disk space, which fails halfway through a 4.6 GB decompression after the download has already run. The offer follows --install-ca: prompted on a TTY, --install-deps and --no-install-deps either way, never implied by -y, and it never installs a package manager. isTerminal read a character device rather than a terminal, so /dev/null passed: a command with stdin redirected prompted, took EOF for the default answer, and proceeded -- the opposite of the rule it existed to enforce. The endpoint list at the end becomes one link to the console. Three URLs are a menu, and what a finished install owes the reader is a next step; `agyn local status` still prints them all.
The port prompt fired on every first run, including a second VM's -- whose port had just been chosen for being free. A question with one sensible answer in front of every install is not a wizard step, it is a keypress. It now appears only when the port this VM would take is not available, which is the case it was written for. "Ingress port" named the component that terminates the connection. Nobody outside the cluster asked about an ingress; what they are choosing is where the platform answers, so the prompt says so and shows the URL it is completing. The CA question was a yes/no whose no is a dead end: someone who will not hand sudo to a CLI declined and was left with a browser warning and no certificate, though `agyn local ca export` existed the whole time. Three answers now, on the arrow-key picker the group already uses -- install, export, skip -- and export writes the PEM into the working directory and says where. The picker returns a position and the caller switches on a constant, so the rows are built by indexing with those constants and a test holds the two together. A row inserted in the wrong place would install a CA on the machine of someone who chose to skip, and nothing in the output would say so.
set-bootstrap-token.sh and set-ingress-port.sh move here from the image and are piped into the guest, as upgrade-platform.sh already was. The image's copies are removed in bundle-vm. The reason is the one written beside upgrade-platform.sh: a script in the image can only be corrected by building a new image and recreating the VM, which is what `upgrade` exists to avoid. This week's openziti fix could not reach one existing VM, and upgrade-platform.sh had already been copied here and already diverged from an image copy nothing invoked any more. The token stops being an argument. It was $1 to a process in the guest, so a per-install credential sat in a process list any user of that guest could read. It now goes to a script staged 0700 on the guest's tmpfs, on stdin, and the script fails loudly on an empty read rather than logging "no token supplied" and exiting 0 -- that path would have recorded a profile holding a credential the Gateway never received, surfacing later as a 401 with nothing pointing back. The ingress-port step moves out of the upgrade script into the command, which is the side that knows which port this host forwards. The script says whether anything moved and the CLI does the repair, so no script has to know about another. Two upgrade behaviours found by running it. A release left in flight by an interrupted upgrade is invisible to `helm list` and refuses every later attempt with the lock rather than the way out, so its status is read directly and reported with `--resume`, which drops the in-flight revision and continues forward -- not backward, which would move already-upgraded workloads further than the one version of backward compatibility migrations promise. And under `set -e` with `pipefail`, every `$(helm ... | sed ...)` reader was a place the whole run could die: `helm status` fails routinely for a release that is not installed, and it took the script down mid-recovery. The script is now covered by tests that run it against stub tools, which is what found the second of those.
Struct literal alignment, left behind by an earlier change and picked up by a gofmt -w over the package. No behaviour in it.
Every command truncated the same ~/.agyn/local/last-run.log, so two running at once wrote into each other's. It showed up as a failure report that made no sense: an upgrade that failed printed the tail of the log, and the tail was a delete running beside it powering a VM down -- which reads as the upgrade having stopped the VM it was upgrading. A log belongs to a VM, like its CA, its profile and its kubeconfig context do. ~/.agyn/local/logs/<vm>.log.
On a non-default port, pointing the browser-facing URLs at it restarts most of the platform: two helm upgrades of the OpenZiti charts with --wait, seven deployments re-envd and rolled, Keycloak restarted and its four realm clients rewritten through kcadm, then a rollout wait on each. Minutes, under a step labelled 'Configuring profile' whose profile write is the trivial part of it. The script already logs each phase. Those lines now go to the run log on stderr and to the CLI on stdout as markers, so the step's detail follows the work instead of standing still -- which is the difference between a long step and a hung one. On the default port none of this runs and the step stays a second long, which is why only a second VM ever saw it.
'Configuring profile local-test' covered installing a credential into the Gateway, moving the platform to another port, and writing a file on this machine. Only the last one is a profile, and it is the one that takes no time -- so minutes of cluster reconfiguration ran under the name of the fastest part, and 'moving the OpenZiti overlay' appeared as something configuring a profile does. Now: installing the token, pointing the platform at the port, configuring the profile. Each says what it is doing while it does it -- the token script reports its phases the same way the port script does, because a token that changed restarts the Gateway and waits on its rollout. Reads that used to run first for fail-fast now sit in the third step. Nothing is lost: the organization id is handed over by the readiness wait that already read it, and the two VM steps are idempotent, so a CA extract that fails after them costs a repeat of work that changed nothing.
On a VM serving any port but the baked 2496, every upgrade deadlocked until Helm's 15-minute timeout. An upgrade rewrites the browser-facing URLs back to the chart's default port, because they were set with kubectl set env rather than through the release. The workloads holding those URLs -- gateway, networks, ziti-management, agents-orchestrator -- then crash-loop against a port that publishes nothing. helm upgrade --wait waits for exactly those to become Ready, and the repair that would let them is the step after it. Each side waiting on the other. So the upgrade no longer passes --wait: Helm returns once the manifests are applied, the CLI points the platform back at the host's port, and only then waits for the rollout. --timeout still bounds the chart's hooks. The wait is better where it now is. Helm reports a timeout as 'timed out waiting for the condition'; the CLI's readiness wait names the workloads that are behind and updates as they land. Found by running an upgrade on a second VM, which is the only place it happens: on 2496 there is nothing to revert and nothing to repair.
The release's values named 2496 on a VM serving 2497 -- in eighteen service URLs and in keycloak.wiring.ingressHostPort.port -- because nothing had ever written the host's choice into them. `agyn local start` patched the rendered Deployments instead, so every upgrade re-applied the baked port, every workload holding those URLs crash-looped against a port publishing nothing, and a second pass had to patch them back. Two rollouts of most of the platform, and a window between them long enough for Kubernetes to back off to five-minute retries. That, not the work, was the eleven minutes. The upgrade now derives an overlay from the release's own values, replacing the port they currently name with the host's, and hands it to Helm. One rollout, rendered right the first time. Derived rather than listed: nineteen keys carry it today and a twentieth added upstream would be missed silently. Only the exact stale number is replaced, so a service port that happens to appear is never touched, and when the values already agree no overlay is produced at all -- which is every VM on the default port. Values that name the wrong port are also their own reason to upgrade now. Skipping on a matching chart version left the release one re-render away from reverting to a port the VM does not serve. Measured on a second VM: a values-only correction took 20s with no workload restarted and the platform never unready, against eleven minutes before.
Profiled a real port move, 84s end to end: overlay 19s, ziti-management 13s, keycloak restart 29s, keycloak realm clients 12s, remaining rollouts 10s. Two things follow, and neither is the one I expected. The overlay phase logs once and then runs two silent helm upgrades with --wait, so the detail line stands still for nineteen seconds -- the same long-versus-hung problem the steps exist to solve, one level down. Each upgrade now says which half of the overlay it is on. The realm client update started a JVM per kcadm call, nine of them, at 1.3s each. The client ids are all in one listing, so it fetches them once: nine launches become six. Column order verified against the running realm, because a mis-parse here skips every client and leaves login broken while reporting success. What is NOT worth tuning, measured rather than assumed: both overlay pods terminate in 1s and start in 2s and 12s, so terminationGracePeriodSeconds and the Recreate strategy are worth nothing. The chart pulls are 0.7s together. restart_mounters touches no deployments at all. The rest is inherent. On a fresh VM the whole 84s restarts a platform that finished starting thirty seconds earlier, because the image bakes every URL with port 2496 and a VM on any other port has to rewrite its way out. Reordering cannot help: the workloads are running before the CLI learns the port.
You were right that killing a pod and starting a new one is seconds. It is: 1s to terminate, 2s for the overlay controller, 12s for the router. None of the 80 was pod lifecycle. It was CrashLoopBackOff. The script restarted about twenty interdependent services at once, Keycloak among them, so every OIDC consumer came up against an issuer that was itself restarting, exited 1, and was backed off at 10s, 20s, 40s. The counters said so plainly: gateway 3 restarts on exit 1, media-proxy 3, chat and files and images 4, groups 5, metering 6. The gateway took 52s to become ready and spent almost none of it starting. The comment above that block already said Keycloak had to go first; only the waits were ordered, never the restarts. Three changes, each measured on a real port move: Keycloak is restarted alone and waited for before anything that fetches discovery from it is touched. Backoff gone: all seven consumers now roll out together in 12-14s. On its own this did not help the total -- the crash loops had been running in parallel with the Keycloak wait, so they were largely free -- but it removes the failure rather than hiding it. Keycloak's restart is kicked off next to the overlay move instead of after it. Nothing about the issuer depends on the overlay, and it is ~28s of waiting that now happens while the overlay is moving. This is where the time actually went. The router's helm upgrade no longer waits, because repoint_router_endpoints restarts that same router seconds later to clear its endpoint cache. Waiting for a pod that is about to be replaced is waiting twice for one rollout. 84s -> 41s, verified on the way out and back: overlay advertising the new port, zero not-ready workloads, all three endpoints answering. Not worth touching, measured: terminationGracePeriodSeconds (pods stop in 1s), the Recreate strategy, the chart pulls (0.7s), restart_mounters (touches nothing).
The bundle is switching to Dex, and this script was Keycloak all the way through: it composed the issuer as auth./realms/<realm>, set KC_HOSTNAME on a deployment named keycloak, and drove kcadm to rewrite realm clients. On a Dex image the first of those runs against a deployment that does not exist, and `set -e` ends the port move before the overlay has been touched -- so every VM on a non-default port fails at start. The issuer is now read from the Gateway and has only its port changed. Keycloak serves auth./realms/<realm> and Dex serves auth. with no path at all, so composing it here means knowing which provider is deployed and being wrong the day a third one is. The install already holds the right string. The provider steps follow whichever deployment exists. Keycloak takes a hostname env and its realm clients rewritten through kcadm; Dex holds its issuer and redirect URIs in a ConfigMap it re-reads on every start, so the port moves by rewriting that and restarting -- no admin API, no client-by-client update. An install pointed at an external issuer has neither, and nothing is restarted for it. Verified on a Keycloak VM, which is the path that exists to test: the issuer derived as auth.agyn.dev:2498/realms/agyn on the way out and 2497 on the way back, keeping the realm path this script no longer knows about. The Dex branch is unexercised until an image ships with it.
A divider, then the console link, then the accounts to sign in with. The link alone is half an answer: a fresh VM has two static logins and nothing on screen said so. Printed only when the VM runs the shipped Dex config, checked by looking for both accounts in it. Keycloak's are different, an install pointed at its own issuer has none of ours, and a VM whose dex.users were replaced would be handed credentials that do not work -- each worse than printing none. The passwords are bcrypt hashes in the chart, so they cannot be read back from the VM; what is printed is what the chart ships, which is why the check is that the chart's accounts are still the ones in place. Rendering the block found a bug in the steps that report rather than run: Report, Skipped and Failed built a Step with no start time, so every one of them ended in a duration measured from the zero time -- '153722867m16s' next to 'Trusting the CA'. Unexercised until now because both callers are on the fresh-VM path. There is a test, and a preview that prints the block.
Done("") kept whatever detail was showing, so a step that spent nine seconds
reporting where it had got to ended on the final frame of that: 'Pointing the
platform at port 2497 agyn-sandboxes -> https://sandboxes.agyn.dev:2497'. The
title already said it better.
Empty now means no detail. Callers with something to say still say it -- the
profile step keeps its organization id, the upgrade keeps its version
transition, which it passes explicitly.
Also stops the port script's closing 'done' from being a progress line. It is
for whoever reads the log; on screen it became the step's last word.
The branch added yesterday rewrote Dex's ConfigMap and restarted it. Helm renders that ConfigMap from dex.externalUrl, so the next upgrade puts the baked port back -- the same mistake as writing the port over rendered Deployments instead of into the values, which is what made an upgrade restart the platform twice. The upgrade's overlay already covers it: dex.externalUrl is a URL on the platform's domain, so the port in it moves with every other one. What this leaves is start, which changes the port without running an upgrade at all. That wants the same treatment -- a values-only upgrade rather than kubectl set env across nine deployments -- and is not this commit.
0.56.0 made dex the provider an install gets, on auth. -- the hostname keycloak already had. A release installed before it names keycloak, and reusing those values put both on auth., which the chart refuses to render. Every upgrade from here on failed on a VM that had ever been installed, with the guard's message and no way past it. So the upgrade migrates rather than fails: keycloak off, dex on at auth. and this host's port, and the issuer URLs lose the realm path keycloak served and dex does not. It is the same edit by hand that moved a VM over, done where every VM will meet it. Also fixes the port rewrite, which replaced one stale number found in the first URL it saw. A release can hold several -- a VM moved to 2497 still had keycloak.appOrigins on 2496 -- so every URL on the platform's domain now takes the host's port by shape, and only a bare port: line is matched against the old number. And the markers now go to a duplicate of stdout taken at the top. A function that emitted one from inside $(...) had it captured as part of the value: this migration's own note was read as a filename, and the upgrade died with 'open AGYN|note|moving this install...: no such file or directory'. Verified: a fresh 0.42.1 keycloak VM upgraded to 0.57.0 in 24s and came back on dex -- issuer https://auth.agyn.dev:2497, no keycloak deployment, all three endpoints healthy.
Sign-in failed on the migrated VM with nothing in the browser but "We couldn't sign you in". The issuer was right; every redirect URI was on 2496 while the VM served 2497. Dex matches redirect URIs exactly -- there is no wildcard form -- so the callback was refused and the app could only say that. The migration set the issuer and the routing host and left appOrigins to the chart, whose default is the baked port. So the four URLs are set on every upgrade rather than written into the values once: a VM migrated before this existed is corrected instead of keeping the default forever. Which meant the skip had to learn about it. A release already on the newest chart was skipped without looking, and the callbacks are wrong independently of the version -- so a mismatch between the running Dex config and this host's port is now its own reason to upgrade, like the values naming a port the VM does not serve. Verified on the migrated VM: 0.57.0 to 0.57.0 in 23s, callbacks now on 2497.
Two bugs, one visible and one that hid it. The accounts were printed as "admin / admin". Dex authenticates a static user by email and nothing else, so signing in that way stores an account under "admin" — and the cluster-admin declaration for admin@<domain> then has nothing to resolve to. The sign-in works, the role never arrives, and the Console offers no clue why. The aliases that made the bare form work at all are gone from the chart, so now it simply fails. Printed by address. None of which had been seen, because the lookup read a ConfigMap named "dex" and the chart's is "dex-config". Nothing found is how this reports "not the shipped provider", so the block never printed on any VM -- including the one I checked it on and called correctly suppressed.
Moving an install to dex changes who issues tokens and therefore which accounts exist. Whoever ran the upgrade is signed out of a provider that is gone, with credentials that no longer resolve, and nothing on screen said so -- the sign-in block only ever printed at the end of a start. So the script reports the migration as its own marker rather than only a note, the upgrade returns it, and the command closes with the console and the accounts when it happened. Keyed on the migration rather than a version number: the condition is a release that still names keycloak, which is what actually decides it. The block is one function now, shared with start, so the two cannot drift.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rewrites the output and the failure modes of the
agyn localgroup, and carriesthe platform's move to Dex through an upgrade.
Output
Long operations report as steps: animated on a TTY with what they are waiting
on, printed once when piped.
limactl,helmandkubectloutput goes to aper-VM log the failing step names;
--debugstreams it instead. A start endswith one call to action — the console, plus the accounts to sign in with when
the VM runs the shipped provider.
Failures that were reported as success
organization, so a first start printed an error and exited 0. Readiness now
includes that id.
isTerminalaccepted any character device, so/dev/nullread as interactive:a redirected stdin prompted, took EOF for the default, and proceeded.
helm list. Detected, and continued forward with--resume— not rolled back,which would move already-upgraded workloads outside the one version of
backward compatibility migrations promise.
Upgrades
The host's port is written into the release values instead of over the rendered
workloads, so an upgrade renders the right port the first time: one rollout
instead of two, and no window where services dial a port that publishes nothing.
Helm no longer waits for pods whose configuration the upgrade just invalidated —
that deadlocked every VM not on the default port until Helm's timeout.
An install still naming Keycloak is migrated to Dex, since 0.56.0 makes both
claim
auth.and the chart refuses to render that.Port moves
84s to 41s, measured. The cost was CrashLoopBackOff, not pod lifecycle:
restarting ~20 interdependent services at once put every OIDC consumer against
an issuer that was itself restarting. Keycloak is restarted first and waited
for, and its restart runs alongside the overlay move.
Preflight
Host tools are checked for version as well as presence, with disk space and
ports, and offered for installation — prompted on a TTY,
--install-deps/--no-install-depseither way, never implied by-y.Scripts
set-bootstrap-token.shandset-ingress-port.shmove out of the image andship here, as
upgrade-platform.shalready did: a script in the image can onlybe corrected by rebuilding it and recreating the VM. The bootstrap token stops
being a command-line argument on the way.
Companion changes in
bundle-vm(image stops carrying them) andplatform-charts(Dex onauth., enabled by default).