Skip to content

Commit 4c9e1dd

Browse files
authored
Merge pull request #3394 from uktrade/feat/add-prod-to-production-visualisations
feat: add --prod tag suffix to production visualisations to help cleanup old ones
2 parents ce59585 + 954588f commit 4c9e1dd

File tree

1 file changed

+21
-3
lines changed
  • dataworkspace/dataworkspace/apps/applications

1 file changed

+21
-3
lines changed

dataworkspace/dataworkspace/apps/applications/views.py

+21-3
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ def visualisation_branch_html_GET(request, gitlab_project, branch_name):
522522
production_commit_id = None
523523
for tag in tags:
524524
possible_host_basename, _, host_basename_or_commit_id = tag.rpartition("--")
525-
if possible_host_basename:
525+
if possible_host_basename and host_basename_or_commit_id != "prod":
526526
production_commit_id = host_basename_or_commit_id
527527
break
528528

@@ -572,9 +572,27 @@ def visualisation_branch_html_GET(request, gitlab_project, branch_name):
572572

573573
def visualisation_branch_html_POST(request, gitlab_project, branch_name):
574574
release_commit = request.POST["release-commit"]
575+
576+
# A "release" of a visualisation adds two tags to the previously generated image for that
577+
# commit
578+
#
579+
# 1. A tag with the basename of the visualistion but "--prod" appended. This is so it can match
580+
# an ECR lifecycle rule that does _not_ expire images that end in "--prod" (or at least,
581+
# expires them in an extremely long time like 1000 years)
582+
# 2. A tag with the basename of the visualisation. This is then used to identify and so run
583+
# the released visualisation
584+
#
585+
# In a future release we could simplify and toughen this and only use the "--prod".
575586
application_template = _application_template(gitlab_project)
576-
get_spawner(application_template.spawner).retag(
577-
application_options(application_template),
587+
spawner = get_spawner(application_template.spawner)
588+
options = application_options(application_template)
589+
spawner.retag(
590+
options,
591+
f"{application_template.host_basename}--{release_commit}",
592+
f"{application_template.host_basename}--prod",
593+
)
594+
spawner.retag(
595+
options,
578596
f"{application_template.host_basename}--{release_commit}",
579597
application_template.host_basename,
580598
)

0 commit comments

Comments
 (0)