-
Notifications
You must be signed in to change notification settings - Fork 719
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
Refactor downscales and add unit tests #1506
Conversation
This refactors the StatefulSets downscale code into multiple smaller functions, easier to test. It also adds unit tests for most of those functions, and generally covers the entire downscale codebase with unit tests.
operators/pkg/controller/elasticsearch/driver/downscale_test.go
Outdated
Show resolved
Hide resolved
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.
Looks good, few comments.
case downscale.isReplicaDecrease(): | ||
// adjust the theoretical downscale to one we can safely perform | ||
performable := calculatePerformableDownscale(ctx, downscale, allLeavingNodes) | ||
if !performable.isReplicaDecrease() { |
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.
Nice.
Jenkins test this please |
1 similar comment
Jenkins test this please |
Not sure if it is related to this PR but I think I managed to have a race condition: I quickly changed the number of expected Pods from 5 -> 3 -> 5
But I have the two last nodes excluded: {
"persistent" : { },
"transient" : {
"cluster" : {
"routing" : {
"allocation" : {
"exclude" : {
"_name" : "elasticsearch-sample-es-default-4,elasticsearch-sample-es-default-3"
}
}
}
}
}
} |
@barkbay good catch! // scheduleDataMigrations requests Elasticsearch to migrate data away from leavingNodes.
func scheduleDataMigrations(esClient esclient.Client, leavingNodes []string) error {
if len(leavingNodes) == 0 {
return nil
}
log.V(1).Info("Migrating data away from nodes", "nodes", leavingNodes)
return migration.MigrateData(esClient, leavingNodes)
} I'll fix this. |
Last commit should correctly reset shard allocation excludes, similar to how done before. I think there is a potential race where we'd clear allocation excludes before the pod is completely deleted (if it's still being terminated for example). I'd like to handle that with another issue: #1523. |
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
operators/pkg/controller/elasticsearch/driver/downscale_test.go
Outdated
Show resolved
Hide resolved
operators/pkg/controller/elasticsearch/driver/downscale_test.go
Outdated
Show resolved
Hide resolved
LGTM, just one question about the fakes |
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
This refactors the StatefulSets downscale code into multiple smaller
functions, easier to test.
It also adds unit tests for most of those functions, and generally covers
the entire downscale codebase with unit tests.
Relates #1287.