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

podman system reset removed machines incorrectly #14066

Merged
merged 1 commit into from
May 4, 2022

Conversation

ashley-cui
Copy link
Member

@ashley-cui ashley-cui commented Apr 29, 2022

podman system reset did not clean up machines fully, leaving some config
files, and breaking machines. Now it removes all machines files fully.

Signed-off-by: Ashley Cui [email protected]

Does this PR introduce a user-facing change?

Podman system reset now properly deletes all podman machines and associated files. 

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 29, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ashley-cui

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:

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 29, 2022
cmd/podman/system/reset.go Outdated Show resolved Hide resolved
@ashley-cui ashley-cui force-pushed the sysres branch 2 times, most recently from 93ca1ca to 09c3c06 Compare May 2, 2022 15:07
@TomSweeneyRedHat
Copy link
Member

Could you change the title when you repush please? correctly -> incorrectly

@ashley-cui ashley-cui force-pushed the sysres branch 2 times, most recently from 1ab0158 to 7ee9d36 Compare May 2, 2022 18:18
@ashley-cui ashley-cui changed the title podman system reset removes machines correctly podman system reset removed machines incorrectly May 2, 2022
@ashley-cui ashley-cui force-pushed the sysres branch 3 times, most recently from 9897dbc to 588ac1f Compare May 2, 2022 19:25
@@ -1442,3 +1442,57 @@ func (v *MachineVM) getResources() (resources machine.ResourceConfig) {
resources.DiskSize = getDiskSize(v)
return
}

// RemoveAndCleanMachines removes all machine and cleans up any other files associatied with podman machine
func (p *Provider) RemoveAndCleanMachines() error {
Copy link
Member

Choose a reason for hiding this comment

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

Why is this function logrus.Error rather then returning it? Looks like it never returns an error?

Copy link
Member Author

@ashley-cui ashley-cui May 3, 2022

Choose a reason for hiding this comment

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

The function should not error just because one machine failed to be removed, but rather keep going to check and remove more machines. I can either logrus.err it or return a list of errors and also error, but I think logrus is cleaner in this case

Copy link
Member

Choose a reason for hiding this comment

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

If the function never returns an error, then it should not have error in its core.

I think you should do

var prevError Error
...
if err != nil {
        if prevError != nil {
                logrus.Errorf(prevErr)
         }
        prevError = err
}
...
Return prevError

Copy link
Member Author

Choose a reason for hiding this comment

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

So the calling function would also just logrus the returned error too?

I updated the function to return an error if it's unable to list machines to remove, so the function will return an error if it fails there, do you think it's still necessary to do what you said?

Copy link
Member

Choose a reason for hiding this comment

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

It would logrus all errors except for the last error. So if only one error, then no logging. If two errors logus.Error First Error, return second.

pkg/machine/wsl/machine.go Outdated Show resolved Hide resolved
podman system reset did not clean up machines fully, leaving some config
files, and breaking machines. Now it removes all machines files fully.

Signed-off-by: Ashley Cui <[email protected]>
@rhatdan
Copy link
Member

rhatdan commented May 4, 2022

LGTM
@containers/podman-maintainers PTAL

@jwhonce
Copy link
Member

jwhonce commented May 4, 2022

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label May 4, 2022
@openshift-merge-robot openshift-merge-robot merged commit ad93318 into containers:main May 4, 2022
@ashley-cui
Copy link
Member Author

/cherry-pick v4.1

@openshift-cherrypick-robot
Copy link
Collaborator

@ashley-cui: new pull request created: #14117

In response to this:

/cherry-pick v4.1

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.

@edsantiago edsantiago added the kind/bug Categorizes issue or PR as related to a bug. label Jun 2, 2022
@ashley-cui ashley-cui deleted the sysres branch June 3, 2022 17:51
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 21, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants