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

Touch artifacts and content to prevent cleanup #362

Merged
merged 1 commit into from
Jul 28, 2021
Merged

Conversation

mdellweg
Copy link
Member

This change prepares for the async orphan cleanup that is expected to
come with pulpcore 3.15.

fixes #9134

@pulpbot
Copy link
Member

pulpbot commented Jul 27, 2021

Attached issue: https://pulp.plan.io/issues/9134

# TODO Evaluate, whether we need touch here.
# The manifest is in a repository version, so not orphaned,
# but can the version be deleted between this and using it?
manifest.touch()
Copy link
Member Author

Choose a reason for hiding this comment

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

Please discuss

Copy link
Member

Choose a reason for hiding this comment

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

there is a small window for such case, so i probably would keep it.

@@ -668,7 +669,7 @@ def copy_tags(self, request, pk):

result = dispatch(
tasks.recursive_add_content,
[repository],
[repository, source_latest.repository],
Copy link
Member Author

Choose a reason for hiding this comment

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

I think, this was actually a bug.

@@ -705,7 +706,7 @@ def copy_manifests(self, request, pk):
manifests_to_add = manifests_in_repo.filter(**filters)
result = dispatch(
tasks.recursive_add_content,
[repository],
[repository, source_latest.repository],
Copy link
Member Author

Choose a reason for hiding this comment

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

same here

@@ -111,12 +112,14 @@ def build_image_from_containerfile(

"""
containerfile = Artifact.objects.get(pk=containerfile_pk)
containerfile.touch()
Copy link
Member

Choose a reason for hiding this comment

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

i think, here, the line is not needed as well since we touched it in the viewset

Copy link
Member Author

@mdellweg mdellweg Jul 27, 2021

Choose a reason for hiding this comment

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

I had the same thougt. But then i decided to go ahead anyway, because there could be a considerate a amount of time between the request and the task, and it would be just so inconvenient if the artifact vanished between here and being used after reading all the other artifacts from cloud storage.
I'm open for discussion though.

Copy link
Member

@ipanova ipanova Jul 27, 2021

Choose a reason for hiding this comment

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

with this logic then we should double that use of touch in viewset and inside of the task..
the default is set to 1day( for the orphan cleanup), i'd still insist on not doubling this.

@@ -107,6 +107,7 @@ async def run(self):
except IntegrityError:
del tag.artifact_attributes["file"]
saved_artifact = Artifact.objects.get(**tag.artifact_attributes)
Copy link
Member

Choose a reason for hiding this comment

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

:+1

repository = ContainerRepository.objects.get(pk=repository_pk)
name = str(uuid4())
with tempfile.TemporaryDirectory(".") as working_directory:
path = "{}/".format(working_directory.path)
for key, val in artifacts.items():
artifact = Artifact.objects.get(pk=key)
artifact.touch()
Copy link
Member

Choose a reason for hiding this comment

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

i'd move this to the viewset

Copy link
Member

@ipanova ipanova left a comment

Choose a reason for hiding this comment

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

thank you for this pr, it looks good to me - i would rather move touch outside of the task into the viewset #362 (comment) and this one seems to be redundant #362 (comment)

This change prepares for the async orphan cleanup that is expected to
come with pulpcore 3.15.

fixes #9134
@mdellweg mdellweg merged commit 3ebc13e into pulp:master Jul 28, 2021
@mdellweg mdellweg deleted the touch branch July 28, 2021 11:39
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.

None yet

3 participants