Refactor Keycloak direct-access-grants into shared helper; harden eval port-forwards; add cluster/dry flags to ibac comparison - #48
Conversation
…l port-forwards; add cluster/dry flags to ibac comparison - Extract the duplicated "enable Direct Access Grants for the rossoctl client" logic from deploy-agent.sh and deploy-benchmark.sh into a new libsh/keycloak-direct-access.sh helper (enable_direct_access_grants). Resolves master-realm admin creds from env vars, the keycloak-initial-admin secret, then admin/admin defaults. - delete-all-deployments.sh now calls the helper too: its token requests use grant_type=password against the rossoctl client, which requires Direct Access Grants to be enabled first. - evaluate-benchmark.sh: detect and clean up stale kubectl port-forwards holding a local port before binding, refusing to touch non-kubectl processes; capture port-forward output to surface the real error on startup failure. - run-ibac-comparison.sh: add --kind/--openshift/--in-cluster cluster flags and a --dry run mode, forwarded to deploy-and-evaluate.sh. Signed-off-by: Yoav Katz <katz@il.ibm.com>
secret mode previously ran a client_credentials grant for the mlflow service account, but mlflow-oidc-auth authorizes reads from its own user DB (not the token's group claim), so the traces API returned 403. Switch to a password (direct-access) grant for a real MLflow user (default: admin), matching how the other deploy scripts authenticate. - analyze-run.sh: obtain the token via a password grant built from keycloak_api_url() and the mlflow-oauth-secret client id/secret; resolve the user password from KEYCLOAK_PASSWORD or the rossoctl-test-user secret; enable Direct Access Grants on the mlflow client first. - Default MLFLOW_LOCAL_PORT to 8085: 8080 is served by the kind ingress for keycloak.localtest.me (127.0.0.1), so binding there would shadow Keycloak and send the token request to MLflow. - Detect the downloader's exit 75 (token rejected) via PIPESTATUS and print an actionable hint (log into the MLflow UI once), re-echoing the original invocation. - download_mlflow_traces.py: raise MLflowAuthError on 401/403 and exit 75 so the wrapper can distinguish "no MLflow user record yet" from a generic failure. - keycloak-direct-access.sh: parameterize enable_direct_access_grants with an optional CLIENT_ID (defaults to rossoctl) so analyze-run can target the mlflow client. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Yoav Katz <katz@il.ibm.com>
Optionally tee the raw traces JSON from download_mlflow_traces.py into a timestamped file under the given directory before piping to the analyzer, so the saved copy and the analysis come from the same download. Off by default; the directory is created if needed. Also drop a stray leftover `env` debug line that dumped the full environment before the download pipeline. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Yoav Katz <katz@il.ibm.com>
|
Tested this on a local Kind cluster ( The core fix is confirmedI proved the
So the password-grant prerequisite really was broken on What else I verifiedKeycloak helper — works against live Keycloak, and the flag genuinely persists (checked via the admin API, not just an HTTP 200 on the PUT). All three failure paths exit 1 with a useful diagnostic: wrong admin password, nonexistent client, unreachable Keycloak. Port-forward hardening — both branches behave correctly:
Refactor fidelity — Bug:
|
clawgenti
left a comment
There was a problem hiding this comment.
This PR introduces significant improvements to MLflow authentication, error handling, and script robustness within the A2A runner. It also adds better cluster deployment options. All checks pass. Ready for human review.
Reviewed by clawgenti using the github-pr-review skill
Summary
deploy-agent.shanddeploy-benchmark.sh. It now lives in a newlibsh/keycloak-direct-access.shasenable_direct_access_grants, which resolves master-realm admin creds from env vars → thekeycloak-initial-adminsecret →admin/admindefaults, and exits with a clear diagnostic on any failure.delete-all-deployments.sh. Its token requests usegrant_type=passwordagainst the rossoctl client, which requires Direct Access Grants to be enabled first. It now sources the helper and calls it before requesting a token.evaluate-benchmark.shport-forwards. Before binding a local port, detect a stale (or suspended) leftoverkubectl port-forwardholding it and clean it up — refusing to touch any non-kubectl process. Port-forward output is captured to a temp file so the real error is surfaced when startup fails; temp files are removed on cleanup.run-ibac-comparison.sh. New--kind/--openshift DOMAIN/--in-clustercluster flags and a--dryrun mode, all forwarded verbatim todeploy-and-evaluate.sh(which already validates and supports them).Testing
bash -nsyntax-checks pass on all six changed scripts.deploy-and-evaluate.shaccepts the forwarded--dry,--kind,--openshift, and--in-clusterflags.