Pulp
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Help
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# relative_path problem ### Agenda * Existing design and the Problem * Potentially valid proposals and their pros/cons * Discussion and/or brainstorm more ideas ### Use cases * As a user, I can publish the same content in different repos under different relative paths. * As a user, I can mirror repository metadata ### Problem Currently, a "relative_path" is tied to ContentArtifact in Pulp. This means that either a content unit can't exist in two places within a repository or across repositories with different relative paths, or it has to be stored as two separate content units. This creates redundant data and potential confusion for users. As a specific example, we need to support mirroring content in pulp_rpm. Currently, for each location at which a single package is stored, we’ll need to create a content unit. We could end up with several records representing a single package. Users may be confused about why they see multiple records for a package and they may have trouble for example deciding which content unit to copy. ### Existing Design *Open in new tab to see a larger image.* ![current models](https://i.imgur.com/gyQ5i90.png) ### Potentially valid proposals #### pulp_deb / pulp_file way Have a relative_path as a part of a content unit uniqueness constraint. Solves the problem of having a content unit in two places within a repository - but not the problem of having many duplicate content units. Metadata mirroring is handled by having special content units for metadata storage. Pros: * no changes in pulpcore * plugin is in control if they need this feature or not * easy to implement Cons: * doesn't solve the content duplication concern * multi-artifact content can't leverage that * it's confusing for users to see a list of same content and choose which one to copy. #### Additive changes only Our existing data model stays the same, we just add the following model. RepositoryContentContentArtifact repo_content (models.ForeignKey): The associated RepositoryContent content_artifact (models.ForeignKey): The associated ContentArtifact relative_path (str): The relative path for this relationship unique_together = (repo_content, content_artifact, relative_path) *Open in new tab to see a larger image.* ![proposal3](https://i.imgur.com/sInWfpk.png) Metadata mirroring is handled by having special content units for metadata storage. Pros: * no change to existing relations * multi-artifact content is handled * avoids the duplicate content problem * general solution * simple data migration Cons: * one more table to deal with for every piece of content * performance impact? * complicated db schema * many places need adjustments (stages, content app, etc) * relative_path info is present in multiple places and somewhat duplicated * might need REST API changes * copy API is difficult, need to provide relative_path for each content or find a convention for defaults #### relative_path in PublishedArtifact only There is no work that we can usefully do at publish time for a mirrored RPM repo because the metadata and locations must be an ***exact*** replica of the original repository. Since all of this information is available to us at sync-time, the proposal in this case is to simply create a Publication (save PublishedArtifacts and PublishedMetadata) at sync time, directly. This allows to have the same content published in many locations without needing to temporarily store it somewhere else to use later during publish, avoiding any model changes. ##### Simple version Pros: * no model changes * no data migration * (mostly) avoids the duplicate content problem * avoids needing to have special models for mirroring metadata Cons: * Doesn't solve the problem in a generalized way, would still be on the plugin writer to implement * Doesn't solve the duplicate content problem for productID (we have a workaround for this currently) * RPM sync gets a complicated special case * Possibly some minor workflow differences due to no separate publish <!-- I realized that we don't actually *need* to make the ContentArtifact change, it would just "make sense" to do given the general idea of what we're trying to go for. But it makes equally as much sense to do with proposal 2, as you say 'relative_path' is duplicated in many places. --> ##### More complicated version (generalization) We could take this idea further and make it generalized, but it would have a lot of the same drawbacks as Proposal 2. Applying it outside of the mirrored metadata case means that you need to be concerned with copy, and the need to provide a location along with the content unit, or reading locations from existing PublishedArtifacts. It would also mean, probably, adding this feature to DeclarativeVersion somehow. Pros: * all of the above from previous * generalized, also applies to multi-artifact content Cons: * might need REST API changes * copy API is difficult, need to provide relative_path for each content or find a convention for defaults * copy might need to involve PublishedArtifacts (not universally, just for the plugins that utilize this) * big changes needed to stages & add/remove content ### Discussion Observation: There are really 2 different types of publishable repositories. 1. Repositories where there the layout matters, and there is one and *only* one appropriate layout for artifacts. * e.g. file repositories, "mirrored" RPM repositories * "relative_path" is absolute, it's the full path. * in a mirrored RPM repo, you can't move `packages/d/dog.rpm` to `packages/dog.rpm`, nor can you rearrange the structure of a file repo. * very little needs to happen at publish time because there's not much that you can change 2. Repositories where republishing in different layouts is possible, "layout doesn't matter". * e.g. standard RPM repositories and python repositories * "relative_path" is floating, it's really just the filename. The location of this file within the repository can vary depending on the publish-time options and it won't meaningfully affect the consumer. * a non-mirrored RPM repo can be published in different ways, you *can* move `packages/d/dog.rpm` to `packages/dog.rpm * same with Python repositories --- ### Considered Proposals #### Proposal I (skip, no solution for multi-artifact content) Create a RepositoryContentArtifact which maps ContentArtifact and its relative path. RepositoryContent has foreign key to a RepositoryContentArtifact instead of Content. RepositoryContentArtifact content_artifact (models.ForeignKey): The associated content artifact. relative_path (str): the relative path of an artifact in a repository RepositoryContent repo_content_artifact (models.ForeignKey): The associated RepositoryContentArtifact repository (models.ForeignKey): The associated repository. version_added (models.ForeignKey): The RepositoryVersion which added the referenced Content. version_removed (models.ForeignKey): The RepositoryVersion which removed the referenced Content. ##### Code Changes * Stages API: `Content` should no longer be associated with a `Repository`. `RepositoryContentArtifact` should be associated with a repository. Plugin writers need to create `DeclarativeRepositoryContentArtifacts`. Associating `Content` with a `Repository`, need to create a `RepositoryContentArtifact` for every `ContentArtifact` and associate the `RepositoryContentArtifact` with the `Repository`. * Content App: Need to update query to inspect `RepositoryContent.artifact.relative_path` directly and serve the associated `RepositoryContent.artifact.content_artifact` * Complex migration is needed ##### Questions? * How does this work with multi-artifact content?Q: how to list multi-artifact content? Seems like it has a lot of downsides and few if any upsides compared to other proposals. #### Proposal II (skip, no solution for multi-artifact content) Inspired by proposal I. Use `ContentArtifact.relative_path`. RepositoryContent has foreign key to ContentArtifact instead of Content. RepositoryContent content_artifact (models.ForeignKey): The associated ContentArtifact ### Q: how to list multi-artifact content - get all content through content_artifact and then show unique items? repository (models.ForeignKey): The associated repository. version_added (models.ForeignKey): The RepositoryVersion which added the referenced Content. version_removed (models.ForeignKey): The RepositoryVersion which removed the referenced Content. ##### Code Changes * Stages API * Content App * Complex migration is needed ##### Questions? * How does this work with multi-artifact content? * Performance concern to search content by a repo version #### Proposal III Everything stays the same, we just add the following model. RepositoryContentContentArtifact repo_content (models.ForeignKey): The associated RepositoryContent content_artifact (models.ForeignKey): The associated ContentArtifact relative_path (str): The relative path for this relationship unique_together = (repo_content, content_artifact, relative_path) *Open in new tab to see a larger image.* ![proposal3](https://i.imgur.com/sInWfpk.png) ##### Code Changes * Stages API * Content app * Copy workflow * Migration: no changes in existing models/tables ##### Questions * Does it create a circular reference? * Performance concerns? #### Proposal IV Observation: There are really 2 different types of publishable repositories. 1. Repositories where there the layout matters, and there is one and *only* one appropriate layout for artifacts. * e.g. file repositories, "mirrored" RPM repositories * "relative_path" is absolute, it's the full path. * in a mirrored RPM repo, you can't move `packages/d/dog.rpm` to `packages/dog.rpm`, nor can you rearrange the structure of a file repo. * very little needs to happen at publish time because there's not much that you can change 2. Repositories where republishing in different layouts is possible, "layout doesn't matter". * e.g. standard RPM repositories and python repositories * "relative_path" is floating, it's really just the filename. The location of this file within the repository can vary depending on the publish-time options and it won't meaningfully affect the consumer. * a non-mirrored RPM repo can be published in different ways, you *can* move `packages/d/dog.rpm` to `packages/dog.rpm * same with Python repositories Our problems are rooted in trying to serve both needs with the same `relative_path` mechanism, *especially* in the RPM plugin where repositories could behave either way and content synced or uploaded into one must be cross-compatible. We're currently trying to push this problem outside of the domain of "content uniqueness" where it is causing us the most immediate issues, but it might be better to rethink what we are trying to do here and avoid mixing the two entirely. Observation: We already have a mechanism for handling absolute, locked in paths. The `RepositoryContentArtifact` model from Proposal 1 is actually completely identical to `PublishedArtifact` except for the latter's extra PK to `Publication`. There will be a perfect 1-to-1 duplication between `RepositoryContentArtifact` and `PublishedArtifact` - is this actually productive? The entire purpose of storing the content_artifact-relative_path relationship to begin with is to have somewhere to hold it until publication time, when we copy it into the `PublishedArtifact` table. If we know all of that information up-front, why bother with a middleman? `RepositoryContentContentArtifact` from Proposal 3 is also *mostly* identical to `PublishedArtifact`. Proposal: * Rename "relative_path" to "filename" and rewrite existing ones to be just the filename * Add a nullable `Publication` column to the `RepositoryVersion` model and have the serializer only show it if it is "complete" * No new models added, and `ContentArtifact` and `RepositoryContent` remain exactly the same * Migration would be simple * Hardest part would be stripping the path prefix from the "filename" * Repository modification needs a "special case" for "Type 1" repositories - need to add/remove `PublishedArtifact` at the same time as `RepositoryContent`. * This possibly means that `Repository` / `RepositoryVersion` code needs to know what "type" of repository it is to know how it should behave? * Mirrored RPM repositories need to disallow modification, anyway, so we need to keep track of this somewhere. Within repositories that require "absolute" paths, instead of storing the full path somewhere within the "artifact-content-relationship-complex", we just create an incomplete `Publication` for the repository version and save the `PublishedArtifact`s directly. In the general case (e.g. the file plugin), at publish time, the only thing which must happen is to write the metadata, utilizing a query on `PublishedArtifact`. In the case of mirrored RPM repositories, we can go further, and simply finish the entire `Publication` at sync time. We save the metadata directly as `PublishedMetadata`, save our `PublishedArtifacts`, and we're done. Future attempts to publish the repo version become a no-op (or maybe an error) and we probably need some mechanism to block manual modifications. Q: Where does saving `PublishedArtifact`s need to happen? A: It could be done in either the plugin or DeclarativeVersion or RepositoryVersion.add_content() itself... I think it makes the most sense in RepositoryVersion.add_content(), however in that case it must have knowledge about the repository and the content type to decide whether doing so is appropriate Q: How does copy work? A: I'm not sure, but there's some fundamental problems here aren't really tied to any specific proposal. Using the file plugin as an example, if we extract the location of a content unit within the repository from the content unit itself, then that means that when copying that unit into another repository we need to provide that location somehow, which our repo modification API has no provision for. We'll have this problem regardless of which proposal we use. Something which is more specific to this proposal is the fact that copy would now involve `PublishedArtifact`s as well in some circumstances. But if we're adding a new model, we'd have the same sort of concerns as well. Q: How does it work for plugins which do not need a Publication? (is it safe to strip the relative_path to the filename in such case) A: ? need feedback from these plugins on the subject of 'relative_path'. I wouldn't expect any other part of the proposal would be problematic though. * it's ok fo the container plugin * it's ok for the rpm plugin #### Proposal V No changes in pulpcore for the relative path. Have a separate content type for mirrored metadata. All plugins/content units carry relative path themselves. #### Proposal VI (pulp_deb solution) No changes in pulpcore. Have relative_path added to all content types natural_key. Bite the bullet that you can have the same content unit multiple times with different relative_path if they are found in different places (Artifacts stay deduplicated). Downside: This only works with content_units that have at most one file associated. Q: How is it different from the Proposal 5? ### Questions Q1: How does copy work with these proposals? (Any of them, really). Once "relative_path" is removed as a direct property of a content unit and content (say a file) can exist at different locations in different repos, and/or multiple different paths in the same repo, it becomes impossible to say "add this content unit to a repository" without answering the question "where" for content types where the location matters. A: If the current `relative_path` from ContentArtifact is renamed to a `filename`. It can be used as a default relative_path. Or during copy the configured relative path for that repo is used. How does that sound? ###### tags: `PulpCon 2020`

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully