bookingcom / shipper

Kubernetes native multi-cluster canary or blue-green rollouts using Helm
Apache License 2.0
733 stars 39 forks source link

traffic controller: report the correct achieved traffic weight #245

Closed juliogreff closed 4 years ago

juliogreff commented 4 years ago

This builds on top of work done in #241 , which builds on top of #238, so make sure those are merged before going through the changes here :)

Before this, the pod label shifter would return a bogus achieved traffic weight whenever the number of pods required to take traffic was equal to the number of pods ready. Fixing that up front would've broken the release controller, as it used to check the achieved traffic weight instead of just looking at conditions (which at the time didn't exist). Now that this has been fixed [1], we can start reporting the actual achieved weight instead of having to lie.

The diff is also a fair bit larger than it should be, since I got a bit carried away with the pod label shifter refactoring. There's a rationale, though: it moves all the actual logic of traffic calculations away from ever touching informers and clients and into traffic_shifting_status.go, making unit testing much easier. pod_label_shifter.go now only does the mechanical job of shifting labels, making its own surface area much smaller. As a bonus, tests are much faster too!

Last but not least, now we can also tell the difference traffic shifting being in progress (as in, shipper is currently moving labels around) and it being stuck (as in, pods aren't ready). This was also some extra motivation for the state we accumulate in trafficShiftingStatus.

[1] https://github.com/bookingcom/shipper/pull/241