Skip to content

Commit 511e71e

Browse files
feat: log when image has not been pulled in 7 days and is only tag
1 parent 3f42485 commit 511e71e

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

charts/ecr-cleanup/Chart.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ type: application
2020
# This is the chart version. This version number should be incremented each time you make changes
2121
# to the chart and its templates, including the app version.
2222
# Versions are expected to follow Semantic Versioning (https://semver.org/)
23-
version: 0.3.1
23+
version: 0.3.2
2424

2525
# This is the version number of the application being deployed. This version number should be
2626
# incremented each time you make changes to the application. Versions are not expected to
2727
# follow Semantic Versioning. They should reflect the version the application is using.
2828
# It is recommended to use it with quotes.
29-
appVersion: "0.3.1"
29+
appVersion: "0.3.2"

charts/ecr-cleanup/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Deploys a job that cleans up an ECR repo based on the following rules.
66
3. Has the container been tagged with the word `keep`
77
4. Is the container the only tag in the ECR repository
88

9-
![Version: 0.3.1](https://img.shields.io/badge/Version-0.3.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.3.1](https://img.shields.io/badge/AppVersion-0.3.1-informational?style=flat-square)
9+
![Version: 0.3.2](https://img.shields.io/badge/Version-0.3.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.3.2](https://img.shields.io/badge/AppVersion-0.3.2-informational?style=flat-square)
1010

1111
## Values
1212

main.py

+12
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,18 @@ def get_ecr_images(
176176
logger.info(
177177
f"Image {repository['repository_uri']}@{imageDetails[0]['imageDigest']} is the only image in the repository skipping"
178178
)
179+
if "lastRecordedPullTime" in imageDetails:
180+
last_pull_time = imageDetails["lastRecordedPullTime"]
181+
localized_now_ts = UTC.localize(datetime.now() - timedelta(7))
182+
if last_pull_time > localized_now_ts:
183+
logger.debug("The last pulltime was more than 7 days ago")
184+
logger.info(
185+
f"Image {repository['repository_uri']}@{imageDetails[0]['imageDigest']} is the only image in the repository skipping and hasn't been pulled in 7 days, consider deleting"
186+
)
187+
else:
188+
logger.info(
189+
f"Image {repository['repository_uri']}@{imageDetails[0]['imageDigest']} is the only image in the repository skipping and hasn't been pulled in 7 days, consider deleting"
190+
)
179191
break
180192
images = append_image(images, imageDetails, repository)
181193

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "ecr-image-cleanup-job"
3-
version = "0.2.1"
3+
version = "0.3.2"
44
description = ""
55
authors = ["Hans Knecht <[email protected]>"]
66
readme = "README.md"

0 commit comments

Comments
 (0)