-
Notifications
You must be signed in to change notification settings - Fork 39
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
[controller] Support multi instance placement add #275
Conversation
ee06603
to
05f3c48
Compare
Codecov Report
@@ Coverage Diff @@
## master #275 +/- ##
=======================================
Coverage 76.01% 76.02%
=======================================
Files 32 32
Lines 2381 2394 +13
=======================================
+ Hits 1810 1820 +10
- Misses 427 429 +2
- Partials 144 145 +1 Continue to review full report at Codecov.
|
d6e5e70
to
aa4aa9c
Compare
aa4aa9c
to
75ae345
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. A few minor nits.
One general question: do our current "ready replica" checks guarantee that we'll add all pods at once, rather than accidentally adding one at a time?
For example, say we scale a set from 2 to 4 pods. At time T1, 1/2 new pods is up. Are our readiness checks structured in such a way that we won't immediate add the 3rd pod, and will wait until we can evaluate the two new ones at once?
pkg/controller/update_cluster.go
Outdated
err := fmt.Errorf("error creating instance for pod %s", pod.Name) | ||
c.logger.Error(err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: take advantage of structured logging here (i.e. logger.Error("error creating instance for pod", zap.String("pod", ...
pkg/controller/update_cluster.go
Outdated
func (c *M3DBController) addPodsToPlacement(cluster *myspec.M3DBCluster, pods []*corev1.Pod) error { | ||
var ( | ||
instances = make([]*placementpb.Instance, 0, len(pods)) | ||
reasonBuf = bytes.NewBufferString("adding pods to placement (") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a pretty different convention than how build up logs, and this isn't very perf-sensitive code.
I would vote for just adding to an array of strings, which are the names of the instances / pods, and then calling zap.Strings
.
pkg/controller/update_cluster.go
Outdated
if err != nil { | ||
err := fmt.Errorf("error adding pod to placement: %s", pod.Name) | ||
err := fmt.Errorf("error: %s", reason) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here re: taking the change to structure the below .Error
log.
pkg/controller/update_cluster.go
Outdated
"github.com/m3db/m3/src/cluster/placement" | ||
dbns "github.com/m3db/m3/src/dbnode/generated/proto/namespace" | ||
"github.com/m3db/m3/src/query/generated/proto/admin" | ||
|
||
appsv1 "k8s.io/api/apps/v1" | ||
corev1 "k8s.io/api/core/v1" | ||
v1 "k8s.io/api/core/v1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: this ls already imported as corev1
on the line above.
In practice, I observed the operator bringing up a pod at a time (waiting for each to be ready before proceeding) and then expanding the placement when all requested pods are up/ready/bootstrapped (w/ no shards). I observed this pattern testing in In the code it looks like we add a pod at a time here: m3db-operator/pkg/controller/controller.go Lines 710 to 716 in 7a6466e
And then when the number of m3db-operator/pkg/controller/controller.go Lines 688 to 701 in 7a6466e
Can observe this in the bootstrap metrics as well (2 -> 4 and then 2 -> 6): |
* master: Backwards compatibility when using the original update annoation with an OnDelete update strategy (#284) Add support for parallel node updates within a statefulset (#283) Support namespace ExtendedOptions in cluster spec (#282) [controller] Support multi instance placement add (#275) [gomod] Update M3DB dependency (#277) [cmd] Fix instrument package name (#280) # Conflicts: # pkg/k8sops/annotations/annotations.go
Modifies the placement client
Add()
API to accept multiple instances.