# Alternate Content Sources - https://pulp.plan.io/issues/7832 ## Models ### AlternateContentSource (MasterModel) `` pulpcore.plugin.models.AlternateContentSource`` MasterModel * name - a string, the name. A required field. * <s>enabled - an optional boolean, defaults to True</s> * remote - a ForeignKey to a remote, this is required as the remote defineds how the ACS can sync. ### AlternateContentSourceRepository (AlternateContentSourcePath?) * alternate_content_source - fk to AlternateContentSource * repository - fk to repository (hidden) * paths - Each must validate as a string path. It must not include a slash at the beginning of each. * Optional - If unspecified, only the base_path will be used when the AlternateContentSource is refreshed. ### Repository (exists) * user_hidden - https://github.com/pulp/pulpcore/pull/1223 * Each ACS path will create a hidden repo * Can be set to always keep 1 version +1 ## API Endpoints Create: ``` POST /pulp/api/v3/acs/rpm/rpm/ remote=/pulp/api/v3/remotes/.../.../ name=ACS_name_foo enabled=true paths:=[ "beta/rhel/server/7/x86_64/satellite/6/os/", "eus/rhel/server/7/7.3/x86_64/os/"] { "pulp_href": "/pulp/api/v3/acs/rpm/rpm/:uuid/", "name": "ACS_name_foo", "remote": "/pulp/api/v3/remotes/rpm/rpm/:uuid/", "paths": ["beta/rhel/server/7/x86_64/satellite/6/os/", "eus/rhel/server/7/7.3/x86_64/os/"], "enabled": True, } ``` Read: ``` GET /pulp/api/v3/acs/rpm/rpm/:uuid/ { "pulp_href": "/pulp/api/v3/acs/rpm/rpm/:uuid/", "name": "ACS_name_foo", "remote": "/pulp/api/v3/remotes/rpm/rpm/:uuid/", "paths": ["beta/rhel/server/7/x86_64/satellite/6/os/", "eus/rhel/server/7/7.3/x86_64/os/"], "enabled": True, } ``` Update: (or Patch?) ``` PATCH /pulp/api/v3/acs/rpm/rpm/:uuid/ name="ACS_foo_name" paths:=["alpha/rhel/server/7/x86_64/satellite/6/os/"] { "pulp_href": "/pulp/api/v3/acs/rpm/rpm/:uuid/", "name": "ACS_name_foo", "remote": "/pulp/api/v3/remotes/rpm/rpm/:uuid/", "paths": ["beta/rhel/server/7/x86_64/satellite/6/os/", "eus/rhel/server/7/7.3/x86_64/os/"], "enabled": True, } ``` List: ``` GET /pulp/api/v3/acs/rpm/rpm/ { "count": 1, "next": null, "previous": null, "results": [ { "pulp_href": "/pulp/api/v3/acs/rpm/rpm/:uuid/", "name": "ACS_name_foo", "remote": "/pulp/api/v3/remotes/rpm/rpm/:uuid/", "paths": ["beta/rhel/server/7/x86_64/satellite/6/os/", "eus/rhel/server/7/7.3/x86_64/os/"], "enabled": True, }, ] } ``` Delete: ``` DELETE /pulp/api/v3/acs/rpm/rpm/:uuid/ { "task": "/pulp/api/v3/tasks/bf2d0fe1-2516-4c13-9b56-04e7646e6f14/" } ``` Refresh: ``` POST /pulp/api/v3/acs/rpm/rpm/:uuid/refresh/ { "task": "/pulp/api/v3/tasks/bf2d0fe1-2516-4c13-9b56-04e7646e6f14/" } ``` same as sync ## Questions * Can there be more than one ACS per repo type? * Have multiple instances per type * Don't worry about the enabled flag for now * We'd need to figure out how to support enabled vs disabled remote artifacts at sync time (tricky/complex) * What happens when user wants ACS for two repositories (e.g. base & apps)? * "As user I want ACS for two or more repositories with different remotes" * we will have multiple ACS instances for per repo type * How do we handle the case where plugins might have 2+ types of repos? * One ACS type per repo type * What happens when I delete an ACS? What happens when I remove/add a path? * It cleans up the hidden repositories * What to do about remote artifacts? * RemoteArtifacts can be deleted by deleting the Remote * Do we delete the remote? * No, let the user do it * Do we make ACS immutable or allow paths to be changed? * allow paths to be added/removed * What happens when I remove remote that is being used for ACS? * same problem with current remotes and RA * What happens when remote gets updated (e.g. remote.url)? * User will need to trigger refresh * Add last_refreshed field on the ACS - might be helpful information to know whether a re-fresh is needed? * yes * Is there a way to delete content produced by ACS? For example I don't want some local ACS content be preffered over CDN * https://docs.pulpproject.org/en/2.21/user-guide/content-sources.html?highlight=alternate#recipes * Delete the ACS and Remote * Deleting the ACS will delete the repos. Orphan cleanup will remove the content. * Deleting the Remote deletes the RemoteArtifacts * What to do with outdated ACS content? * use mirror mode * Which field can user update/patch? * use patch only for path field * Can ACS be viewed without typed plugins (like repo)? * <s>/pulp/api/v3/acs/ => all ACS</s> * /pulp/api/v3/acs/file/file/ => file ACS * Should paths only inherit certs from base remote or have option to have its own? * yes, base remote will be used everywhere * User hidden remotes (same as for repositories)? * no only one remote will be used to keep certs * When no paths specified auto create root one ('/'). When first path created afterwards should we remove root one or keep it and let user to decide? * when no path specified, root will be automatically created ## Ideas * check logs where from are content downloaded * add missing content to ACS to be found ## Action items * <s>Pavel do the API calls</s> * Pavel to share draft PR/branches * https://github.com/pulp/pulpcore/pull/1437 - core models * https://github.com/pulp/pulpcore/pull/1496 - core stage * https://github.com/pulp/pulp_file/pull/530 - file models * https://github.com/pulp/pulp_file/pull/536 - file refresh