Skip to content

[release-4.20] OCPBUGS-85271: fsync static pod cert and manifest writes for crash durability#2207

Open
sanchezl wants to merge 8 commits into
openshift:release-4.20from
sanchezl:cherry-pick-2176-to-release-4.20
Open

[release-4.20] OCPBUGS-85271: fsync static pod cert and manifest writes for crash durability#2207
sanchezl wants to merge 8 commits into
openshift:release-4.20from
sanchezl:cherry-pick-2176-to-release-4.20

Conversation

@sanchezl
Copy link
Copy Markdown
Contributor

@sanchezl sanchezl commented May 7, 2026

This is a cherry-pick of #2176.

tchap and others added 8 commits May 7, 2026 15:20
pkg/operator/staticpod/internal/atomicdir contains internal helpers for
performing atomic operations on directories.

This patch contains only a standalone swap function, which will be
subsequenty used for synchronizing directory with the given state.
The function can be used to atomically sync a directory with the desired
state. This uses atomicdir.swap implemented earlier.
Use atomicdir.Sync to write target secret/configmap directories to be
synchronized with the relevant objects.

Added unit tests, but the coverage is not complete. Particularly
filesystem operations failing are not being tested.
atomicdir.Sync writes files to a staging directory, atomically swaps
it with the target directory via renameat2(RENAME_EXCHANGE), then
deletes the old data. Without fsync, file data lives only in the
kernel page cache. On ungraceful shutdown the journal replays the
swap and deletion (metadata), but the file data was never flushed,
leaving truncated or empty files.

Introduce an fsutil package with WriteFileFsync (write + fsync file +
fsync parent directory) and Fsync (fsync a path) primitives. Use
WriteFileFsync for all file writes so each file is individually
durable, and fsync both parent directories after the swap to persist
which inode each directory name points to.
writePod uses bare os.WriteFile plus a delete-then-write pattern for
kubelet manifests. On ungraceful shutdown, the delete is journaled
but the new file data may not have reached disk, leaving the manifest
missing.

Replace os.WriteFile with fsutil.WriteFileFsync, which writes, fsyncs
the file, and fsyncs the parent directory in a single call, ensuring
both the resource copy and the kubelet manifest are durable before the
function returns.
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 7, 2026

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

@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 May 7, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 4fd218bc-fd3f-44d6-8ebb-18179ae54973

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@sanchezl sanchezl changed the title cherry pick 2176 to release 4.20 [release-4.20] OCPBUGS-85271: fsync static pod cert and manifest writes for crash durability May 7, 2026
@openshift-ci-robot openshift-ci-robot added jira/severity-critical Referenced Jira bug's severity is critical for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels May 7, 2026
@openshift-ci-robot
Copy link
Copy Markdown

@sanchezl: This pull request references Jira Issue OCPBUGS-85271, which is invalid:

  • expected dependent Jira Issue OCPBUGS-85270 to be in one of the following states: VERIFIED, RELEASE PENDING, CLOSED (ERRATA), CLOSED (CURRENT RELEASE), CLOSED (DONE), CLOSED (DONE-ERRATA), but it is New instead

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

  • Add atomicdir package
  • operator/staticpod/internal/atomicdir/swap_other: add missing import
  • Add atomicdir.Sync function
  • atomicdir: Set permission for each file separately
  • atomicdir: Split testing utils into a helper pkg
  • certsync+installer: Write object dirs atomically
  • atomicdir: fsync files and directories for crash durability
  • installerpod: fsync pod manifest writes for crash durability

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.

@sanchezl sanchezl marked this pull request as ready for review May 7, 2026 19:31
@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 May 7, 2026
@openshift-ci openshift-ci Bot requested review from dgrisonnet and p0lyn0mial May 7, 2026 19:32
@sanchezl
Copy link
Copy Markdown
Contributor Author

sanchezl commented May 7, 2026

/jira refresh

@openshift-ci-robot
Copy link
Copy Markdown

@sanchezl: This pull request references Jira Issue OCPBUGS-85271, which is invalid:

  • expected dependent Jira Issue OCPBUGS-85270 to be in one of the following states: VERIFIED, RELEASE PENDING, CLOSED (ERRATA), CLOSED (CURRENT RELEASE), CLOSED (DONE), CLOSED (DONE-ERRATA), but it is New instead

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

Details

In response to this:

/jira refresh

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.

@sanchezl
Copy link
Copy Markdown
Contributor Author

sanchezl commented May 8, 2026

/retest

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 8, 2026

@sanchezl: all tests passed!

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.

@sanchezl
Copy link
Copy Markdown
Contributor Author

sanchezl commented May 8, 2026

/payload-job periodic-ci-openshift-release-main-nightly-4.20-e2e-aws-ovn-upgrade-fips

@sanchezl
Copy link
Copy Markdown
Contributor Author

sanchezl commented May 8, 2026

/payload-job periodic-ci-openshift-release-main-ci-4.20-upgrade-from-stable-4.19-e2e-gcp-ovn-upgrade

@sanchezl
Copy link
Copy Markdown
Contributor Author

/jira refresh

@openshift-ci-robot
Copy link
Copy Markdown

@sanchezl: This pull request references Jira Issue OCPBUGS-85271, which is invalid:

  • expected dependent Jira Issue OCPBUGS-85270 to be in one of the following states: VERIFIED, RELEASE PENDING, CLOSED (ERRATA), CLOSED (CURRENT RELEASE), CLOSED (DONE), CLOSED (DONE-ERRATA), but it is New instead

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

Details

In response to this:

/jira refresh

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.

@rh-roman
Copy link
Copy Markdown

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label May 14, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 14, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: rh-roman, sanchezl
Once this PR has been reviewed and has the lgtm label, please assign p0lyn0mial 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

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

Labels

jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. jira/severity-critical Referenced Jira bug's severity is critical for the branch this PR is targeting. 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