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

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

a-dubs
Copy link
Collaborator

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

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, and also when not using context managers and the
cloud.clean() method is called.


Keeping this as a draft until the following is resolved.
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.

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
Collaborator 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
pycloudlib/oci/cloud.py Outdated Show resolved Hide resolved
@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
Collaborator Author

a-dubs commented Oct 17, 2024

@blackboxsw finally ready for re-review!

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.
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