Skip to content

Sync: Google's changes up to #259 (ssh --force, example imports) - #18

Merged
arlinamid merged 6 commits into
mainfrom
sync/upstream-2026-11-20
Nov 20, 2026
Merged

arlinamid merged 6 commits into
mainfrom
sync/upstream-2026-11-20

Conversation

@arlinamid

Copy link
Copy Markdown
Owner

Merges googlecolab/google-colab-cli main up to googlecolab#259 into the fork, keeping every fork feature.

Tests: 1288 passed, 11 skipped; ruff clean.

🤖 Generated with Claude Code

DevDesai444 and others added 6 commits November 18, 2026 10:25
* fix: hint `--force` in HTTP 429 error messages

Both 429 variants (with and without session limit) now tell
the user to retry with `--force` when a previous client died.

* feat: add _killStaleSshd helper for force-reconnect

Executes `pkill -P <sshd-parent-pid>` on the runtime kernel to
kill stale per-connection sshd children left behind by a dead
client, then waits 2s for the port to free.

* feat: add --force flag to `colab ssh`

Wires `--force` into all four ssh() code paths (cmd, proxy+cmd,
proxy, interactive). When set, kills stale sshd children on the
runtime before connecting, resolving HTTP 429 when a previous
client died.

Closes googlecolab#242

* test: add --force flag tests for colab ssh

Covers interactive mode, proxy mode, no-force skip, and both
429 message variants mentioning --force.

* fix: prevent kernel leak in _killStaleSshd

Pass kernel_id to ColabRuntime and call rt.stop() in a finally
block so the websocket is always closed. Simplify the kernel
snippet to os.system, unquote the type annotation, and move the
sleep outside the try block. Update --force help text to reflect
that all SSH sessions are killed, not only stale ones.

* refactor: remove dead --force in proxy+cmd child path

_proxy_command() never forwards --force, so force is always False
in the hidden --colab-internal-mode cmd branch.

* refactor: consolidate --force tests into parametrized test

Replace three separate tests + a redundant 429 message test with
one parametrized test covering interactive, proxy-mode, cmd, and
no-force paths. Add a body-coverage test that asserts kernel_id
is forwarded and rt.stop() is called.

* fix: remove time.sleep(2) from _killStaleSshd
…ooglecolab#212)

When the Drive consent is approved for a Google account other than the
one the CLI authenticated as, the propagation POST returns 400. The hook
assumed every failure was an auth challenge, so it printed the raw
response body (HTML), waited for the user to approve again, and retried
forever. If the body was not JSON, parsing raised inside the websocket
hook, which swallows the exception — leaving drive.mount() blocked until
the 600s timeout.

- Parse propagation responses defensively; HTML, plain text, empty and
  non-object bodies become an empty dict instead of raising.
- Only show the consent prompt when the server returns an
  `unauthorized_redirect_uri`; other failures are reported directly.
- Never echo the raw body. Print the status, a short server detail when
  present, and the multi-account guidance (select the account from
  `colab whoami`); log the body to the history file.
- Answer the intercepted kernel request on failure too, so the command
  exits promptly rather than hanging.

Co-authored-by: Seth Troisi <sethtroisi@google.com>
Brings in Google's commits since the last sync:

- googlecolab#254 `colab ssh --force`: kills the runtime's stale SSH sessions
  before connecting. Kept next to the fork's -L/-N/--no-keep-alive
  options; it works on every ssh path of the fork.
- googlecolab#222 example imports annotated after the runtime pip install
  (replaces the fork's own comment for the same thing).
- googlecolab#212 / googlecolab#259 Drive propagation failures: the fork already handles
  these in drive_auth.perform_drive_authorization (defensive parsing,
  multi-account guidance, an error reply to the kernel), so the fork's
  hook and tests are kept; docs/04 says so.

Also lists, in docs/01 TODO, the fork code keyed by endpoint that has to
follow upstream googlecolab#260 (Public API assign/unassign) once it lands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	docs/04_automation_and_utility.md
@arlinamid
arlinamid merged commit 07453de into main Nov 20, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants