Skip to content

Bug 1817458: [release-4.3] pkg/daemon: fix deletion of stale files - #1587

Closed
runcom wants to merge 1 commit into
openshift:release-4.3from
runcom:4.3-fix-orig
Closed

runcom wants to merge 1 commit into
openshift:release-4.3from
runcom:4.3-fix-orig

Conversation

@runcom

@runcom runcom commented Mar 26, 2020 •

Copy link
Copy Markdown
Member

NOTICE: the 4.3 patch contains an additional snippet which makes sure to:

a) check if the file was shipped with RHCOS with rpm -qf PATH and if it wasn't...
b) create a no-orig file
c) remove any orig file previously created, if any

We could miss some file shipped by the base OS that are using incorrect rpm specs and don't like to files but I think this will cover the majority of the config file that rhcos ships and users change - I guess we'll manually workaround any that we miss?

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 #782).

However, that patch that fixed #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. Otherwise, an e2e can be consulted here #1590

Signed-off-by: Antonio Murdaca [email protected]

NOTICE: the 4.3 patch contains an additional snippet which makes sure to:

a) check if the file was shipped with RHCOS with rpm -qf PATH and if it wasn't...
b) create a no-orig file
c) remove any orig file previously created, if any

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 <[email protected]>
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@runcom: No Bugzilla bug is referenced in the title of this pull request.
To reference a bug, add 'Bug XXX:' to the title of this pull request and request another bug refresh with /bugzilla refresh.

Details

In response to this:

[release-4.3] pkg/daemon: fix deletion of stale 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.

@openshift-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: runcom

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

@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
@runcom

runcom commented Mar 26, 2020

Copy link
Copy Markdown
Member Author

@cgwalters @miabbott could you tell me if running rpm -qf would with a certain confidente tell us that the file was in RHCOS? I suspect so for the majority of the files

@runcom runcom changed the title [release-4.3] pkg/daemon: fix deletion of stale files Bug 1817458: [release-4.3] pkg/daemon: fix deletion of stale files Mar 26, 2020
@openshift-ci-robot openshift-ci-robot added the bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. label Mar 26, 2020
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@runcom: This pull request references Bugzilla bug 1817458, which is invalid:

  • expected dependent Bugzilla bug 1814397 to be in one of the following states: VERIFIED, RELEASE_PENDING, CLOSED (ERRATA), but it is POST instead
  • expected dependent Bugzilla bug 1817455 to be in one of the following states: VERIFIED, RELEASE_PENDING, CLOSED (ERRATA), but it is NEW instead
  • expected dependent Bugzilla bug 1814397 to target the "4.4.0" release, but it targets "4.5.0" instead

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

Details

In response to this:

Bug 1817458: [release-4.3] pkg/daemon: fix deletion of stale 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.

2 similar comments
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@runcom: This pull request references Bugzilla bug 1817458, which is invalid:

  • expected dependent Bugzilla bug 1814397 to be in one of the following states: VERIFIED, RELEASE_PENDING, CLOSED (ERRATA), but it is POST instead
  • expected dependent Bugzilla bug 1817455 to be in one of the following states: VERIFIED, RELEASE_PENDING, CLOSED (ERRATA), but it is NEW instead
  • expected dependent Bugzilla bug 1814397 to target the "4.4.0" release, but it targets "4.5.0" instead

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

Details

In response to this:

Bug 1817458: [release-4.3] pkg/daemon: fix deletion of stale 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.

@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@runcom: This pull request references Bugzilla bug 1817458, which is invalid:

  • expected dependent Bugzilla bug 1814397 to be in one of the following states: VERIFIED, RELEASE_PENDING, CLOSED (ERRATA), but it is POST instead
  • expected dependent Bugzilla bug 1817455 to be in one of the following states: VERIFIED, RELEASE_PENDING, CLOSED (ERRATA), but it is NEW instead
  • expected dependent Bugzilla bug 1814397 to target the "4.4.0" release, but it targets "4.5.0" instead

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

Details

In response to this:

Bug 1817458: [release-4.3] pkg/daemon: fix deletion of stale 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

runcom commented Mar 26, 2020

Copy link
Copy Markdown
Member Author

/retest

Comment thread pkg/daemon/update.go
return createNoOrigFile(fpath)
}

if _, err := exec.Command("rpm", "-qf", fpath).CombinedOutput(); err != nil {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

for files under /etc which are probably the ones being modified more often by users - we should check /usr/etc (see @jlebon comment here #1586 (comment))

Maybe we could still use a combination of /usr/etc/ and rpm -qf to do a best effort check here

@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@runcom: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/e2e-aws e91c112 link /test e2e-aws
ci/prow/e2e-gcp-op e91c112 link /test e2e-gcp-op
ci/prow/e2e-gcp-upgrade e91c112 link /test e2e-gcp-upgrade

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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/test-infra repository. I understand the commands that are listed here.

@miabbott

Copy link
Copy Markdown
Member

@cgwalters @miabbott could you tell me if running rpm -qf would with a certain confidente tell us that the file was in RHCOS? I suspect so for the majority of the files

There are a couple heredocs that we use during the compose of RHCOS to create files that wouldn't be owned by any RPM, but I think rpm -qf is safe for like 99.9% of the cases.

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/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants