Skip to content
This repository was archived by the owner on Dec 20, 2025. It is now read-only.

Commit 6862466

Browse files
authored
feat(imagehandler): allow opting out of base updates (#2003)
Allow setting `ignoreBaseUpdates` in vmOptions to skip rebaking/deploying when new base images are available.
1 parent 346c09c commit 6862466

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

keel-api/src/main/kotlin/com/netflix/spinnaker/keel/api/artifacts/VirtualMachineOptions.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ data class VirtualMachineOptions(
77
val baseLabel: BaseLabel = RELEASE,
88
val baseOs: String,
99
val regions: Set<String>,
10-
val storeType: StoreType = EBS
10+
val storeType: StoreType = EBS,
11+
val ignoreBaseUpdates: Boolean = false
1112
)

keel-bakery-plugin/src/main/kotlin/com/netflix/spinnaker/keel/bakery/artifact/ImageHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class ImageHandler(
7272
log.info("No AMI found for {}", desiredAppVersion)
7373
launchBake(artifact, desiredAppVersion)
7474
}
75-
imagesWithOlderBaseImages.isNotEmpty() -> {
75+
imagesWithOlderBaseImages.isNotEmpty() && !artifact.vmOptions.ignoreBaseUpdates -> {
7676
log.info("AMIs for {} are outdated, rebaking…", desiredAppVersion)
7777
launchBake(
7878
artifact,

keel-bakery-plugin/src/test/kotlin/com/netflix/spinnaker/keel/bakery/artifact/ImageHandlerTests.kt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ internal class ImageHandlerTests : JUnit5Minutests {
6262
storeType = EBS
6363
)
6464
)
65+
val artifactIgnoreBaseUpdates = DebianArtifact(
66+
name = "keel",
67+
deliveryConfigName = "delivery-config",
68+
vmOptions = VirtualMachineOptions(
69+
baseLabel = RELEASE,
70+
baseOs = "xenial",
71+
regions = setOf("us-west-2", "us-east-1"),
72+
storeType = EBS,
73+
ignoreBaseUpdates = true,
74+
)
75+
)
6576
val deliveryConfig = deliveryConfig(
6677
configName = artifact.deliveryConfigName!!,
6778
artifact = artifact
@@ -518,6 +529,40 @@ internal class ImageHandlerTests : JUnit5Minutests {
518529
}
519530
}
520531
}
532+
533+
context("newer base exists, but artifact ignores new bases") {
534+
before {
535+
val newerBaseAmiVersion = "nflx-base-5.380.0-h1234.8808866"
536+
every {
537+
baseImageCache.getBaseAmiName(
538+
artifactIgnoreBaseUpdates.vmOptions.baseOs,
539+
artifactIgnoreBaseUpdates.vmOptions.baseLabel,
540+
)
541+
} returns newerBaseAmiVersion
542+
543+
every { repository.artifactVersions(artifactIgnoreBaseUpdates, any()) } returns listOf(
544+
artifactVersion
545+
)
546+
547+
every {
548+
imageService.getLatestNamedImage(any(), any(), any(), any())
549+
} returns image
550+
551+
every { repository.getArtifactVersion(artifactIgnoreBaseUpdates, appVersion, null) } returns PublishedArtifact(
552+
name = artifact.name,
553+
reference = artifact.reference,
554+
version = appVersion,
555+
type = DEBIAN,
556+
metadata = emptyMap()
557+
)
558+
559+
runHandler(artifactIgnoreBaseUpdates)
560+
}
561+
562+
test("a bake is not launched") {
563+
expectThat(bakeTask).isNotCaptured()
564+
}
565+
}
521566
}
522567
}
523568
}

0 commit comments

Comments
 (0)