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): do not throw NPE on NetworkPolicies with null ingres… #4172

Merged
merged 1 commit into from
Nov 20, 2019

Conversation

maggieneterval
Copy link
Contributor

…s and egress

Closes spinnaker/spinnaker#5121

  • It is valid for Kubernetes NetworkPolicy resource specs to have empty or omitted ingress and egress fields. In fact, when ingress or egress is set to [], Kubernetes actually nulls the field out rather than preserving the empty array.
  • Clouddriver's Kubernetes V2 caching logic uses the V1NetworkPolicySpec model from the Kubernetes Java client library to deserialize NetworkPolicies, which defaults ingress and egress to null. It looks like we were expecting the default to be an empty list. Currently, /securityGroups requests fail if you've deployed any NetworkPolicy with empty ingress or egress because we'll always throw an NPE when trying to stream these fields.

Copy link
Contributor

@ezimanyi ezimanyi left a comment

Choose a reason for hiding this comment

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

🔨 🚫 👉 🥅 👩‍💻 💯

@maggieneterval maggieneterval merged commit d9bdaf1 into spinnaker:master Nov 20, 2019
@maggieneterval maggieneterval deleted the fix-np-npe branch November 20, 2019 21:33
@maggieneterval
Copy link
Contributor Author

@spinnakerbot 🍒 ⛏️ 1.17

@spinnakerbot
Copy link
Contributor

Cherry pick successful: #4173

ttomsu pushed a commit that referenced this pull request Nov 25, 2019
gregjones added a commit to gregjones/clouddriver that referenced this pull request Nov 25, 2019
…ith null ports

Similar to spinnaker#4172, the code is assuming that a NetworkPolicy that has an ingress
will return an empty list of ports, but instead it defaults to null for this[1]
and so crashes.

[1] https://github.com/kubernetes-client/java/blob/master/kubernetes/src/main/java/io/kubernetes/client/openapi/models/V1NetworkPolicyIngressRule.java#L45
gregjones added a commit to gregjones/clouddriver that referenced this pull request Nov 25, 2019
…ith null ports

Similar to spinnaker#4172, the code is assuming that a NetworkPolicy that has an ingress
will return an empty list of ports, but instead it defaults to null for this[1]
and so crashes.

[1] https://github.com/kubernetes-client/java/blob/master/kubernetes/src/main/java/io/kubernetes/client/openapi/models/V1NetworkPolicyIngressRule.java#L45
gregjones added a commit to gregjones/clouddriver that referenced this pull request Nov 26, 2019
…ith null ports

Similar to spinnaker#4172, the code is assuming that a NetworkPolicy that has an ingress
will return an empty list of ports, but instead it defaults to null for this[1]
and so crashes.

[1] https://github.com/kubernetes-client/java/blob/master/kubernetes/src/main/java/io/kubernetes/client/openapi/models/V1NetworkPolicyIngressRule.java#L45
mergify bot pushed a commit that referenced this pull request Nov 26, 2019
…ith null ports (#4182)

Similar to #4172, the code is assuming that a NetworkPolicy that has an ingress
will return an empty list of ports, but instead it defaults to null for this[1]
and so crashes.

[1] https://github.com/kubernetes-client/java/blob/master/kubernetes/src/main/java/io/kubernetes/client/openapi/models/V1NetworkPolicyIngressRule.java#L45
spinnakerbot pushed a commit that referenced this pull request Nov 26, 2019
…ith null ports (#4182)

Similar to #4172, the code is assuming that a NetworkPolicy that has an ingress
will return an empty list of ports, but instead it defaults to null for this[1]
and so crashes.

[1] https://github.com/kubernetes-client/java/blob/master/kubernetes/src/main/java/io/kubernetes/client/openapi/models/V1NetworkPolicyIngressRule.java#L45
ttomsu pushed a commit that referenced this pull request Dec 2, 2019
…ith null ports (#4182) (#4186)

Similar to #4172, the code is assuming that a NetworkPolicy that has an ingress
will return an empty list of ports, but instead it defaults to null for this[1]
and so crashes.

[1] https://github.com/kubernetes-client/java/blob/master/kubernetes/src/main/java/io/kubernetes/client/openapi/models/V1NetworkPolicyIngressRule.java#L45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants