Skip to content

fix(infra): read the default branch at origin, not the working tree - #5181

Merged
dan-petty merged 2 commits into
mainfrom
fix/5162-read-the-default-branch-at-origin
Nov 12, 2026
Merged

dan-petty merged 2 commits into
mainfrom
fix/5162-read-the-default-branch-at-origin

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

devops infra onboard read the working tree of the local checkout. On dan-petty/homelab, a checkout on an old branch made row 9 report host key checks off, while origin/main has them on (homelab #24). The profile of a repo is read at its default branch, the trusted ref (#4627).

A shared reader, infra/repo_tree.py, fetches origin with the credential of the GitHub session and no prompt, takes the commit of refs/remotes/origin/HEAD, exports it with git archive into a private folder, unpacks it with the data filter of tarfile, and removes the folder after. It changes no file and no branch of the checkout. Onboarding runs every read in the export, prints the default branch and its commit, and adds one line when the checkout is at another commit. status, plan and apply use the same reader.

Closes #5162

Change: openspec/changes/archive/2026-11-12-5162-read-the-default-branch-at-origin/

devops infra onboard read the working tree of the local checkout. A checkout
on an old branch gave rows for that branch: on dan-petty/homelab, row 9
reported host key checks off, while origin/main has them on.

A shared reader, infra/repo_tree.py, fetches origin with the credential of
the GitHub session, takes the commit of refs/remotes/origin/HEAD, exports
it with git archive into a private folder and removes the folder after.
Onboarding reads every file and runs each Ansible read in the export. It
prints the default branch and the commit that it read, and one more line
when the checkout is at another commit. status, plan and apply use the
same reader.

Closes #5162
@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/infra Docker container images, DevContainers, and infrastructure tooling labels Nov 12, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Fail-to-pass

uv run devops ci fail-to-pass --base origin/main exited 0: 8 tests fail on base and pass on head. tests/infra/test_repo_tree.py does not collect on base, because infra/repo_tree.py is new.


  errored on base: tests.infra.test_repo_tree (collection failure)
  failed on base: tests.commands.test_infra_onboard::test_onboard_prints_one_row_for_each_check (AssertionError: assert [+ received] == [- snapshot])
  failed on base: tests.commands.test_infra_onboard::test_dry_run_starts_no_process_and_writes_nothing (AssertionError: assert [+ received] == [- snapshot])
  failed on base: tests.commands.test_infra_onboard::test_onboard_names_the_commit_it_reads_and_a_checkout_on_another_branch (AssertionError: assert ['1. The Ansi... its source)'] == ['Reads origi...origin/main.'])
  failed on base: tests.infra.test_onboard::test_a_failed_fetch_names_the_reason_of_git_with_no_credential (Failed: DID NOT RAISE InfraReadError)
  failed on base: tests.infra.test_onboard::test_an_export_with_a_link_out_of_the_tree_is_refused (Failed: DID NOT RAISE InfraReadError)
  failed on base: tests.infra.test_onboard::test_a_checkout_that_records_no_default_branch_is_refused (Failed: DID NOT RAISE InfraReadError)
  failed on base: tests.infra.test_onboard::test_the_report_fetches_origin_and_reads_only_local_tools (AssertionError: assert [('ansible-co....0.2.4'), ...] == [('git', 'fet...s.yaml'), ...])
  failed on base: tests.infra.test_onboard::test_the_report_reads_the_default_branch_not_the_working_tree (AssertionError: assert [(1, <Onboard...esent'>), ...] == [(1, <Onboard...esent'>), ...])
8 failed on base (8 failed and 32 passed in tests/commands/test_infra_onboard.py, tests/infra/test_onboard.py, tests/infra/test_repo_tree.py; 1 errored).

Live run on dan-petty/homelab (2026-11-12)

The checkout was on feat/node-crash-capture at 6b5a7fa. The command read origin/main at f5961bd. Row 9 is now present. After the run the checkout kept its branch and git status was clean.

uv run devops infra onboard dan-petty/homelab --path <checkout> (exit 1: rows 8 and 13 are missing on origin/main):


# Onboarding of dan-petty/homelab at <checkout>
Reads origin/main at f5961bd2da6856e31914037c0f048337989dfbe7, not the working tree of the checkout.
The checkout is on the branch feat/node-crash-capture at 6b5a7fa70022cffbdc09ff0e5c6e82ac7916b864, not on origin/main.
1. The Ansible tool environment is installed: present (ansible-core 2.22.0)
2. The project profile of the repository has the type ansible-k8s: listed (detected: ansible.cfg; the repository has no .devops/project.toml. These values differ from the type template.)
   - extends = "ansible-k8s" (detected: ansible.cfg)
   - ansible.inventory = ["ansible/inventory/hosts.yaml"] (detected: ansible.cfg)
   - ansible.playbook_dir = "ansible/playbooks" (detected: ansible/playbooks)
   - ansible.roles_path = ["ansible/roles"] (detected: ansible.cfg)
   - kubernetes.dir = "k8s" (detected: k8s)
   Step: Commit .devops/project.toml with these values, so that the profile does not change when a file that detection reads changes.
3. ansible.cfg is at the root of the repository: present
4. The inventory names hosts: present (6 hosts in 6 groups)
   - debian_nodes: 4 hosts
   - gpu_nodes: 4 hosts
   - k3s_agent: 3 hosts
   - k3s_cluster: 4 hosts
   - k3s_server: 1 host
   - offline: 2 hosts
5. The inventory has the group offline for hosts out of service: present (2 hosts out of service)
   - bombas.lan
   - workhorse.lan
6. The repository holds playbooks: present (17 playbooks in ansible/playbooks)
   - ansible/playbooks/00_bootstrap_user.yaml
   - ansible/playbooks/01_bootstrap.yaml
   - ansible/playbooks/02_nvidia.yaml
   - ansible/playbooks/03_k3s.yaml
   - ansible/playbooks/04_gpu_validation.yaml
   - ansible/playbooks/05_cluster_maintenance.yaml
   - ansible/playbooks/06_cluster_backup.yaml
   - ansible/playbooks/07_cluster_upgrade.yaml
   - ansible/playbooks/08_mount_nvme.yaml
   - ansible/playbooks/09_system_update.yaml
   - ansible/playbooks/10_rolling_restart.yaml
   - ansible/playbooks/11_secrets_encryption.yaml
   - ansible/playbooks/12_move_ollama_models.yaml
   - ansible/playbooks/13_crash_capture.yaml
   - ansible/playbooks/configure_registries.yaml
   - ansible/playbooks/health_check.yaml
   - ansible/playbooks/site.yaml
7. The repository holds roles: present (5 roles)
   - common
   - k3s_agent
   - k3s_server
   - k8s_gpu
   - nvidia
8. collections/requirements.yml pins each collection: missing (collections/requirements.yml is not in the repository. The plays use ansible.posix, community.general, kubernetes.core.)
   Step: Add collections/requirements.yml, with an exact version for each collection that the plays use.
9. Host key checks are on: present
10. ~/.ssh/known_hosts holds the key of each host in service: present (4 hosts in service)
11. A devops ssh key of the prefix ansible exists: present
   - ansible-id_ed25519-20260909
12. The kube context of the repository is in the kubeconfig: present
   - homelab-k3s
13. A CI workflow checks the repository: missing
   Step: Add a CI workflow that runs ansible-lint and ansible-playbook --syntax-check on each playbook.
14. Each host in service names its node service (devops_infra_node_service): listed (4 hosts in service do not set devops_infra_node_service.)
   - condor.lan
   - gemini.lan
   - hawk.lan
   - hog.lan
   Step: Set devops_infra_node_service, such as k3s-agent, on each host that runs a Kubernetes node.
15. No task runs for real in check mode (check_mode: false): listed (14 tasks run for real when a plan runs the playbook in check mode.)
   - ansible/playbooks/11_secrets_encryption.yaml:40 Read secrets encryption status
   - ansible/playbooks/11_secrets_encryption.yaml:54 Count Secrets still stored as plaintext
   - ansible/playbooks/12_move_ollama_models.yaml:84 Check if the model store is already a mount point
   - ansible/playbooks/12_move_ollama_models.yaml:155 Measure the source of the copy
   - ansible/playbooks/12_move_ollama_models.yaml:163 Measure the target folder
   - ansible/playbooks/12_move_ollama_models.yaml:212 Copy the store, first pass (the pods keep running)
   - ansible/playbooks/12_move_ollama_models.yaml:225 Copy the store, last pass (--delete)
   - ansible/playbooks/12_move_ollama_models.yaml:284 Check if a pod still uses the old store
   - ansible/playbooks/tasks/k3s_node_reboot.yaml:3 Read Kubernetes node readiness and scheduling state
   - ansible/playbooks/tasks/k3s_node_reboot.yaml:31 Wait for K3s service to become active
   - ansible/playbooks/tasks/k3s_node_reboot.yaml:41 Wait for node to report Ready in Kubernetes
   - ansible/playbooks/tasks/k3s_node_reboot.yaml:54 Verify NVIDIA driver and GPUs after reboot
   - ansible/playbooks/tasks/k3s_node_reboot.yaml:67 Read running kernel
   - ansible/roles/k3s_server/tasks/main.yaml:30 Wait for K3s node to report Ready
   Step: Make sure that each of these tasks only reads.
16. No Makefile target drains, restarts or reboots a node: listed (16 targets change a node outside devops.)
   - drain-agent
   - uncordon-agent
   - restart-agent
   - drain-condor
   - uncordon-condor
   - restart-condor
   - drain-hawk
   - uncordon-hawk
   - restart-hawk
   - drain-bombas
   - uncordon-bombas
   - restart-bombas
   - drain-gemini
   - uncordon-gemini
   - restart-gemini
   - rolling-restart
   Step: devops owns the node life cycle: cordon, drain, restart and reboot. Move these steps out of the Makefile.
17. The repository is in infra.repos: present (agent access full)

@dan-petty
dan-petty marked this pull request as ready for review November 12, 2026 18:10
@dan-petty
dan-petty merged commit 6ef4336 into main Nov 12, 2026
25 checks passed
@dan-petty
dan-petty deleted the fix/5162-read-the-default-branch-at-origin branch November 12, 2026 18:22
dan-petty pushed a commit that referenced this pull request Nov 12, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.122.0](v0.121.1...v0.122.0)
(2026-11-12)


### Features

* **docs:** move the docs site to Zensical with a full nav and version
([#5183](#5183))
([64b7199](64b7199))
* **infra:** show the hosts of an infra repo with node state
([#5188](#5188))
([ed1d2e2](ed1d2e2))
* **roadmap:** eval grades prints the grade of each workflow
([#5189](#5189))
([aeb33d6](aeb33d6))


### Bug Fixes

* **infra:** read the default branch at origin, not the working tree
([#5181](#5181))
([6ef4336](6ef4336))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/infra Docker container images, DevContainers, and infrastructure tooling type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(infra): read the default branch at origin, not the working tree

1 participant