Skip to content

Commit

Permalink
feat: add --prod tag suffix to production visualisations
Browse files Browse the repository at this point in the history
This adds the "--prod" tag suffix to production Docker-based visualisations.

This is so we can add a lifecycle policy to clean up old previews, but prevent
the production visualisations, that would match "*--prod", from being deleted.

Note that before such a policy is added, we would need to manually add the
"*--prod" tag to all prod images in ECR.
  • Loading branch information
michalc committed Dec 10, 2024
1 parent ce59585 commit ca34fca
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions dataworkspace/dataworkspace/apps/applications/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ def visualisation_branch_html_GET(request, gitlab_project, branch_name):
production_commit_id = None
for tag in tags:
possible_host_basename, _, host_basename_or_commit_id = tag.rpartition("--")
if possible_host_basename:
if possible_host_basename and host_basename_or_commit_id != "prod":
production_commit_id = host_basename_or_commit_id
break

Expand Down Expand Up @@ -572,9 +572,26 @@ def visualisation_branch_html_GET(request, gitlab_project, branch_name):

def visualisation_branch_html_POST(request, gitlab_project, branch_name):
release_commit = request.POST["release-commit"]

# A "release" of a visualisation adds adds two tags to the previously generated image
# for that commit
#
# 1. A tag with the basename of the visualistion but "--prod" appended. This is so it can match
# an ECR lifecycle rule that does _not_ expire images that end in "--prod"
# 2. A tag with the basename of the visualisation. This is then used to identify and so run
# the released visualisation
#
# In a future release we could simplify and toughen this and only use the "--prod".
application_template = _application_template(gitlab_project)
get_spawner(application_template.spawner).retag(
application_options(application_template),
spawner = get_spawner(application_template.spawner)
options = application_options(application_template)
spawner.retag(
options,
f"{application_template.host_basename}--{release_commit}",
f"{application_template.host_basename}--prod",
)
spawner.retag(
options,
f"{application_template.host_basename}--{release_commit}",
application_template.host_basename,
)
Expand Down

0 comments on commit ca34fca

Please sign in to comment.