#1878 Chroot aliases maintained in database, not in config
Closed: MIGRATED a year ago by nikromen. Opened 2 years ago by praiskup.

This is follow up from https://pagure.io/copr/copr/pull-request/1875

I enjoyed the thinking moment on this, so no problem if we scratched
this idea in the future.

I think that the ideal approach would be to maintain the chroot aliases in
a database (for the repo file generator). And also, maintain symbolic links
on the backend side -- so we should have a new action (add/remove) on the
backend side taking care of the symbolic links.

We could avoid manual changes in httpd configuration (redirects) and
manual edits of coprs.conf (CHROOT ALIAS).

We should have four new logic methods:

ChrootAliasLogic.add(from_name_release, to_name_release)
ChrootAliasLogic.remove(from_name_release)  // not needed now
ChrootAliasLogic.change(from_name_release, new_to_name_release)
ChrootAliasLogic.sync()  // called by all the above

We need the change method because we need to drop and re-create the
symbolic link in one step (as atomic as possible).

Then, on FE, we should have two routes. (a) something like
/backend/aliases-all/ and (b) /backend/aliases/<owner>/<dirname>/.

The expensive route (a) would be used by Action on the backend side to
converge the links in all projects, upon the .sync() method call.

The (relatively) cheap route (b) would be used on each CoprDir change, to
converge the related backend data. E.g. when a new chroot is enabled in
the project, or when a new CoprDir is created.

Backend action pseudocode?

def sync-all():
  all_projects = get_all_aliases_from_frontend()
  for dirs, aliases in all_projects:
    for dir in dirs:
      sync_aliases_in_dir(dir, aliases)

def sync_project(project):
  dirs, aliases = get_aliases_from_frontend_for(project)
  sync_aliases_in_dir(dir, aliases)

def sync_aliases_in_dir(dir, aliases):
  // cleanup non-existing aliases
  for symlink in dir:
    if symlink in aliases and destination matches the alias:
      continue
    unlink(symlink)

  // sync aliases
  for from, to in aliases:
    if from exists and is not a symlink:
      // error out, this should be a symbolic link and we should
      // fix the directory manually
      continue

    if from doesn't exist:
      // new alias
      create symlink

The benefit here is that we could rename chroots easily in the future, as
we did for the centos-stream-x86_64 => centos-stream-8-x86_64.

We could do this in copr-frontend branch-fedora 35, simply changes
alias from fedora-34 => fedora-rawhide to fedora-35 => fedora-rawhide.


Metadata Update from @nikromen:
- Issue close_status updated to: MIGRATED
- Issue status updated to: Closed (was: Open)

a year ago

Login to comment on this ticket.

Metadata