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

pgsql: Change layer name column data type #382

Merged
merged 1 commit into from
May 20, 2017
Merged

pgsql: Change layer name column data type #382

merged 1 commit into from
May 20, 2017

Conversation

caipre
Copy link
Contributor

@caipre caipre commented May 2, 2017

Presently the layer.name column has type varchar(128). This works
fine enough when using the sha256 layer digests provided by docker.
However, if one wishes to encode the image name into the layer (eg, to
avoid collisions like in #319),
the limit of 128 bytes becomes a bit cramped.

I've configured my client to name layers using the docker layer digest

sha256:21a547c3a96a390f700a68bc506a26e5c6e8f129fce41e05485d907d7fc130c1

concatenated with sha256(image.name, image.tag, layer.parent.digest):

69429e10ce617a247feca82cf50ffc9bd071c1184e6910872f26b5c3d37325d3

This change allows the name column to support such a format.

@caipre
Copy link
Contributor Author

caipre commented May 2, 2017

If this change is acceptable, I'm happy to write the migration code as well.

@Quentin-M
Copy link
Contributor

Quentin-M commented May 2, 2017

Hey,

We do actually use a combination of a few things as well in production. I'd be happy to merge this thing, but wondering if there is any performance hit involved here at scale?

Also, I believe you'd need to make a new migration, do not modify old ones, it might break existing deployments. We have a few casts here and there, I'd verify if there is any applying to that field.

Thanks!

@caipre
Copy link
Contributor Author

caipre commented May 2, 2017

@Quentin-M : Thanks for the review; I've updated the commit to do a migration rather than modify the initial schema. I looked into the Postgres docs and they claim there is no performance penalty: text and varchar share the same implementation underneath. I also didn't see any casts on these columns, but I'm not sure where in the codebase they might be.

@caipre
Copy link
Contributor Author

caipre commented May 15, 2017

@Quentin-M Mind taking another look at this?

@jzelinskie
Copy link
Contributor

This change looks good from the database-side; however, I do think there should be some limit via the API to prevent DoS. I think we need to discuss a fair length and then add another commit to enforce this at the API before merging.

@caipre
Copy link
Contributor Author

caipre commented May 17, 2017

@jzelinskie That's a valid concern. How would you like to proceed? For my purposes, the column need not be unbounded. Perhaps just bumping the width up to varchar(256) would be more agreeable?

@jzelinskie
Copy link
Contributor

@caipre This sounds fair. If you're quick, I'll cut this in v2.0.0.

@caipre
Copy link
Contributor Author

caipre commented May 19, 2017

Looks like I missed the release, but I've updated the commit.

Presently the layer and namespace tables use type `varchar(128)` for
their respective name columns. For layer, this width works fine enough
using the sha256 digests provided by docker. However, if one wishes to
encode the image name into the layer  name (eg, to avoid collisions like
in [0]), the limit of 128 bytes starts to feel a bit cramped. Bump to
256 bytes, since that "ought to be enough for anybody." (TM)

[0]: #319
Copy link
Contributor

@jzelinskie jzelinskie left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for the PR. Sorry about the rush for v2.0.0.

@jzelinskie jzelinskie merged commit c2d8aec into quay:master May 20, 2017
@caipre caipre deleted the patch-1 branch May 20, 2017 05:42
jzelinskie added a commit that referenced this pull request Jun 19, 2017
pgsql: Change layer name column data type
KeyboardNerd pushed a commit to KeyboardNerd/clair that referenced this pull request Feb 2, 2018
pgsql: Change layer name column data type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants