in pkg/controller/elasticsearch/driver/autoscaling.go [21:76]
func (d *defaultDriver) autoscaledResourcesSynced(ctx context.Context, es esv1.Elasticsearch) (bool, error) {
autoscalingResource, err := autoscaling.GetAssociatedAutoscalingResource(ctx, d.Client, es)
if err != nil {
return false, err
}
if autoscalingResource == nil {
// Cluster is not managed by an autoscaler.
return true, nil
}
log := ulog.FromContext(ctx)
autoscalingSpecs, err := autoscalingResource.GetAutoscalingPolicySpecs()
if err != nil {
return false, err
}
autoscalingStatus, err := autoscalingResource.GetElasticsearchAutoscalerStatus()
if err != nil {
return false, err
}
v, err := version.Parse(es.Spec.Version)
if err != nil {
return false, err
}
for _, nodeSet := range es.Spec.NodeSets {
nodeSetAutoscalingSpec, err := nodeSet.GetAutoscalingSpecFor(v, autoscalingSpecs)
if err != nil {
return false, err
}
if nodeSetAutoscalingSpec == nil {
// This nodeSet is not managed by an autoscaling configuration
log.V(1).Info("NodeSet not managed by an autoscaling controller", "nodeset", nodeSet.Name)
continue
}
expectedNodeSetsResources, ok := autoscalingStatus.CurrentResourcesForPolicy(nodeSetAutoscalingSpec.Name)
if !ok {
log.Info("NodeSet managed by the autoscaling controller but not found in status",
"nodeset", nodeSet.Name,
)
return false, nil
}
inSync, err := resources.Match(expectedNodeSetsResources, esv1.ElasticsearchContainerName, nodeSet)
if err != nil {
return false, err
}
if !inSync {
log.Info("NodeSet managed by the autoscaling controller but not in sync",
"nodeset", nodeSet.Name,
"expected", expectedNodeSetsResources.NodeResources,
)
return false, nil
}
}
return true, nil
}