Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(imagehandler): allow opting out of base updates #2003

Merged
merged 1 commit into from Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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