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

Refactor uninstall to add -purge flag #47

Merged

Conversation

TinaMor
Copy link
Contributor

@TinaMor TinaMor commented Jan 30, 2025

PR description

Refactor the uninstall commands to only remove program data (program data folder, config files, env variable, and RegKeys) when the -purge flag is passed.

Github issue

Uninstall-Containerd too destructive #40

Background information

Running the uninstall command currently deletes the program data as well. This is too destructive as the user would like to retain these folders/files (e.g. Containerd snapshot folder) even after installing another version (either an upgrade or a downgrade).

To resolve this, we add a -purge flag that when passed in the uninstall command, the program data will be removed, otherwise, it will be retained.

Testing information

Examples: To uninstall containerd

  1. WhatIf

    > Uninstall-Containerd -WhatIf
    
    What if: Performing the operation "Containerd will be uninstalled from 'C:\Program Files\Containerd'' and containerd service     will be stopped and unregistered" on target "COMPUTERNAME".
  2. Retain the program data

    > Uninstall-Containerd
    
    Confirm
    Are you sure you want to perform this action?
    Performing the operation "Containerd will be uninstalled from 'C:\Program Files\Containerd\bin' and containerd service will be stopped and unregistered.
    Containerd program data won't be removed. To remove program data, run 'Uninstall-Containerd' command without -Purge flag." on target "COMPUTERNAME".
    [Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): Y
    
    Are you sure you want to uninstall Containerd?
    C:\Program Files\Containerd\bin
    [Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): Y
    WARNING: Uninstalling preinstalled Containerd at the path 'C:\Program Files\Containerd\bin'.
    Containerd will be uninstalled from 'C:\Program Files\Containerd\bin' and containerd service will be stopped and     unregistered. Containerd program data won't be removed. To remove program data, run 'Uninstall-Containerd' command without -Purge flag.
    Successfully uninstalled Containerd. 
  3. Purge program data

    > Uninstall-Containerd -Purge
    
    Confirm
    Are you sure you want to perform this action?
    Performing the operation "Containerd will be uninstalled from 'C:\Program Files\Containerd' and containerd service will be stopped and unregistered. Containerd
    program data will also be removed." on target "COMPUTERNAME".
    [Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): Y
    
    Are you sure you want to uninstall Containerd?
    C:\Program Files\Containerd
    [Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): Y
    WARNING: Uninstalling preinstalled Containerd at the path 'C:\Program Files\Containerd'.
    Containerd will be uninstalled from 'C:\Program Files\Containerd' and containerd service will be stopped and unregistered. Containerd program data will also be removed.
    Purging Containerd program data
    WARNING: Removing Containerd registry key
    WARNING: Removing Containerd program data
    WARNING: Removing Containerd from env path
    Removing containerd in User Environment Path
    Removing containerd in System Environment Path
    Successfully uninstalled Containerd.

TODOs not included in this PR

  1. Unit tests for new functionality
  2. Updating documentation for the -purge flag

Checklist

As part of our commitment to engineering excellence, before submitting this PR, please make sure:

  • You've tested this code in both Desktop & Server environments and AMD & ARM64 enviroments (functional testing).
  • You've added unit tests for new code.
  • You've added/updated documentation in the cmdlet docs, command-reference.md and the modules help files.
  • You've reviewed the PR/code best practices defined in the CONTRIBUTING.md.

In addition, after this PR has been reviewed, please agree to:

  • If changes have been made to your PR in the process of addressing comments, please make sure to test again the final version in both AMD and ARM64 environments.
  • Validate your changes have not introduced any regressions.

Copy link

@iankingori iankingori left a comment

Choose a reason for hiding this comment

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

Looks good

@TinaMor TinaMor changed the title Tinamor/refactor uninstall Refactor uninstall to add -purge flag Feb 3, 2025
@TinaMor TinaMor marked this pull request as ready for review February 5, 2025 10:46
@TinaMor TinaMor merged commit 4f82428 into microsoft:fix-uninstall-#40 Feb 5, 2025
1 check passed
@TinaMor TinaMor mentioned this pull request Feb 5, 2025
6 tasks
TinaMor added a commit that referenced this pull request Feb 5, 2025
    * Refactor uninstall to only remove program data files when the `-purge` flag is passsed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants