From 802fc676618c153130a87e51c6d7b0fb379a11fb Mon Sep 17 00:00:00 2001 From: Michael Morello Date: Wed, 24 Feb 2021 08:17:11 +0100 Subject: [PATCH] Rename syncPeriod to pollingPeriod --- pkg/apis/elasticsearch/v1/autoscaling.go | 18 +++++++++--------- .../autoscaling/elasticsearch/controller.go | 2 +- .../elasticsearch-expected.yml | 2 +- .../max-storage-reached/elasticsearch.yml | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/apis/elasticsearch/v1/autoscaling.go b/pkg/apis/elasticsearch/v1/autoscaling.go index ee73669ef2..179c1b3708 100644 --- a/pkg/apis/elasticsearch/v1/autoscaling.go +++ b/pkg/apis/elasticsearch/v1/autoscaling.go @@ -31,8 +31,8 @@ var ( // resources specification. By default we don't want a CPU limit, hence a default value of 0.0 defaultCPURequestsToLimitsRatio = 0.0 - // defaultSyncPeriod is the default period between 2 Elasticsearch autoscaling API polls. - defaultSyncPeriod = 60 * time.Second + // defaultPollingPeriod is the default period between 2 Elasticsearch autoscaling API polls. + defaultPollingPeriod = 60 * time.Second ) // -- Elasticsearch Autoscaling API structures @@ -58,8 +58,8 @@ type AutoscalingPolicy struct { type AutoscalingSpec struct { AutoscalingPolicySpecs AutoscalingPolicySpecs `json:"policies"` - // SyncPeriod is the period at which to synchronize and poll the Elasticsearch autoscaling API. - SyncPeriod *metav1.Duration `json:"syncPeriod"` + // PollingPeriod is the period at which to synchronize and poll the Elasticsearch autoscaling API. + PollingPeriod *metav1.Duration `json:"pollingPeriod"` // Elasticsearch is stored in the autoscaling spec for convenience. It should be removed once the autoscaling spec is // fully part of the Elasticsearch specification. @@ -166,12 +166,12 @@ func (aps AutoscalingPolicySpec) IsStorageDefined() bool { return aps.Storage != nil } -// GetSyncPeriodOrDefault returns the sync period as specified by the user in the autoscaling specification or the default value. -func (as AutoscalingSpec) GetSyncPeriodOrDefault() time.Duration { - if as.SyncPeriod != nil { - return as.SyncPeriod.Duration +// GetPollingPeriodOrDefault returns the polling period as specified by the user in the autoscaling specification or the default value. +func (as AutoscalingSpec) GetPollingPeriodOrDefault() time.Duration { + if as.PollingPeriod != nil { + return as.PollingPeriod.Duration } - return defaultSyncPeriod + return defaultPollingPeriod } // findByRoles returns the autoscaling specification associated with a set of roles or nil if not found. diff --git a/pkg/controller/autoscaling/elasticsearch/controller.go b/pkg/controller/autoscaling/elasticsearch/controller.go index b66a65d97b..4c5ab01417 100644 --- a/pkg/controller/autoscaling/elasticsearch/controller.go +++ b/pkg/controller/autoscaling/elasticsearch/controller.go @@ -175,7 +175,7 @@ func (r *ReconcileElasticsearch) Reconcile(ctx context.Context, request reconcil func defaultResult(autoscalingSpecification esv1.AutoscalingSpec) reconcile.Result { return reconcile.Result{ Requeue: true, - RequeueAfter: autoscalingSpecification.GetSyncPeriodOrDefault(), + RequeueAfter: autoscalingSpecification.GetPollingPeriodOrDefault(), } } diff --git a/pkg/controller/autoscaling/elasticsearch/testdata/max-storage-reached/elasticsearch-expected.yml b/pkg/controller/autoscaling/elasticsearch/testdata/max-storage-reached/elasticsearch-expected.yml index 9a9b2c15c3..90e48341a8 100644 --- a/pkg/controller/autoscaling/elasticsearch/testdata/max-storage-reached/elasticsearch-expected.yml +++ b/pkg/controller/autoscaling/elasticsearch/testdata/max-storage-reached/elasticsearch-expected.yml @@ -58,7 +58,7 @@ metadata: } } }], - "syncPeriod": "42s" + "pollingPeriod": "42s" }' elasticsearch.alpha.elastic.co/autoscaling-status: '{"policies":[{"name":"di","nodeSets":[{"name":"di","nodeCount":8}],"resources":{"requests":{"cpu":"6","memory":"8Gi","storage":"4Gi"}},"state":[{"type":"HorizontalScalingLimitReached","messages":["Can''t provide total required storage 37106614256, max number of nodes is 8, requires 9 nodes"]}],"lastModificationTime":"2021-01-17T05:59:22Z"},{"name":"ml","nodeSets":[{"name":"ml","nodeCount":1}],"resources":{"requests":{"cpu":"2","memory":"2Gi"}},"state":[],"lastModificationTime":"2021-01-17T13:25:18Z"}]}' elasticsearch.k8s.elastic.co/cluster-uuid: FghvC9XFS16wDXdAusm9yg diff --git a/pkg/controller/autoscaling/elasticsearch/testdata/max-storage-reached/elasticsearch.yml b/pkg/controller/autoscaling/elasticsearch/testdata/max-storage-reached/elasticsearch.yml index 9a9b2c15c3..90e48341a8 100644 --- a/pkg/controller/autoscaling/elasticsearch/testdata/max-storage-reached/elasticsearch.yml +++ b/pkg/controller/autoscaling/elasticsearch/testdata/max-storage-reached/elasticsearch.yml @@ -58,7 +58,7 @@ metadata: } } }], - "syncPeriod": "42s" + "pollingPeriod": "42s" }' elasticsearch.alpha.elastic.co/autoscaling-status: '{"policies":[{"name":"di","nodeSets":[{"name":"di","nodeCount":8}],"resources":{"requests":{"cpu":"6","memory":"8Gi","storage":"4Gi"}},"state":[{"type":"HorizontalScalingLimitReached","messages":["Can''t provide total required storage 37106614256, max number of nodes is 8, requires 9 nodes"]}],"lastModificationTime":"2021-01-17T05:59:22Z"},{"name":"ml","nodeSets":[{"name":"ml","nodeCount":1}],"resources":{"requests":{"cpu":"2","memory":"2Gi"}},"state":[],"lastModificationTime":"2021-01-17T13:25:18Z"}]}' elasticsearch.k8s.elastic.co/cluster-uuid: FghvC9XFS16wDXdAusm9yg