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

fix(kubernetes/artifacts): Support for legacy Clouddriver's artifact replacement logic #5513

Merged
merged 18 commits into from Sep 15, 2021
Merged

fix(kubernetes/artifacts): Support for legacy Clouddriver's artifact replacement logic #5513

merged 18 commits into from Sep 15, 2021

Conversation

cristhian-castaneda
Copy link
Member

@cristhian-castaneda cristhian-castaneda commented Sep 8, 2021

This change adds support for this breaking change #4874.

We added an optional flag to enable the old behavior

kubernetes:
  artifact-binding:
    docker-image: match-name-only

This is mainly to help current users that rely on the old behavior.

@spinnakerbot
Copy link
Contributor

The following commits need their title changed:

  • 0481fe5: Merge remote-tracking branch 'origin/master' into fix/support-legacy-binding

Please format your commit title into the form:

<type>(<scope>): <subject>, e.g. fix(kubernetes): address NPE in status check

This allows us to easily generate changelogs & determine semantic version numbers when cutting releases. You can read more about commit conventions here.

@cristhian-castaneda cristhian-castaneda marked this pull request as ready for review September 9, 2021 01:13
Copy link
Contributor

@german-muzquiz german-muzquiz left a 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) {
Copy link
Member Author

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;
Copy link
Contributor

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

Copy link
Member Author

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.

@german-muzquiz german-muzquiz added the ready to merge Approved and ready for a merge label Sep 15, 2021
@mergify mergify bot added the auto merged Merged automatically by a bot label Sep 15, 2021
@mergify mergify bot merged commit 18e53a0 into spinnaker:master Sep 15, 2021
@cristhian-castaneda cristhian-castaneda deleted the fix/support-legacy-binding branch September 15, 2021 19:30
@link108 link108 added the backport-candidate Add to PRs to designate release branch patch candidates. label Sep 15, 2021
@cristhian-castaneda
Copy link
Member Author

@Mergifyio backport release-1.25.x

mergify bot pushed a commit that referenced this pull request Sep 15, 2021
…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)
@mergify
Copy link
Contributor

mergify bot commented Sep 15, 2021

Command backport release-1.25.x: success

Backports have been created

@link108
Copy link
Member

link108 commented Sep 16, 2021

@Mergifyio backport release-1.26.x release-1.27.x

mergify bot pushed a commit that referenced this pull request Sep 16, 2021
…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)
mergify bot pushed a commit that referenced this pull request Sep 16, 2021
…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)
@mergify
Copy link
Contributor

mergify bot commented Sep 16, 2021

Command backport release-1.26.x release-1.27.x: success

Backports have been created

link108 pushed a commit that referenced this pull request Sep 17, 2021
…replacement logic (backport #5513) (#5536)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Cristhian Castaneda <ccastanedarivera@gmail.com>
link108 pushed a commit that referenced this pull request Sep 17, 2021
…replacement logic (backport #5513) (#5537)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Cristhian Castaneda <ccastanedarivera@gmail.com>
@link108 link108 removed the backport-candidate Add to PRs to designate release branch patch candidates. label Sep 17, 2021
mergify bot pushed a commit that referenced this pull request Sep 23, 2021
…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>
link108 added a commit that referenced this pull request Oct 25, 2021
…replacement logic (backport #5513) (#5531)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Cristhian Castaneda <ccastanedarivera@gmail.com>
Co-authored-by: Cameron Motevasselani <cmotevasselani@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto merged Merged automatically by a bot ready to merge Approved and ready for a merge target-release/1.28
Projects
None yet
4 participants