Skip to content

[libvirt_manager] Add retries to controller SSH key inject tasks - #4057

Open
skovili wants to merge 4 commits into
openstack-k8s-operators:stablefrom
skovili:fix/inject-key-retries
Open

[libvirt_manager] Add retries to controller SSH key inject tasks#4057
skovili wants to merge 4 commits into
openstack-k8s-operators:stablefrom
skovili:fix/inject-key-retries

Conversation

@skovili

@skovili skovili commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds retries: 5, delay: 30 to both "Inject private key" and "Inject public key" tasks in manage_vms.yml
  • Matches the retry pattern already used for OCP SSH access (line 62-75, retries: 5, delay: 60)
  • Fixes a race condition where cloud-init hasn't written authorized_keys before the inject task attempts SSH, causing Permission denied (publickey) on controller VMs

Root cause

SSHD starts independently of cloud-init on RHEL 9. The SSH port opens ~16s after VM boot, but cloud-init may not finish writing SSH keys until 30-60s post-boot. Without retries, the inject task fails immediately on first attempt.

Observed in testproject build 5ac3f032 on devin07 (reused hypervisor, routable IPs through physical bridge), but this is a latent race condition that could affect any environment where cloud-init is slower than usual.

Test plan

  • Verify via ci-framework-testproject build with Depends-On: pointing to this PR
  • Confirm inject tasks succeed with retries on devin07 testproject

Related-Issue: #OSPRH-32065

🤖 Generated with Claude Code

Cloud-init may not finish writing authorized_keys before the inject
tasks attempt SSH, causing "Permission denied (publickey)" on
controller VMs. This is the same race the OCP SSH task already handles
with retries.

Related-Issue: #OSPRH-32065

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@centosinfra-prod-github-app

Copy link
Copy Markdown

Build failed (check pipeline). Post recheck (without leading slash)
to rerun all jobs. Make sure the failure cause has been resolved before
you rerun jobs.

https://gateway-cloud-softwarefactory.apps.ocp.cloud.ci.centos.org/zuul/t/rdoproject.org/buildset/d066cd195b724690bfa99b689b485c9c

✔️ openstack-k8s-operators-content-provider SUCCESS in 2h 32m 27s
✔️ podified-multinode-edpm-deployment-crc SUCCESS in 1h 35m 29s
✔️ cifmw-crc-podified-edpm-baremetal SUCCESS in 1h 48m 18s
✔️ cifmw-crc-podified-edpm-baremetal-minor-update SUCCESS in 2h 15m 54s
✔️ cifmw-pod-zuul-files SUCCESS in 6m 33s
✔️ noop SUCCESS in 0s
✔️ cifmw-pod-ansible-test SUCCESS in 10m 35s
✔️ cifmw-pod-pre-commit SUCCESS in 10m 08s
cifmw-molecule-libvirt_manager FAILURE in 32m 08s
cifmw-molecule-reproducer FAILURE in 11m 32s

@skovili
skovili changed the base branch from main to stable July 23, 2026 02:56
Ansible's retries/until mechanism only retries FAILED tasks, not
UNREACHABLE ones. When controller-0 SSH is not yet ready (cloud-init
race), the host is marked unreachable and removed from the play
without retrying.

Add ignore_unreachable: true so the task result includes unreachable
status instead of ejecting the host, and extend the until condition
to retry on both failed and unreachable states.
@openshift-ci

openshift-ci Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign tosky for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Replace ignore_unreachable + retries approach with
wait_for_connection before the inject tasks. The previous
approach failed because Ansible treats an "ignored unreachable"
as task-complete, skipping the retry loop entirely.

wait_for_connection has its own internal retry mechanism that
handles UNREACHABLE hosts correctly, waiting up to 5 minutes
for SSH to become ready after cloud-init completes.

Related-Issue: #OSPRH-32065

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@michburk

Copy link
Copy Markdown
Contributor

Hello, there are currently two issues with this pull request.

First, see that the check Check if commit message body is not too short / verify-body-length (pull_request) is failing with this error:

**WARNING: Missing 'Signed-off-by:' line in commit message.**

Add: Signed-off-by: Your Name <you@example.com>

Include this signed-off-by line in your commit by including the -s flag when committing or amending a commit.

Additionally, please target the main branch in your pull request, not stable. Changes are merged to main first, then once an automated suite of tests pass against the main branch, those changes are promoted to the stable branch.

Thanks!

When the hypervisor is a remote host (not localhost), the
ssh_jumper proxy config on the Zuul executor lacks the
IdentityFile directive. This causes delegate_to connections
to the controller VM to fail with Permission denied because
the reproducer key only exists on the hypervisor.

Replace delegate_to + ansible.builtin.copy with direct ssh/scp
commands that run on the hypervisor, matching the pattern used
by the existing OCP SSH access task. The hypervisor's SSH config
has the IdentityFile, so these commands authenticate correctly.

Related-Issue: #OSPRH-32065

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@michburk

Copy link
Copy Markdown
Contributor

Taking another look at this pr, I notice it is broken up into 4 commits. When we merge prs, we don't squash commits together. If your changes don't need to be broken up into multiple commits, would you be able to combine them appropriately? Thank you!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants