Skip to content

USHIFT-7342: Replace hardcoded sleep with state check before restart#6996

Open
pacevedom wants to merge 2 commits into
openshift:mainfrom
pacevedom:test-restarts
Open

USHIFT-7342: Replace hardcoded sleep with state check before restart#6996
pacevedom wants to merge 2 commits into
openshift:mainfrom
pacevedom:test-restarts

Conversation

@pacevedom

@pacevedom pacevedom commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

The Restart MicroShift keyword had an unconditional 10s sleep before every restart to avoid issuing restarts while the service was mid-transition. Replace it with an active check that polls systemd SubState for transitional states, passing instantly when the service is already stable and saving ~10s per restart.

Summary by CodeRabbit

  • Bug Fixes
    • Improved the MicroShift restart flow by removing the fixed wait and instead waiting for the microshift.service state to fully settle, clearing any failed state, restarting, verifying both MicroShift and etcd PIDs changed, then refreshing kubeconfig and confirming readiness.
    • Adjusted Wait For MicroShift Service to use fewer retries and clarified that the timeout budget covers TimeoutStartSec=4m.
  • Tests
    • Added a new check to ensure microshift.service is not transitioning (not activating, deactivating, or reloading) before proceeding with the restart.

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 7, 2026
@pacevedom

Copy link
Copy Markdown
Contributor Author

/test ?

@openshift-ci

openshift-ci Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Restart MicroShift now settles systemd state, clears failed state, verifies MicroShift and etcd PID changes, and refreshes readiness. Service wait retries are reduced, and a keyword validates that the service is not transitioning.

Changes

MicroShift Restart Reliability

Layer / File(s) Summary
Service wait and transition validation
test/resources/microshift-process.resource
Wait For MicroShift Service uses 30 ten-second retries and documents TimeoutStartSec=4m coverage. MicroShift Service Is Not Transitioning rejects activating, deactivating, and reloading states.
Restart orchestration
test/resources/microshift-process.resource
Restart MicroShift waits for a settled service state, resets failed state, snapshots both PIDs, performs a synchronous restart, verifies PID changes, then reruns kubeconfig setup and readiness checks.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: replacing the fixed sleep with a service state check before restart.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed The PR only changes Robot Framework keywords; no Ginkgo test titles were added or modified, and no dynamic values appear in titles.
Test Structure And Quality ✅ Passed PASS: This PR only changes Robot keywords, not Ginkgo tests; the waits are bounded and cleanup remains handled by existing teardown/restore flows.
Microshift Test Compatibility ✅ Passed The PR only changes a Robot resource file; no new Ginkgo e2e tests or MicroShift-unsupported API usage were added.
Single Node Openshift (Sno) Test Compatibility ✅ Passed PASS: The PR only changes a Robot Framework resource keyword; no new Ginkgo e2e tests or multi-node/HA assumptions were added.
Topology-Aware Scheduling Compatibility ✅ Passed Only a Robot test resource changed; no manifests/controllers or topology-sensitive scheduling constraints were added.
Ote Binary Stdout Contract ✅ Passed PR only changes a Robot resource file; no process-level code or stdout writes were added.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No new Ginkgo tests were added; the PR only changes a Robot resource file and contains no IPv4 or external-connectivity assumptions.
No-Weak-Crypto ✅ Passed The only changed file is a Robot resource; it adds no cryptography, custom crypto, or secret comparisons, and no weak-crypto terms appear in the diff.
Container-Privileges ✅ Passed The PR only changes a Robot resource file for MicroShift restart logic; no container/K8s manifests were modified, and no privilege fields appear in the changed file.
No-Sensitive-Data-In-Logs ✅ Passed No new logging of secrets/PII/internal hostnames was added; the new restart keyword only uses systemd state checks and fixed command outputs.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 7, 2026
@pacevedom

Copy link
Copy Markdown
Contributor Author

/test e2e-aws-tests

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/resources/microshift-process.resource`:
- Around line 83-89: The PID snapshot is taken too early in the restart flow, so
the existing MicroShift process and etcd PIDs can become stale before the
restart is triggered. Move the MicroShift Process ID and MicroShift Etcd Process
ID captures in this resource so they happen after `Wait Until Keyword Succeeds`
/ `MicroShift Service Is Not Transitioning` and immediately before `Systemctl   
restart    microshift.service`, then keep the `Wait Until ... Changes` checks
using those fresh values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 9704d8bc-0c13-4dad-86cb-b127ce30b0db

📥 Commits

Reviewing files that changed from the base of the PR and between 3b84391 and 80a91ee.

📒 Files selected for processing (1)
  • test/resources/microshift-process.resource

Comment thread test/resources/microshift-process.resource
@pacevedom

Copy link
Copy Markdown
Contributor Author

/test e2e-aws-tests

@pacevedom

Copy link
Copy Markdown
Contributor Author

/test all

@pacevedom pacevedom changed the title Replace hardcoded sleep with state check before restart USHIFT-7342: Replace hardcoded sleep with state check before restart Jul 8, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 8, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 8, 2026

Copy link
Copy Markdown

@pacevedom: This pull request references USHIFT-7342 which is a valid jira issue.

Details

In response to this:

The Restart MicroShift keyword had an unconditional 10s sleep before every restart to avoid issuing restarts while the service was mid-transition. Replace it with an active check that polls systemd SubState for transitional states, passing instantly when the service is already stable and saving ~10s per restart.

Summary by CodeRabbit

  • Bug Fixes
  • Improved the MicroShift restart flow by removing the fixed delay and instead waiting for the service to fully settle before restarting.
  • Added handling to reset systemd’s failed state prior to restart, then verifies MicroShift and etcd restarted, refreshes kubeconfig, and confirms readiness.
  • Tests
  • Added a new service-state check to ensure MicroShift is not transitioning (not activating, deactivating, or reloading) before restart.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

The Restart MicroShift keyword had an unconditional 10s sleep
before every restart to avoid issuing restarts while the service
was mid-transition. Replace it with an active check that polls
systemd ActiveState for transitional states, passing instantly when
the service is already stable and saving ~10s per restart.

Also reset the systemd failure counter before restarting so that
start-limit-hit from prior rapid failures (e.g. invalid config
tests) does not block the restart.
@pacevedom pacevedom marked this pull request as ready for review July 8, 2026 08:22
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 8, 2026
@openshift-ci openshift-ci Bot requested review from copejon and jogeo July 8, 2026 08:23
Comment thread test/resources/microshift-process.resource Outdated
Comment thread test/resources/microshift-process.resource
@pacevedom

Copy link
Copy Markdown
Contributor Author

/retest

@suleymanakbas91

Copy link
Copy Markdown

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 9, 2026
@pacevedom

Copy link
Copy Markdown
Contributor Author

/verified by CI

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Jul 9, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@pacevedom: This PR has been marked as verified by CI.

Details

In response to this:

/verified by CI

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@pacevedom

Copy link
Copy Markdown
Contributor Author

/hold

@openshift-ci openshift-ci Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 9, 2026
@openshift-ci-robot openshift-ci-robot removed the verified Signifies that the PR passed pre-merge verification criteria label Jul 10, 2026
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Jul 10, 2026
@pacevedom

Copy link
Copy Markdown
Contributor Author

/hold cancel

@openshift-ci openshift-ci Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 10, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 10, 2026

Copy link
Copy Markdown

@pacevedom: This pull request references USHIFT-7342 which is a valid jira issue.

Details

In response to this:

The Restart MicroShift keyword had an unconditional 10s sleep before every restart to avoid issuing restarts while the service was mid-transition. Replace it with an active check that polls systemd SubState for transitional states, passing instantly when the service is already stable and saving ~10s per restart.

Summary by CodeRabbit

  • Bug Fixes
  • Improved the MicroShift restart flow by removing the fixed wait and instead waiting for microshift.service to fully settle before restarting.
  • Cleared systemd’s failed state to prevent restart rejection, then verified MicroShift and etcd restarted, refreshed kubeconfig, and confirmed readiness.
  • Tests
  • Added a service-state check to ensure microshift.service is not transitioning (not activating, deactivating, or reloading) before the restart occurs.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@pacevedom

Copy link
Copy Markdown
Contributor Author

/hold

@openshift-ci openshift-ci Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 10, 2026
@pacevedom pacevedom removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 10, 2026
@ggiguash

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 10, 2026
The transition check budget (10x 5s = 50s) was too short — the
activating state can last up to TimeoutStartSec=4m (240s) during
slow startups. Increase to 30x 10s (300s) to cover the full startup
window, matching the poll interval used by every other wait in the
file.

Reduce Wait For MicroShift Service from 50x 10s (500s) to 30x 10s
(300s). TimeoutStartSec=4m (240s) is the hard ceiling — systemd
kills the process after that, so the extra 200s could never fire.
All waits in the file now use a uniform 30x 10s (300s) budget.

Document the full Restart MicroShift flow: the Restart=always
auto-restart loop, why the transition check must precede
reset-failed (to close the race where pending auto-restarts
re-trigger start-limit-hit after we clear it), PID tracking as
defense-in-depth, and the readiness verification sequence.
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Jul 10, 2026
@ggiguash

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 10, 2026
@openshift-ci

openshift-ci Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ggiguash, Neilhamza, pacevedom, suleymanakbas91

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

The pull request process is described 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

@pacevedom

Copy link
Copy Markdown
Contributor Author

/retest

1 similar comment
@pacevedom

Copy link
Copy Markdown
Contributor Author

/retest

@openshift-ci

openshift-ci Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

@pacevedom: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws-tests-bootc-el9 181cc5a link true /test e2e-aws-tests-bootc-el9
ci/prow/e2e-aws-tests-bootc-arm-el9 181cc5a link true /test e2e-aws-tests-bootc-arm-el9

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants