Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Don't expect .tar in path for Directory Transport 1.1+ #235

Merged
merged 1 commit into from
Jun 12, 2018

Conversation

asmacdo
Copy link
Contributor

@asmacdo asmacdo commented Jun 4, 2018

containers/image#419 removed the expectation that the file ends in .tar and skopeo followed suit.

https://pulp.plan.io/issues/3703

Unless we need to remain compatible with older versions of skopeo, I think we are ok to make the simple change here.

@asmacdo
Copy link
Contributor Author

asmacdo commented Jun 4, 2018

TODO: If we go this route, I should find out what versions of skopeo use the new transport and include that in a release note.

This code reads the version file when determining the expected file path.

@thomasmckay
Copy link
Contributor

Shouldn't we instead check the version file written by skopeo and check for the correct file ending?

blob_src_path = os.path.join(self.get_working_dir(), checksum + '.tar')

with open(os.path.join(self.get_working_dir(), 'version')) as version_file:
version = version_file.readline().split(':')[1].strip()
Copy link
Contributor

@jortel jortel Jun 5, 2018

Choose a reason for hiding this comment

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

Recommend encapsulating understanding of the version file format in the Version class and add something like:

@classmethod
def read(cls, path):
    with open(path) as fp:
        version = fp.readline().split(':')[1].strip()
        return cls(version)

blob_src_path = os.path.join(self.get_working_dir(), checksum + '.tar')

blob_src_path = os.path.join(self.get_working_dir(), checksum)
version_file_path = os.path.join(self.get_working_dir(), 'version')
Copy link
Member

@ipanova ipanova Jun 6, 2018

Choose a reason for hiding this comment

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

i was wondering if it is a good idea to rely on the version file because of the future rfe https://pulp.plan.io/issues/3497 where we'd allow to upload to pulp partial tar that would not contain whole content.

what do you think about using glob? we can provide a pathname pattern

In [11]: glob.glob(dir + checksum + '.tar')
Out[11]: ['/home/ipanova/pulp_development/pulp_docker/existingemptydirectory/8c811b4aec35f259572d0f79207bc0678df4c736eeec50bc9fec37ed936a472a.tar']

in case it'd find a blob with tar extension it would return a list containing it otherwise it would be empty

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO, I would still use the version file. Remember that the user is not uploading skopeo output directly but is instead being forced to tar it up. If I were a smart user, I'd write a script that made the tar files optimal to not duplicate layers. Also consider that a future version of skopeo may change the format of the output. My vote is to use the version file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was assuming that for 3497 the tar would still contain a version file. Referenced blobs don't exist, they would be queried in pulp, and I assume the file extension wouldn't matter for that case.

If we are going to support multiple versions of the transport, I think its probably better for the code to be aware of the transport version rather than go with whatever is there.

@asmacdo asmacdo changed the title Remove .tar from path Don't expect .tar in path for Directory Transport 1.1+ Jun 6, 2018
@asmacdo asmacdo force-pushed the skopeo-transport-1.1 branch 3 times, most recently from 434421b to aeac863 Compare June 11, 2018 14:59
@asmacdo
Copy link
Contributor Author

asmacdo commented Jun 11, 2018

ok test

@@ -0,0 +1,117 @@
class Version:
"""
Represents a version of a Skopeo version file.
Copy link
Member

Choose a reason for hiding this comment

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

can we re-phrase this to skopeo directory transport version?
this version file is the version of directory transport, not skopeo version.

maybe also worth changing the class name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I fixed the docstring, but left the class as "Version" since it is scoped by the module "transport".


blob_src_path = os.path.join(self.get_working_dir(), checksum)
version_file_path = os.path.join(self.get_working_dir(), 'version')
transport_version = transport.Version.from_file(version_file_path)
Copy link
Member

Choose a reason for hiding this comment

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

i was just wondering, what would be wrong with the approach of getting the version like this https://github.com/pulp/pulp_docker/pull/235/files#diff-bd957746355aec66e333c744e73a128aR30 since it's the file that consists from 1 line and then just converting that to float?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is we need integer comparison for the number after the decimal. 1.19 > 1.2.

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.

please mind small suggestions

Adds comparators for a new class Version which represents a skopeo
directory transport version. This will allow us to easily support
future changes.

containers/image#419
fixes: #3703
@asmacdo asmacdo merged commit 26de4cc into pulp:master Jun 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants