-
Notifications
You must be signed in to change notification settings - Fork 143
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(artifact): introduce SKIPPED status, more data for previous #959
Conversation
promotion_reference has a special meaning currently, see i.e. https://github.com/spinnaker/keel/blob/master/keel-sql/src/main/kotlin/com/netflix/spinnaker/keel/sql/SqlArtifactRepository.kt#L488-L494. Repurposing it this way, without rewriting the existing use will probably break automated artifact version vetoing and rollbacks. |
|
||
context("there are two approved versions for the environment and the latter was deployed") { | ||
before { | ||
clock.incrementBy(Duration.ofHours(1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you think it's easier to read, you can now do clock.tickHours(1)
.
@@ -1,5 +1,32 @@ | |||
package com.netflix.spinnaker.keel.core.api | |||
|
|||
enum class PromotionStatus { | |||
PENDING, APPROVED, DEPLOYING, CURRENT, PREVIOUS, VETOED | |||
/** | |||
* Waiting on constraint evaluation before being approved |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for documenting the enum values! ❤️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1!
keel-sql/src/main/kotlin/com/netflix/spinnaker/keel/sql/SqlArtifactRepository.kt
Outdated
Show resolved
Hide resolved
keel-sql/src/main/kotlin/com/netflix/spinnaker/keel/sql/SqlArtifactRepository.kt
Outdated
Show resolved
Hide resolved
😍 fantastic! Just for my own clarification: does this also modify the behavior of |
.where(ENVIRONMENT_ARTIFACT_VERSIONS.ENVIRONMENT_UID.eq(environmentUid)) | ||
.and(ENVIRONMENT_ARTIFACT_VERSIONS.ARTIFACT_UID.eq(artifact.uid)) | ||
.and(ENVIRONMENT_ARTIFACT_VERSIONS.PROMOTION_STATUS.eq(APPROVED.name)) | ||
.and(ENVIRONMENT_ARTIFACT_VERSIONS.ARTIFACT_VERSION.`in`(*approvedButOld.toTypedArray())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does the star in *approvedButOld
? does? just wondering since I haven't seen this pattern here before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It takes a list of strings and turns it into whatever form sql needs to actually be able to tell whether a string is in a list of strings :D
15f690e
to
e6334cf
Compare
Updated this PR to address my accidental misuse of the |
.../src/main/kotlin/com/netflix/spinnaker/keel/persistence/ApplicationSummaryGenerationTests.kt
Outdated
Show resolved
Hide resolved
fun isHigher(artifact: DeliveryArtifact, new: String, existing: String): Boolean = | ||
artifact.versioningStrategy.comparator.compare(new, existing) < 0 | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General question - we are relaying here on the fact that a newer version will get the higher number. is it always the case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! It is always the case that we are deciding which is the newer version by this comparator, and "higher" version will always be newer. It's one of our core artifact assumptions. It's definitely an assumption, but it's what allows us to do cool artifact things.
keel-core/src/main/kotlin/com/netflix/spinnaker/keel/persistence/ArtifactRepository.kt
Outdated
Show resolved
Hide resolved
.../src/main/kotlin/com/netflix/spinnaker/keel/persistence/ApplicationSummaryGenerationTests.kt
Outdated
Show resolved
Hide resolved
.../src/main/kotlin/com/netflix/spinnaker/keel/persistence/ApplicationSummaryGenerationTests.kt
Outdated
Show resolved
Hide resolved
.../src/main/kotlin/com/netflix/spinnaker/keel/persistence/ApplicationSummaryGenerationTests.kt
Outdated
Show resolved
Hide resolved
keel-core/src/main/kotlin/com/netflix/spinnaker/keel/core/api/EnvironmentSummary.kt
Show resolved
Hide resolved
The PR description says:
What does when an artifact is marked as |
keel-sql/src/main/kotlin/com/netflix/spinnaker/keel/sql/SqlArtifactRepository.kt
Outdated
Show resolved
Hide resolved
.and(ENVIRONMENT_ARTIFACT_VERSIONS.ARTIFACT_VERSION.ne(version)) | ||
.execute() | ||
// update any past artifacts that were "APPROVED" to be "SKIPPED | ||
// // because the new version takes precedence |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// // because the new version takes precedence | |
// because the new version takes precedence |
keel-core/src/main/kotlin/com/netflix/spinnaker/keel/persistence/ArtifactRepository.kt
Outdated
Show resolved
Hide resolved
keel-core/src/main/kotlin/com/netflix/spinnaker/keel/persistence/ArtifactRepository.kt
Outdated
Show resolved
Hide resolved
/** | ||
* Marks a version of an artifact as skipped for an environment, with information on what version skipped it. | ||
*/ | ||
fun markAsSkipped( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is currently only used in tests. Do you anticipate it being used elsewhere? If not, should probably move it to the test classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I anticipate that it might, which is why I kept it here.
.../src/main/kotlin/com/netflix/spinnaker/keel/persistence/memory/InMemoryArtifactRepository.kt
Outdated
Show resolved
Hide resolved
keel-sql/src/main/kotlin/com/netflix/spinnaker/keel/sql/SqlArtifactRepository.kt
Outdated
Show resolved
Hide resolved
keel-sql/src/main/kotlin/com/netflix/spinnaker/keel/sql/SqlArtifactRepository.kt
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Some of the comments have been obsoleted by recent changes)
.../src/main/kotlin/com/netflix/spinnaker/keel/persistence/ApplicationSummaryGenerationTests.kt
Outdated
Show resolved
Hide resolved
.and(ENVIRONMENT_ARTIFACT_VERSIONS.PROMOTION_STATUS.eq(CURRENT.name)) | ||
.and(ENVIRONMENT_ARTIFACT_VERSIONS.ARTIFACT_VERSION.ne(version)) | ||
.execute() | ||
jooq.transaction { config -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've noticed that sometimes we use @Transactional
annotations and sometimes we call jooq.transaction
. Is there some guidance on when to do which?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Transactional
is something that spring does (we use it on the api layer sometimes), and the jooq
one is for when you're actually in the sql repository and can control every part of the transaction
keel-core/src/main/kotlin/com/netflix/spinnaker/keel/persistence/ArtifactRepository.kt
Outdated
Show resolved
Hide resolved
@@ -594,6 +617,32 @@ class SqlArtifactRepository( | |||
} | |||
} | |||
|
|||
override fun markAsSkipped( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this called in application logic yet, or just in tests? I didn't see any reference in application code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's just in tests (there's a comment on the interface method for that) I wanted to easily call it in the tests with a separate impl in each repository
keel-core/src/main/kotlin/com/netflix/spinnaker/keel/core/api/PromotionStatus.kt
Outdated
Show resolved
Hide resolved
keel-core/src/main/kotlin/com/netflix/spinnaker/keel/core/api/PromotionStatus.kt
Outdated
Show resolved
Hide resolved
…PromotionStatus.kt Co-Authored-By: Erik Munson <erik@ipsumcreative.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing the comments! lgtm :)
Recently we were talking about artifact statuses. We have an
APPROVED
status which means "this artifact is ready to be deployed". But, we sometimes have the situation where an artifact is approved for an environment but never deployed to that environment. This is probably because the artifact was superseded by another version of an artifact (both were ready to deploy, but we deployed the latest one).We also have a
PENDING
status for artifacts to represent that something might be going on in the future, but we have no idea what. That is calculated like this: we look at all versions we know about, and versions that we have data for in an environment (likeAPPROVED
/CURRENT
etc). The versions that we know about but are not in the environment are markedPENDING
. This is weird, because some versions are never going to happen (for example: two artifacts are waiting on manual judgment. You approve the latest one. We ignore that other version for ever and ever).This PR introduces a
SKIPPED
status which will get set when an artifact is marked asCURRENT
in an environment. When an artifact is marked as deployed, weCURRENT
artifact toPREVIOUS
(this pr also updates thepromotion_reference
column to contain what artifact replaced it)APPROVED
toSKIPPED
(for example: 1.1.1, 1.2.1, and 1.3.1 are all approved. 1.2.1 is marked asCURRENT
. 1.1.1 would be marked asSKIPPED
. 1.3.1 would be untouched)This will make our existing data a bit wonkey (i.e. every place we now have
APPROVED
but that's out of date and confusing). It should be straightforward going forward.This
SKIPPED
status is also used for pending judgments. That works like this:PENDING
in the same way as described aboveSKIPPED
After this PR is merged, we should have a better view of artifacts that will never be deployed.