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

Update deployment sidecar when flags change #961

Merged
merged 5 commits into from
Apr 2, 2020

Conversation

rubenvp8510
Copy link
Collaborator

Still need to update tests.

@rubenvp8510 rubenvp8510 force-pushed the change-flags branch 2 times, most recently from 9bab4aa to dce293b Compare March 11, 2020 20:41
@codecov
Copy link

codecov bot commented Mar 11, 2020

Codecov Report

Merging #961 into master will increase coverage by 0.11%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #961      +/-   ##
==========================================
+ Coverage   64.44%   64.56%   +0.11%     
==========================================
  Files          82       82              
  Lines        6526     6542      +16     
==========================================
+ Hits         4206     4224      +18     
+ Misses       2178     2177       -1     
+ Partials      142      141       -1     
Impacted Files Coverage Δ
pkg/inject/sidecar.go 96.64% <100.00%> (+1.55%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7f45096...def0fa1. Read the comment docs.

Copy link
Contributor

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we try a different approach? Instead of checking whether the container needs updating, you could update the container every time. Kubernetes describes the desired state and will act to make this true, so, updating the container should not yield a new deployment (nor an update) if the container spec hasn't changed.

pkg/controller/deployment/deployment_controller.go Outdated Show resolved Hide resolved
pkg/inject/sidecar.go Outdated Show resolved Hide resolved
@rubenvp8510
Copy link
Collaborator Author

Could we try a different approach? Instead of checking whether the container needs updating, you could update the container every time. Kubernetes describes the desired state and will act to make this true, so, updating the container should not yield a new deployment (nor an update) if the container spec hasn't changed.

Yes, this was my first approach, I just need to remove 1 commit.

@rubenvp8510 rubenvp8510 force-pushed the change-flags branch 2 times, most recently from b5d7bb2 to 363171f Compare March 12, 2020 21:17
@rubenvp8510
Copy link
Collaborator Author

I tried the approach of updating the sidecar on each reconciliation process.

It works, but I saw a couple of errors on logs. regarding of deployment update: "the object has been modified; please apply your changes to the latest version and try again".

This happens even if the client.Reader is used. (without cache).

I think this is due the fact that the deployment status (ready, number of replicas etc..) is modified while we are injecting (or updating) the deployment.

@jpkrohling

Copy link
Contributor

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still needs tests:

  1. ensuring that deployments with explicit sidecars aren't affected by this change
  2. ensuring that sidecars are actually being updated
  3. extra test: add an assertion to the current TestSidecarNeeded, ensuring that there are only two containers in the deployments (to make sure our update is indeed removing the container).

You might also consider simply replacing the container instead of deleting + adding the container.

pkg/controller/deployment/deployment_controller.go Outdated Show resolved Hide resolved
pkg/inject/sidecar_test.go Show resolved Hide resolved
pkg/inject/sidecar.go Outdated Show resolved Hide resolved
@rubenvp8510 rubenvp8510 force-pushed the change-flags branch 11 times, most recently from 6b11c26 to 9ee64d6 Compare March 24, 2020 00:39
Copy link
Contributor

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Perhaps @objectiser or @pavolloffay would also like to take a look before merging?

Copy link
Contributor

@objectiser objectiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - one minor suggestion.

dep2 = Sidecar(jaeger, dep2)
dep3 := dep(map[string]string{Annotation: jaeger.Name}, map[string]string{})

assert.False(t, EqualSidecar(dep1, dep2))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Can you move this above dep3, and then before dep3 line have a comment about // Compare with no agent or something like that - at the moment the different criteria being tested are being interleaved.

@rubenvp8510
Copy link
Collaborator Author

rubenvp8510 commented Mar 24, 2020

There is one thing with this PR. I still observe this:

"the object has been modified; please apply your changes to the latest version and try again".

But the sidecar was injected, I have the theory that this happens due the changes in the deployment status. Not sure how to avoid this.

@jpkrohling @pavolloffay @objectiser

@rubenvp8510 rubenvp8510 force-pushed the change-flags branch 3 times, most recently from 9ea0236 to 8a519d0 Compare March 25, 2020 15:00
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
@objectiser objectiser merged commit e79443e into jaegertracing:master Apr 2, 2020
@objectiser
Copy link
Contributor

@rubenvp8510 If you could create a separate issue for the "the object has been modified; please apply your changes to the latest version and try again" message with steps to reproduce? along with any thoughts you have.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants