Skip to content

feat!: add ability to retain snapshot after cleanup #407

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

Closed
wants to merge 1 commit into from

Conversation

a-dubs
Copy link
Contributor

@a-dubs a-dubs commented Aug 28, 2024

PR Checklist

To ease the process of reviewing your PR, do make sure to complete the following checklist before submitting a pull
request.

  • I have added unit tests to cover the new behavior under ``tests/unit_tests/```
  • I have run tox -e format locally to automatically format my code before submitting
  • I have run tox locally ensuring that it passes before submitting
  • (if applicable) I have added a reference to issues that this PR relates to in the PR message (Refs GH-1234, Fixes GH-1234)

Otherwise, please leave the PR as a draft to indicate that it is still a work in progress.

Proposed Commit Message

N/A

Description and Relevant Issues

Additional Context

Test Steps

I generated html coverage report and ensured 100% coverage of newly added snapshot helper functions

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits.

if not keep:
self.created_images.append(image_data.id)
else:
self._log.info("Keeping image %s", image_data.display_name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's worth us persisting a list of self.kept_images or self.retained_mages. Then on teardown/cloud.clean() we can make sure we emit a footer log or something conspicuous that says f"Skipping deletion of preserved image(s): {self.retained_images}". Otherwise there is little hope we will see this inline log during image creation during our busy integration tests.

Also we probably want to log both name and id so that we can reference that image in the future on CLI/SDK/cloud-dashboards.

Suggested change
self._log.info("Keeping image %s", image_data.display_name)
self._log.info("Keeping image %s[id:%s]", image_data.display_name, image_data.id)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed! Thanks for the feedback @blackboxsw!

Copy link
Collaborator

@blackboxsw blackboxsw left a comment

Choose a reason for hiding this comment

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

Question for the maintainers: Do we want to make this an optional part of the standard pycloudlib API across clouds? I could easily add this to all other clouds if so.

I agree with your sentiment. I think it's a valuable feature to have generally across clouds. Let's make this something available in the general API of pycloudlib.Cloud.snapshot.

@blackboxsw blackboxsw self-assigned this Sep 9, 2024
@a-dubs a-dubs force-pushed the oracle-keep-snapshots branch from 2f08c98 to 009a7af Compare September 9, 2024 21:21
@a-dubs a-dubs force-pushed the oracle-keep-snapshots branch from 009a7af to 8ed5695 Compare September 10, 2024 17:41
@a-dubs a-dubs force-pushed the oracle-keep-snapshots branch 3 times, most recently from 1f5f311 to 8238077 Compare October 15, 2024 13:57
@a-dubs a-dubs changed the title feat(oracle): add ability to retain snapshot after cleanup feat!: add ability to retain snapshot after cleanup Oct 15, 2024
@a-dubs a-dubs force-pushed the oracle-keep-snapshots branch 3 times, most recently from 5d4fad7 to 774bbbe Compare October 17, 2024 16:44
@a-dubs a-dubs marked this pull request as ready for review October 17, 2024 18:45
@a-dubs
Copy link
Contributor Author

a-dubs commented Oct 17, 2024

@blackboxsw finally ready for re-review!

@a-dubs a-dubs force-pushed the oracle-keep-snapshots branch from 774bbbe to 1b4a56c Compare October 18, 2024 19:48
@a-dubs a-dubs force-pushed the oracle-keep-snapshots branch 3 times, most recently from 21a69a5 to 35529b8 Compare February 5, 2025 17:35
@a-dubs a-dubs marked this pull request as draft February 6, 2025 15:23
This allows for marking snapshots to be kept at time of creation
instead of being cleaned up automatically. This allows for still using
context managers for easy cleanup while retaining snapshots where
desired. This functionality can also be used when not using context
managers and instead the cloud.clean() method is manually called,
like in cloud-init's integration tests.

BREAKING CHANGE: signature of cloud.snapshot() public method has
been changed and now all args except for the first (instance)
must be passed as named args.
@a-dubs a-dubs force-pushed the oracle-keep-snapshots branch from 35529b8 to cd62eaf Compare February 6, 2025 19:02
@a-dubs
Copy link
Contributor Author

a-dubs commented Feb 21, 2025

closed in favor of #472 which cherry-picks this change and wraps it into one big v11 bundle

@a-dubs a-dubs closed this Feb 21, 2025
@a-dubs
Copy link
Contributor Author

a-dubs commented Apr 10, 2025

this functionality is now being proposed in PR #480

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.

2 participants