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
fix(kubernetes/artifacts): Support for legacy Clouddriver's artifact replacement logic #5513
fix(kubernetes/artifacts): Support for legacy Clouddriver's artifact replacement logic #5513
Conversation
The following commits need their title changed:
Please format your commit title into the form:
This allows us to easily generate changelogs & determine semantic version numbers when cutting releases. You can read more about commit conventions here. |
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 see a potential race condition where this new flag may not work depending on the order in which spring creates the beans: if any spring bean that imports Replacer
is created before ReplacerFactory
bean is created, when the runtime processes the imports it will invoke the static method of ReplacerFactory
, which hasn't yet read the value of the config file and uses the default of false
.
This problem is because Replacer
is a bunch of static objects and the config flag can only be read from instance fields.
Another approach would be to move using the config flag until the filter is applied rather than when creating the replacers. This means that Replacer
would need to have two instances of replacePathSupplier
: one standard and one legacy, but which one is used is determined until the replace call. There's a single point of usage in ArtifactReplacer
, so we can add the boolean flag to the ArtifactReplacer
constructor and populate it from the nearest spring bean that can load it.
Another comment is to change the config setting from artifacts.legacy-binding.enabled
to kubernetes.artifact-binding.docker-image
, with possible values match-name-and-tag
(default) and match-name-only
(which is the legacy behavior). In this way we're prepared if we need to add more settings related with how artifact binding works, for example if kubernetes.artifact-binding.enabled
is ever implemented globally.
protected KubernetesHandler() { | ||
this.artifactReplacer = new ArtifactReplacer(artifactReplacers()); | ||
} | ||
|
||
protected void setDockerImageBinding(String dockerImageBinding) { |
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 method was defined so the concrete class can assign the value from config properties.
@@ -45,10 +45,20 @@ | |||
|
|||
private final ArtifactReplacer artifactReplacer; | |||
|
|||
protected String dockerImageBinding; |
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.
Have you tried to inject the value here with @Value
instead of injecting in every subclass? In theory it should work
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.
Yeah, you are right, it works, I did some test with this in my first approach but didn't work, never tried that in this approach.
@Mergifyio backport release-1.25.x |
…replacement logic (#5513) * fix(artifacts): support legacy artifact binding. * fix(artifacts): add comment for unit test. * fix(artifacts): delete unnecessary dependency * fix(artifacts): add comment in param * fix(artifacts): fix import * fix(artifacts): update comment. * fix(artifacts): refactor factory and fix unit test * fix(artifacts): fix typo * fix(artifacts): avoid race condition for static context * fix(artifacts): fix typo * fix(artifacts): run spotlessApply * fix(artifacts): fix NPE * fix(artifacts): delete unnecessary dependency * fix(artifacts): use @value annotation within abstract class * fix(artifacts): delete unnecessary imports * fix(artifacts): run spotlessApply Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit 18e53a0)
Command
|
@Mergifyio backport release-1.26.x release-1.27.x |
…replacement logic (#5513) * fix(artifacts): support legacy artifact binding. * fix(artifacts): add comment for unit test. * fix(artifacts): delete unnecessary dependency * fix(artifacts): add comment in param * fix(artifacts): fix import * fix(artifacts): update comment. * fix(artifacts): refactor factory and fix unit test * fix(artifacts): fix typo * fix(artifacts): avoid race condition for static context * fix(artifacts): fix typo * fix(artifacts): run spotlessApply * fix(artifacts): fix NPE * fix(artifacts): delete unnecessary dependency * fix(artifacts): use @value annotation within abstract class * fix(artifacts): delete unnecessary imports * fix(artifacts): run spotlessApply Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit 18e53a0)
…replacement logic (#5513) * fix(artifacts): support legacy artifact binding. * fix(artifacts): add comment for unit test. * fix(artifacts): delete unnecessary dependency * fix(artifacts): add comment in param * fix(artifacts): fix import * fix(artifacts): update comment. * fix(artifacts): refactor factory and fix unit test * fix(artifacts): fix typo * fix(artifacts): avoid race condition for static context * fix(artifacts): fix typo * fix(artifacts): run spotlessApply * fix(artifacts): fix NPE * fix(artifacts): delete unnecessary dependency * fix(artifacts): use @value annotation within abstract class * fix(artifacts): delete unnecessary imports * fix(artifacts): run spotlessApply Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit 18e53a0)
Command
|
…replacement logic (backport #5513) (#5540) * fix(kube/test): Use kind instead of k3s (#5421) * fix(kube/test): Use kind instead of k3s * fix(kube/test): Added README * fix(kube/test): Enabled cache * fix(kube/test): Delete test cluster after all tests finish (cherry picked from commit 807d18e) * chore(deps): update kork to 7.107.0, use new maven coordinates (#5303) (cherry picked from commit 43e3d42) * chore(build): use version 8.14.0 of spinnaker-gradle-project to stop looking in jcenter (#5447) since it no longer exists, and causes builds (e.g. https://github.com/spinnaker/clouddriver/pull/5435/checks?check_run_id=3109445523) to fail. * fix(kubernetes/artifacts): Support for legacy Clouddriver's artifact replacement logic (#5513) * fix(artifacts): support legacy artifact binding. * fix(artifacts): add comment for unit test. * fix(artifacts): delete unnecessary dependency * fix(artifacts): add comment in param * fix(artifacts): fix import * fix(artifacts): update comment. * fix(artifacts): refactor factory and fix unit test * fix(artifacts): fix typo * fix(artifacts): avoid race condition for static context * fix(artifacts): fix typo * fix(artifacts): run spotlessApply * fix(artifacts): fix NPE * fix(artifacts): delete unnecessary dependency * fix(artifacts): use @value annotation within abstract class * fix(artifacts): delete unnecessary imports * fix(artifacts): run spotlessApply Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit 18e53a0) * fix(kube/test): Use kind instead of k3s (#5421) * fix(kube/test): Use kind instead of k3s * fix(kube/test): Added README * fix(kube/test): Enabled cache * fix(kube/test): Delete test cluster after all tests finish (cherry picked from commit 807d18e) * fix(kube/test): Use kind instead of k3s (#5421) * fix(kube/test): Use kind instead of k3s * fix(kube/test): Added README * fix(kube/test): Enabled cache * fix(kube/test): Delete test cluster after all tests finish (cherry picked from commit 807d18e) * fix(kube/test): Use kind instead of k3s (#5421) * fix(kube/test): Use kind instead of k3s * fix(kube/test): Added README * fix(kube/test): Enabled cache * fix(kube/test): Delete test cluster after all tests finish (cherry picked from commit 807d18e) * fix(kube/test): Use kind instead of k3s (#5421) * fix(kube/test): Use kind instead of k3s * fix(kube/test): Added README * fix(kube/test): Enabled cache * fix(kube/test): Delete test cluster after all tests finish (cherry picked from commit 807d18e) Co-authored-by: German Muzquiz <35276119+german-muzquiz@users.noreply.github.com> Co-authored-by: Daniel Peach <daniel.peach@armory.io> Co-authored-by: David Byron <82477955+dbyron-sf@users.noreply.github.com>
This change adds support for this breaking change #4874.
We added an optional flag to enable the old behavior
This is mainly to help current users that rely on the old behavior.