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

Add detector and fix write access on read-only structures #11020

Merged
merged 2 commits into from Apr 16, 2020

Conversation

aanm
Copy link
Member

@aanm aanm commented Apr 16, 2020

With the removal of the function queues in #10914 we no longer perform deep copies for all objects. Unfortunately we still need to perform DeepCopies for CCNP and CNP as they cause #11013 and similar issues to happen.

To avoid future issues like this we will enable a detection mechanism for such writes in all k8s objects received in our CI tests.

Fixes #11013

@aanm aanm added kind/bug This is a bug in the Cilium logic. pending-review priority/high This is considered vital to an upcoming release. labels Apr 16, 2020
@aanm aanm requested a review from a team as a code owner April 16, 2020 15:16
@aanm aanm requested a review from a team April 16, 2020 15:16
@maintainer-s-little-helper
Copy link

Please set the appropriate release note label.

3 similar comments
@maintainer-s-little-helper
Copy link

Please set the appropriate release note label.

@maintainer-s-little-helper
Copy link

Please set the appropriate release note label.

@maintainer-s-little-helper
Copy link

Please set the appropriate release note label.

@maintainer-s-little-helper maintainer-s-little-helper bot added this to In progress in 1.8.0 Apr 16, 2020
@aanm aanm added the release-note/misc This PR makes changes that have no direct user impact. label Apr 16, 2020
@aanm aanm force-pushed the pr/fix-concurrent-access-of-structures branch from 8391280 to 87c2016 Compare April 16, 2020 15:19
@aanm
Copy link
Member Author

aanm commented Apr 16, 2020

test-me-please

Objects should never be modified if they are stored in the internal
k8s store since it's a read-only and local cache.
Since we are using CNP and CCNP fields to store aggregatedSelectors we
should perform a DeepCopy of CNP and CCNP before handling policies.

Fixes: d84edc8 ("Remove function queues for CNP and CCNP")
Signed-off-by: André Martins <andre@cilium.io>
k8s libraries provide a mechanism to detect if object handlers are
modifying objects that are read only. We will enable this
functionality by default in our CI to avoid these accidental writes.

Signed-off-by: André Martins <andre@cilium.io>
@aanm aanm force-pushed the pr/fix-concurrent-access-of-structures branch from 87c2016 to 406eaba Compare April 16, 2020 15:25
@aanm
Copy link
Member Author

aanm commented Apr 16, 2020

test-me-please

Copy link
Contributor

@raybejjani raybejjani left a comment

Choose a reason for hiding this comment

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

@nebril Do you know if we have another way to set the env variables? It might be nice not to mix the CI options with the "official" way to generate config but I can't think of anything better.

@@ -89,6 +89,8 @@ func enableCNPWatcher() error {
AddFunc: func(obj interface{}) {
metrics.EventTSK8s.SetToCurrentTime()
if cnp := k8s.ObjToSlimCNP(obj); cnp != nil {


Copy link
Contributor

Choose a reason for hiding this comment

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

Was this on purpose? I'm fine with it but it might not pass gofmt? (mine usually collapses multiple newlines)

Copy link
Member Author

Choose a reason for hiding this comment

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

I missed this, it is fixed now.

@coveralls
Copy link

coveralls commented Apr 16, 2020

Coverage Status

Coverage decreased (-0.04%) to 46.739% when pulling 406eaba on pr/fix-concurrent-access-of-structures into e92fd24 on master.

@aanm aanm merged commit 26dcffe into master Apr 16, 2020
1.8.0 automation moved this from In progress to Merged Apr 16, 2020
@aanm aanm deleted the pr/fix-concurrent-access-of-structures branch April 16, 2020 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug This is a bug in the Cilium logic. priority/high This is considered vital to an upcoming release. release-note/misc This PR makes changes that have no direct user impact.
Projects
No open projects
1.8.0
  
Merged
Development

Successfully merging this pull request may close these issues.

CI: K8sKafkaPolicyTest Kafka Policy Tests KafkaPolicies
4 participants