Skip to content

Refs #238 - Add update command - #908

Open
jakduch wants to merge 1 commit into
theforeman:masterfrom
jakduch:issue-238-update-command
Open

jakduch wants to merge 1 commit into
theforeman:masterfrom
jakduch:issue-238-update-command

Conversation

@jakduch

@jakduch jakduch commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

What changed

Add foremanctl update as the supported orchestration for connected and air-gapped container updates and upgrades.

The command:

  1. pre-pulls all configured images while services are still available (skipped in air-gapped mode),
  2. records every service managed by foreman.target,
  3. stops the target and every loaded Foreman/Pulp socket,
  4. waits until every recorded service is fully stopped, and
  5. imports the regular deploy playbook with the persisted deployment parameters.

The deploy CLI metadata is now a shared fragment so deploy and update expose the same configuration options without duplication. The user documentation and the upgrade CI job now use the new command.

Why

#238 identifies the missing update/upgrade workflow. The existing documented sequence requires operators to manually coordinate image pulls, service shutdown, and redeployment. It also risks continuing while target services are still deactivating.

The sockets are stopped explicitly because the first update from an older foremanctl version must be safe before the updated socket unit files have been deployed. An image-pull failure happens before downtime; a deployment failure intentionally leaves the services stopped for investigation.

Design scope

This command is intentionally a thin composition of existing foremanctl operations, not an attempt to reproduce the broader foreman_maintain update framework.

Operators can perform the individual steps manually, but keeping the sequence in foremanctl provides consistent ordering and failure behavior: images are pulled before downtime, a pull failure leaves the running deployment untouched, all services and sockets are stopped before deployment begins, and air-gapped installations skip registry access.

The existing pull-images and deploy commands remain independently available, and deploy remains the recovery path after a failure. The update command does not attempt to detect available updates, switch release repositories, provide rollback, or introduce a separate update state machine.

Dependency

Depends on #907, which makes manual systemctl stop foreman.target a complete socket boundary. This branch intentionally contains that commit; once #907 is merged, this PR reduces to the update-command commit.

Verification

  • ansible-lint passed for the new and shared playbook metadata (0 failures, 0 warnings).
  • Repository-wide Ruff passed.
  • The update command discovery, filename, and help tests passed.
  • The deploy and update option sets were compared and are identical.
  • Ran the command twice against the CentOS Stream 10 Quadlet test deployment:
    • first update from the old socket units: 269 tasks OK, 32 changed, 0 failed;
    • second idempotency/update run: 265 tasks OK, 19 changed, 0 failed;
    • the command waited for all 18 target services before starting deployment;
    • post-update health: 31 OK, 0 failed;
    • target, Foreman service, and all three sockets active;
    • Foreman login endpoint returned HTTP 200;
    • persisted parameters checksum unchanged across both runs.

Refs #238

Rebase validation (2026-10-27)

Rebased on current master. The shared _deploy metadata now includes the newly added _network options, so both deploy and update accept the current container-network parameters. Ruff and production Ansible lint passed (with the existing restore-module warning). Local unit results were 49 passed and eight certificate checks blocked by macOS BSD date; those scripts require GNU date and were unchanged by this PR. Full deployment tests require CI.

AI assistance: Codex. Project signature: GPT_5.6 Sol.

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8aaf30db-f7cf-43b3-bc8e-f20f56d2083e
Commits

Reviewing files that changed from the base of the PR and between bda4c5b and 2c27b24.

Files selected for processing: 13
  • .github/workflows/test.yml
  • docs/developer/deployment.md
  • docs/user/update.md
  • docs/user/upgrade.md
  • src/playbooks/_deploy/metadata.obsah.yaml
  • src/playbooks/deploy/metadata.obsah.yaml
  • src/playbooks/update/metadata.obsah.yaml
  • src/playbooks/update/update.yaml
  • src/roles/foreman/templates/foreman.socket.j2
  • src/roles/pulp/templates/pulp-api.socket.j2
  • src/roles/pulp/templates/pulp-content.socket.j2
  • tests/fixtures/help/update.txt
  • tests/target_lifecycle_test.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jakduch

jakduch commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

Rebased on the lifecycle-test fix from #907. The previous matrix-wide test_foreman_target_stop_start failures were caused by checking the socket units while systemd was still completing their stop jobs; the stack now waits for them to become inactive.

@jakduch

jakduch commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

The first failure in the new run is the unrelated 2.y upgrade Pulp migration failure. It occurs before this update/lifecycle code is exercised and is covered by the now-green image fix in theforeman/pulp-oci-images#122. The current deployment matrix is still running.

@jakduch

jakduch commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

The new fapolicyd proxy failure is the shared backup polling issue: after stopping services, Wait for PostgreSQL to fully stop times out waiting for privilege escalation. It is fixed by #863 and is unrelated to the update/lifecycle change. Multiple other current deployment jobs are green.

@ehelms

ehelms commented Oct 4, 2026

Copy link
Copy Markdown
Member

The original issue #238 was written back when we were looking to mirror foreman_maintain behavior. We had not arrived at whether we would mirror that in the long run or if foremanctl would natively handle this and it would be as simple as stop services, pull-images, run deploy. As you have produced a version of what it would look like, you can weigh in on whether it's needed or not.

@jakduch

jakduch commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

Having implemented and tested it, I think a dedicated update command is useful, but as thin native orchestration rather than an attempt to mirror foreman_maintain.

The individual operations can be run manually, but their ordering and failure boundaries matter. Images should be pulled before downtime, a pull failure should leave the running deployment untouched, the first update must also stop socket units created by an older foremanctl version, and deployment should only start after all managed services have stopped. Air-gapped installations need the same flow without registry access.

Keeping this sequence behind one command gives operators and automation a stable interface and avoids duplicating the lifecycle logic in documentation and external scripts. I would keep deploy as the underlying primitive and recovery command, and avoid adding update detection or a larger state machine to update.

My preference is therefore to keep foremanctl update in its current narrow scope. I updated the PR description to make that scope explicit.

Updated the existing change onto current master with the merged Pulp and
container-test prerequisites. Consolidated the PR into one commit.

AI assistance: Codex. Project signature: GPT_5.6 Sol.
@jakduch
jakduch force-pushed the issue-238-update-command branch from bbd87b5 to 2c27b24 Compare October 27, 2026 21:40
@jakduch

jakduch commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

The new run failed only in the shared hourly timer checks: NextElapseUSecRealtime was absent and the execution check then timed out. The migration job had 341 passing tests and the air-gapped Satellite job had 333 passing tests, with those same two failures in each.

The dedicated fix is #888, whose CI is green. I am leaving this run in place until that fix merges, then I can rebase and run the full matrix with it included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Waiting for review in other projects

Development

Successfully merging this pull request may close these issues.

2 participants