Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1814397: fix wrongful backup of files not originally on the system #1593

Merged
merged 3 commits into from Apr 1, 2020

Conversation

yuqi-zhang
Copy link
Contributor

Adds to #1586

Add a check for backwards compatibility: basically if the file
doesn't exist in /usr/etc/ and no rpm is claming it, we assume
that the orig file came from a wrongful backup of a MachineConfig
file instead of a RHCOS file.

We have a serious bug in how we backup "original" files and restore them.
Here, "original" means files that ship with RHCOS. Think of a default Chrony
or another system daemon configuration file. When the MCD kicks in and writes
to those files, we want to backup the original one (the shipped-with-RHCOS) in order
to restore it if a user deletes the MC that modified it (this was the initial bug reported
in GitHub at openshift#782).

However, that patch that fixed openshift#782
was causing the following; if you shipped a file with just _one_ MC, removing it would wipe it out and that works.
However, if you modified that file later again with another MC, a backup
file will be created for the first MC, and when deleting the file by deleting the second MC, it will
restore the initial file shipped with the first MC instead of wiping it out completely which
it should have since that file was never meant to be backed up because it wasn't on RHCOS from the beginning.

This patch now differentiates between files that are already on RHCOS (on-disk so to speak)
and files that are shipped with an MC. For the former, the MCD will create a backup as it's doing today,
for the latter instead, the MCD creates a placeholder file that tells it to just get rid
of the file altogether (along with adding all the necessary checks and actions in order to create those backup files).

The issue popped up on upgrade paths where the new manifests rendered by the MCO don't contain a certain file.
The MCD notices that and go ahead trying to remove the file. It however notices that a backup file
(which was created for an MC shipped file and later other MC have modified it) is there and tries to restore it (also failing
with invalid cross-link device error, but that's another issue which I'm fixing here as well by using cp directly).

Really hoping all the above makes sense.

Signed-off-by: Antonio Murdaca <runcom@linux.com>
@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 26, 2020
pkg/daemon/update.go Outdated Show resolved Hide resolved
@yuqi-zhang yuqi-zhang force-pushed the add-orig-check branch 2 times, most recently from e89a72a to 7a68edd Compare March 26, 2020 17:15
pkg/daemon/update.go Outdated Show resolved Hide resolved
pkg/daemon/update.go Outdated Show resolved Hide resolved
@runcom
Copy link
Member

runcom commented Mar 27, 2020

manually upgraded from 4.2 to 4.4 (with this patch) and it worked just fine, I'm gonna test all the way from 4.1 to fully verify this, otherwise, this replaces #1586

/approve

@runcom runcom changed the title update.go: add extra checks when restoring .orig files Bug 1814397: update.go: add extra checks when restoring .orig files Mar 27, 2020
@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Mar 27, 2020
@openshift-ci-robot
Copy link
Contributor

@yuqi-zhang: This pull request references Bugzilla bug 1814397, which is valid. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1814397: update.go: add extra checks when restoring .orig files

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/test-infra repository.

@runcom
Copy link
Member

runcom commented Mar 27, 2020

The additional patches here are also backported already to #1588 - we'd need a 4.3 patch and 4.2 patch anyway but those can wait till we unblock 4.4 as this patch effectively fixes the upgrade.

@runcom
Copy link
Member

runcom commented Mar 27, 2020

/retest

@yuqi-zhang
Copy link
Contributor Author

Ah, thanks for the fix! Feel free to squash the commits together

pkg/daemon/update.go Outdated Show resolved Hide resolved
pkg/daemon/update.go Outdated Show resolved Hide resolved
@yuqi-zhang
Copy link
Contributor Author

Pushed new commit:
Squashed fixes
Added comments and changed naming for clarity
Add new fix for files that exist in /etc

Manually tested to be good for both new and existing scenarios

@yuqi-zhang
Copy link
Contributor Author

Modified error msg

Now I think about it technically I think the logic is wrong.

/hold

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 27, 2020
@yuqi-zhang
Copy link
Contributor Author

/hold cancel

After some more thought I think this is alright. To be clear if we have an .orig file, the conditions it will restore is that it must both be a) managed by an RPM and b) exist in the original ostree (if it was in /etc).

Is there a scenario where we have an rpm drop in a file in /etc but it would not exist in /usr/etc? Conversely, is there a scenario where it exists in /usr/etc but no rpm is claiming it?

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 27, 2020
@runcom
Copy link
Member

runcom commented Mar 30, 2020

Is there a scenario where we have an rpm drop in a file in /etc but it would not exist in /usr/etc?

I think this is only possible if you install an rpm after initial bootstrap + MCO right?

Conversely, is there a scenario where it exists in /usr/etc but no rpm is claiming it?

I think yes, say you installed an RPM with a spec that doesn't claim ownership of a file (it happens a lot, trust me...) but still ships the file under /etc

@runcom
Copy link
Member

runcom commented Mar 30, 2020

/retest

@yuqi-zhang
Copy link
Contributor Author

I can confirm this passes the tests to be added in #1590

I can also add a test to ensure existing .origs are properly pruned as a separate PR. For now I have done manual testing and can confirm this should fix those cases.

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 1, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kikisdeliveryservice, runcom, sinnykumari, yuqi-zhang

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

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [kikisdeliveryservice,runcom,sinnykumari,yuqi-zhang]

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

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

2 similar comments
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@runcom
Copy link
Member

runcom commented Apr 1, 2020

uhm, wondering if something broke the install but weird it's on for e2e-aws

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

2 similar comments
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@runcom
Copy link
Member

runcom commented Apr 1, 2020

/refresh

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

6 similar comments
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit e49397e into openshift:master Apr 1, 2020
@openshift-ci-robot
Copy link
Contributor

@yuqi-zhang: All pull requests linked via external trackers have merged: openshift/machine-config-operator#1593. Bugzilla bug 1814397 has been moved to the MODIFIED state.

In response to this:

Bug 1814397: fix wrongful backup of files not originally on the system

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/test-infra repository.

@runcom
Copy link
Member

runcom commented Apr 2, 2020

/cherry-pick release-4.4

@openshift-cherrypick-robot

@runcom: new pull request created: #1607

In response to this:

/cherry-pick release-4.4

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/test-infra repository.

@runcom
Copy link
Member

runcom commented Apr 2, 2020

/cherry-pick release-4.3

@openshift-cherrypick-robot

@runcom: new pull request created: #1608

In response to this:

/cherry-pick release-4.3

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/test-infra repository.

@vrutkovs
Copy link
Member

vrutkovs commented Apr 2, 2020

/cherrypick fcos

@openshift-cherrypick-robot

@vrutkovs: #1593 failed to apply on top of branch "fcos":

Using index info to reconstruct a base tree...
M	pkg/daemon/update.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/daemon/update.go
Applying: update.go: add extra checks when restoring .orig files
Using index info to reconstruct a base tree...
M	pkg/daemon/update.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/daemon/update.go
Applying: deleteStaleFiles: only check for /usr/etc on *COS systems
error: Failed to merge in the changes.
Using index info to reconstruct a base tree...
M	pkg/daemon/update.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/daemon/update.go
CONFLICT (content): Merge conflict in pkg/daemon/update.go
Patch failed at 0003 deleteStaleFiles: only check for /usr/etc on *COS systems

In response to this:

/cherrypick fcos

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/test-infra repository.

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. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants