Skip to content

pkg/daemon: do not delete host files when deleting an MC - #797

Merged
openshift-merge-robot merged 1 commit into
openshift:masterfrom
runcom:rpm-files
Jun 13, 2019
Merged

openshift-merge-robot merged 1 commit into
openshift:masterfrom
runcom:rpm-files

Conversation

@runcom

@runcom runcom commented May 28, 2019

Copy link
Copy Markdown
Member

Deploying an MC changing a file and later deleting it causes the file to
be deleted (it could have been already on disk i.e. shipped by an RPM).
Following Colin's suggestion, this patch adds a backup mechanism which,
when deleting an MC, causes the old file to be restored.
Added an e2e test as well.

closes #782

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

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels May 28, 2019
@runcom

runcom commented May 28, 2019

Copy link
Copy Markdown
Member Author

Thinking of any way this could break upgrades/backwards compatibily now lol

Comment thread pkg/daemon/update.go Resolved
Comment thread pkg/daemon/update.go Resolved
Comment thread pkg/daemon/update.go Resolved
Comment thread pkg/daemon/update.go Resolved
@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 7, 2019
@cgwalters

Copy link
Copy Markdown
Member

@runcom Are you going to get back to this PR? Pretty important bug I think, also I realized in later discussion that this would help us support the Ignition append mode.

@runcom

runcom commented Jun 11, 2019

Copy link
Copy Markdown
Member Author

@runcom Are you going to get back to this PR? Pretty important bug I think, also I realized in later discussion that this would help us support the Ignition append mode.

yep, been dragged and buried into something else (mainly bugzillas and next features), I'll get back on this shortly.

@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 12, 2019
@runcom

runcom commented Jun 12, 2019

Copy link
Copy Markdown
Member Author

Updated and ready for another round of reviews now

Deploying an MC changing a file and later deleting it causes the file to
be deleted (it could have been already on disk i.e. shipped by an RPM).
Following Colin's suggestion, this patch adds a backup mechanism which,
when deleting an MC, causes the old file to be restored.
Added an e2e test as well.

Signed-off-by: Antonio Murdaca <[email protected]>
@knobunc

knobunc commented Jun 13, 2019

Copy link
Copy Markdown
Contributor

Image build failing: https://openshift-gce-devel.appspot.com/build/origin-ci-test/pr-logs/pull/openshift_machine-config-operator/797/pull-ci-openshift-machine-config-operator-master-images/2698

could not wait for build: the build machine-config-daemon failed after 45s with reason DockerBuildFailed: Docker build strategy has failed.

Using version from git...
Building github.com/openshift/machine-config-operator/cmd/...-gcfa394e4-dirty, cfa394e44bc9f4f52330fdedc599eaacdab0102f)
# github.com/openshift/machine-config-operator/pkg/daemon
pkg/daemon/update.go:8:2: imported and not used: "io"
error: build error: running 'WHAT=machine-config-daemon ./hack/build-go.sh' failed with exit code 2

@cgwalters

Copy link
Copy Markdown
Member

A brief search turns up https://github.com/docker/docker-ce/blob/9f7430572607260b058cc69c03da91278beac746/components/engine/daemon/graphdriver/copy/copy.go#L30 which looks reasonable if we ever want to copy some code to do this in-process.

Rust also recently gained a good implementation of this FWIW.

@runcom

runcom commented Jun 13, 2019

Copy link
Copy Markdown
Member Author

A brief search turns up https://github.com/docker/docker-ce/blob/9f7430572607260b058cc69c03da91278beac746/components/engine/daemon/graphdriver/copy/copy.go#L30 which looks reasonable if we ever want to copy some code to do this in-process.

I'm familiar with that piece of code, also willing to use that, I'm just worried about the maintenance status of anything within Docker/Moby.

@cgwalters cgwalters left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm

Comment thread pkg/daemon/update.go
// the orig file is already there and we avoid creating a new one to preserve the real default
return nil
}
if out, err := exec.Command("cp", "-a", "--reflink=auto", fpath, origFileName(fpath)).CombinedOutput(); err != nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Of course if this is interrupted in the middle we'll end up with an incomplete backup but...let's just get this in!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The libglnx code I wrote for this properly clones to an O_TMPFILE which also makes it superior to what the Rust libstd is doing. It's a bit surprising actually cp doesn't have a --tmpfile flag or something, would probably be easy to implement.

If only calling C from golang wasn't unspeakably awful...

Anyways we can circle back to polishing this bit later.

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 13, 2019
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cgwalters, 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-merge-robot
openshift-merge-robot merged commit 4d70b0d into openshift:master Jun 13, 2019
@runcom
runcom deleted the rpm-files branch June 14, 2019 14:57
ptalgulk01 pushed a commit to ptalgulk01/machine-config-operator that referenced this pull request May 15, 2026
pkg/daemon: do not delete host files when deleting an MC
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. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

after replacing default config file, removing the MC causes the config file to disappear

6 participants