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

[Autoscaling] Add support for tier only requests #4445

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ func (ctx *Context) nodeResources(minNodesCount int64, minStorage resource.Quant
nodeResources := resources.NodeResources{}
requiredCapacity := ctx.AutoscalingPolicyResult.RequiredCapacity
// Compute desired memory quantity for the nodes managed by this AutoscalingPolicySpec.
if !requiredCapacity.Node.Memory.IsEmpty() {
if !requiredCapacity.Node.Memory.IsEmpty() ||
!requiredCapacity.Total.Memory.IsEmpty() {
memoryRequest := ctx.getResourceValue(
"memory",
requiredCapacity.Node.Memory,
Expand All @@ -30,9 +31,9 @@ func (ctx *Context) nodeResources(minNodesCount int64, minStorage resource.Quant
)
nodeResources.SetRequest(corev1.ResourceMemory, memoryRequest)
}

// Compute desired storage quantity for the nodes managed by this AutoscalingPolicySpec.
if !requiredCapacity.Node.Storage.IsEmpty() {
if !requiredCapacity.Node.Storage.IsEmpty() ||
!requiredCapacity.Total.Storage.IsEmpty() {
storageRequest := ctx.getResourceValue(
"storage",
requiredCapacity.Node.Storage,
Expand Down
28 changes: 25 additions & 3 deletions pkg/controller/autoscaling/elasticsearch/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,21 @@ func TestReconcile(t *testing.T) {
wantEvents []string
wantErr bool
}{
{
name: "Frozen decider only returns capacity at the tier level",
fields: fields{
EsClient: newFakeEsClient(t).withCapacity("frozen-tier"),
recorder: record.NewFakeRecorder(1000),
licenseChecker: &fakeLicenceChecker{},
},
args: args{
esManifest: "frozen-tier",
isOnline: true,
},
want: defaultRequeue,
wantErr: false,
wantEvents: []string{},
},
{
name: "ML case where tier total memory was lower than node memory",
fields: fields{
Expand Down Expand Up @@ -246,12 +261,13 @@ func TestReconcile(t *testing.T) {
bytes, err := ioutil.ReadFile(filepath.Join("testdata", tt.args.esManifest, "elasticsearch-expected.yml"))
require.NoError(t, err)
require.NoError(t, yaml.Unmarshal(bytes, &expectedElasticsearch))
assert.Equal(t, updatedElasticsearch.Spec, expectedElasticsearch.Spec)
assert.Equal(t, updatedElasticsearch.Spec, expectedElasticsearch.Spec, "Updated Elasticsearch spec. is not the expected one")
// Check that the autoscaling spec is still the expected one.
assert.Equal(
t,
updatedElasticsearch.Annotations[esv1.ElasticsearchAutoscalingSpecAnnotationName],
expectedElasticsearch.Annotations[esv1.ElasticsearchAutoscalingSpecAnnotationName],
"Autoscaling specification is not the expected one",
)
// Compare the statuses.
statusesEqual(t, updatedElasticsearch, expectedElasticsearch)
Expand All @@ -275,10 +291,16 @@ func statusesEqual(t *testing.T, got, want esv1.Elasticsearch) {
require.NotNil(t, gotPolicyStatus, "Autoscaling policy not found")
require.ElementsMatch(t, gotPolicyStatus.NodeSetNodeCount, wantPolicyStatus.NodeSetNodeCount)
for resource := range wantPolicyStatus.ResourcesSpecification.Requests {
require.True(t, resources.ResourceEqual(resource, wantPolicyStatus.ResourcesSpecification.Requests, gotPolicyStatus.ResourcesSpecification.Requests))
require.True(
t,
resources.ResourceEqual(resource, wantPolicyStatus.ResourcesSpecification.Requests, gotPolicyStatus.ResourcesSpecification.Requests),
"unexpected resource requests for policy %s, expected %v, got %v", gotPolicyStatus.Name, wantPolicyStatus.ResourcesSpecification.Requests, gotPolicyStatus.ResourcesSpecification.Requests)
}
for resource := range wantPolicyStatus.ResourcesSpecification.Limits {
require.True(t, resources.ResourceEqual(resource, wantPolicyStatus.ResourcesSpecification.Requests, gotPolicyStatus.ResourcesSpecification.Requests))
require.True(
t,
resources.ResourceEqual(resource, wantPolicyStatus.ResourcesSpecification.Limits, gotPolicyStatus.ResourcesSpecification.Limits),
"unexpected resource limits for policy %s, expected %v, got %v", gotPolicyStatus.Name, wantPolicyStatus.ResourcesSpecification.Limits, gotPolicyStatus.ResourcesSpecification.Limits)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
{
"policies" : {
"di-frozen" : {
"required_capacity" : {
"total" : {
"storage" : 1523908623,
"memory" : 2164663494
}
},
"current_capacity" : {
"node" : {
"storage" : 2046640128,
"memory" : 2147483648
},
"total" : {
"storage" : 2046640128,
"memory" : 2147483648
}
},
"current_nodes" : [
{
"name" : "frozen-sample-es-di-frozen-0"
}
],
"deciders" : {
"frozen_shards" : {
"required_capacity" : {
"total" : {
"memory" : 2164663494
}
},
"reason_summary" : "shard count [63]",
"reason_details" : {
"shards" : 63
}
},
"frozen_storage" : {
"required_capacity" : {
"total" : {
"storage" : 1523908623
}
},
"reason_summary" : "total data set size [30478172467]",
"reason_details" : {
"total_data_set_size" : 30478172467
}
}
}
},
"di-hot" : {
"required_capacity" : {
"node" : {
"storage" : 38107923
},
"total" : {
"storage" : 8387952640
}
},
"current_capacity" : {
"node" : {
"storage" : 4193976320,
"memory" : 2147483648
},
"total" : {
"storage" : 8387952640,
"memory" : 4294967296
}
},
"current_nodes" : [
{
"name" : "frozen-sample-es-di-hot-0"
},
{
"name" : "frozen-sample-es-di-hot-1"
}
],
"deciders" : {
"proactive_storage" : {
"required_capacity" : {
"node" : {
"storage" : 38107923
},
"total" : {
"storage" : 8387952640
}
},
"reason_summary" : "storage ok",
"reason_details" : {
"reason" : "storage ok",
"unassigned" : 0,
"assigned" : 0,
"forecasted" : 0,
"forecast_window" : "30m"
}
},
"reactive_storage" : {
"required_capacity" : {
"node" : {
"storage" : 38107923
},
"total" : {
"storage" : 8387952640
}
},
"reason_summary" : "storage ok",
"reason_details" : {
"reason" : "storage ok",
"unassigned" : 0,
"assigned" : 0
}
}
}
},
"ml" : {
"required_capacity" : {
"node" : {
"storage" : 0,
"memory" : 0
},
"total" : {
"storage" : 0,
"memory" : 0
}
},
"current_capacity" : {
"node" : {
"storage" : 0,
"memory" : 0
},
"total" : {
"storage" : 0,
"memory" : 0
}
},
"current_nodes" : [ ],
"deciders" : {
"ml" : {
"required_capacity" : {
"node" : {
"storage" : 0,
"memory" : 0
},
"total" : {
"storage" : 0,
"memory" : 0
}
},
"reason_summary" : "Passing currently perceived capacity as no scaling changes were detected to be possible",
"reason_details" : {
"waiting_analytics_jobs" : [ ],
"waiting_anomaly_jobs" : [ ],
"configuration" : {
"down_scale_delay" : "5m"
},
"perceived_current_capacity" : {
"node" : {
"memory" : 0
},
"total" : {
"memory" : 0
}
},
"reason" : "Passing currently perceived capacity as no scaling changes were detected to be possible"
}
}
}
}
}
}
Loading