Skip to content

Commit

Permalink
feat(imagehandler): allow opting out of base updates (spinnaker#2003)
Browse files Browse the repository at this point in the history
Allow setting `ignoreBaseUpdates` in vmOptions to skip rebaking/deploying when new base images are available.
  • Loading branch information
dmart authored and osoriano committed Sep 2, 2023
1 parent 38b0116 commit b0184da
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
Expand Up @@ -7,5 +7,6 @@ data class VirtualMachineOptions(
val baseLabel: BaseLabel = RELEASE,
val baseOs: String,
val regions: Set<String>,
val storeType: StoreType = EBS
val storeType: StoreType = EBS,
val ignoreBaseUpdates: Boolean = false
)
Expand Up @@ -72,7 +72,7 @@ class ImageHandler(
log.info("No AMI found for {}", desiredAppVersion)
launchBake(artifact, desiredAppVersion)
}
imagesWithOlderBaseImages.isNotEmpty() -> {
imagesWithOlderBaseImages.isNotEmpty() && !artifact.vmOptions.ignoreBaseUpdates -> {
log.info("AMIs for {} are outdated, rebaking…", desiredAppVersion)
launchBake(
artifact,
Expand Down
Expand Up @@ -62,6 +62,17 @@ internal class ImageHandlerTests : JUnit5Minutests {
storeType = EBS
)
)
val artifactIgnoreBaseUpdates = DebianArtifact(
name = "keel",
deliveryConfigName = "delivery-config",
vmOptions = VirtualMachineOptions(
baseLabel = RELEASE,
baseOs = "xenial",
regions = setOf("us-west-2", "us-east-1"),
storeType = EBS,
ignoreBaseUpdates = true,
)
)
val deliveryConfig = deliveryConfig(
configName = artifact.deliveryConfigName!!,
artifact = artifact
Expand Down Expand Up @@ -518,6 +529,40 @@ internal class ImageHandlerTests : JUnit5Minutests {
}
}
}

context("newer base exists, but artifact ignores new bases") {
before {
val newerBaseAmiVersion = "nflx-base-5.380.0-h1234.8808866"
every {
baseImageCache.getBaseAmiName(
artifactIgnoreBaseUpdates.vmOptions.baseOs,
artifactIgnoreBaseUpdates.vmOptions.baseLabel,
)
} returns newerBaseAmiVersion

every { repository.artifactVersions(artifactIgnoreBaseUpdates, any()) } returns listOf(
artifactVersion
)

every {
imageService.getLatestNamedImage(any(), any(), any(), any())
} returns image

every { repository.getArtifactVersion(artifactIgnoreBaseUpdates, appVersion, null) } returns PublishedArtifact(
name = artifact.name,
reference = artifact.reference,
version = appVersion,
type = DEBIAN,
metadata = emptyMap()
)

runHandler(artifactIgnoreBaseUpdates)
}

test("a bake is not launched") {
expectThat(bakeTask).isNotCaptured()
}
}
}
}
}
Expand Down

0 comments on commit b0184da

Please sign in to comment.