Skip to content

Commit 6a33d58

Browse files
committed
Harbor: remove dangling ubi9 rust builder artifacts as well
1 parent a263975 commit 6a33d58

File tree

1 file changed

+44
-39
lines changed
  • tools/harbor-garbage-collector/src

1 file changed

+44
-39
lines changed

tools/harbor-garbage-collector/src/main.rs

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -131,51 +131,56 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
131131

132132
// Cleanup old rust builder artifacts, they don't get garbage collected by Harbor because all of them are tagged
133133
// Only keep the "latest" manifest and its referenced artifacts
134-
let latest_rust_builder_manifest_list: Artifact = reqwest::Client::new()
135-
.get(format!(
136-
"{}/projects/sdp/repositories/ubi8-rust-builder/artifacts/latest",
134+
135+
for ubi_version in &["ubi8", "ubi9"] {
136+
let latest_rust_builder_manifest_list: Artifact = reqwest::Client::new()
137+
.get(format!(
138+
"{}/projects/sdp/repositories/{}-rust-builder/artifacts/latest",
139+
base_url,
140+
ubi_version
141+
))
142+
.send()
143+
.await?
144+
.json()
145+
.await?;
146+
147+
let referenced_digests = latest_rust_builder_manifest_list
148+
.references
149+
.unwrap()
150+
.into_iter()
151+
.map(|reference| reference.child_digest)
152+
.collect::<Vec<String>>();
153+
154+
let rust_builder_artifacts: Vec<Artifact> = reqwest::get(format!(
155+
"{}/projects/sdp/repositories/{}-rust-builder/artifacts?page_size=100",
137156
base_url,
157+
ubi_version
138158
))
139-
.send()
140159
.await?
141160
.json()
142161
.await?;
143162

144-
let referenced_digests = latest_rust_builder_manifest_list
145-
.references
146-
.unwrap()
147-
.into_iter()
148-
.map(|reference| reference.child_digest)
149-
.collect::<Vec<String>>();
150-
151-
let rust_builder_artifacts: Vec<Artifact> = reqwest::get(format!(
152-
"{}/projects/sdp/repositories/ubi8-rust-builder/artifacts?page_size=100",
153-
base_url
154-
))
155-
.await?
156-
.json()
157-
.await?;
158-
159-
for artifact in rust_builder_artifacts {
160-
// Keep "latest" and its referenced artifacts
161-
if artifact.digest != latest_rust_builder_manifest_list.digest
162-
&& !referenced_digests.contains(&artifact.digest)
163-
{
164-
println!(
165-
"Removing dangling rust builder artifact {}",
166-
artifact.digest
167-
);
168-
reqwest::Client::new()
169-
.delete(format!(
170-
"{}/projects/sdp/repositories/ubi8-rust-builder/artifacts/{}",
171-
base_url, artifact.digest
172-
))
173-
.basic_auth(
174-
"robot$stackable-cleanup",
175-
env::var("HARBOR_ROBOT_PASSWORD").ok(),
176-
)
177-
.send()
178-
.await?;
163+
for artifact in rust_builder_artifacts {
164+
// Keep "latest" and its referenced artifacts
165+
if artifact.digest != latest_rust_builder_manifest_list.digest
166+
&& !referenced_digests.contains(&artifact.digest)
167+
{
168+
println!(
169+
"Removing dangling rust builder artifact {}",
170+
artifact.digest
171+
);
172+
reqwest::Client::new()
173+
.delete(format!(
174+
"{}/projects/sdp/repositories/{}-rust-builder/artifacts/{}",
175+
base_url, ubi_version, artifact.digest,
176+
))
177+
.basic_auth(
178+
"robot$stackable-cleanup",
179+
env::var("HARBOR_ROBOT_PASSWORD").ok(),
180+
)
181+
.send()
182+
.await?;
183+
}
179184
}
180185
}
181186

0 commit comments

Comments
 (0)