@@ -19,6 +19,7 @@ import (
1919 esv1 "github.com/elastic/cloud-on-k8s/v2/pkg/apis/elasticsearch/v1"
2020 sset "github.com/elastic/cloud-on-k8s/v2/pkg/controller/common/statefulset"
2121 "github.com/elastic/cloud-on-k8s/v2/pkg/controller/common/tracing"
22+ "github.com/elastic/cloud-on-k8s/v2/pkg/controller/common/version"
2223 "github.com/elastic/cloud-on-k8s/v2/pkg/controller/elasticsearch/client"
2324 "github.com/elastic/cloud-on-k8s/v2/pkg/controller/elasticsearch/settings"
2425 "github.com/elastic/cloud-on-k8s/v2/pkg/utils/k8s"
@@ -226,7 +227,7 @@ const (
226227func (l ResourcesList ) ToDesiredNodes (
227228 ctx context.Context ,
228229 k8sClient k8s.Client ,
229- version string ,
230+ version version. Version ,
230231) (desiredNodes []client.DesiredNode , requeue bool , err error ) {
231232 span , ctx := apm .StartSpan (ctx , "compute_desired_nodes" , tracing .SpanTypeApp )
232233 defer span .End ()
@@ -266,7 +267,7 @@ func (l ResourcesList) ToDesiredNodes(
266267 })
267268
268269 node := client.DesiredNode {
269- NodeVersion : version ,
270+ NodeVersion : emptyIfDeprecated ( version , client . DeprecatedNodeVersionReqBodyParamMinVersion ) ,
270271 ProcessorsRange : nodeResource .cpu ,
271272 Memory : fmt .Sprintf ("%db" , nodeResource .memory ),
272273 Storage : fmt .Sprintf ("%db" , nodeResource .storage ),
@@ -279,6 +280,15 @@ func (l ResourcesList) ToDesiredNodes(
279280 return desiredNodes , requeue , nil
280281}
281282
283+ // emptyIfDeprecated returns an empty string if the version is greater than equal to the deprecated version,
284+ // else the finalized version.
285+ func emptyIfDeprecated (version , deprecatedMinVersion version.Version ) string {
286+ if version .GTE (deprecatedMinVersion ) {
287+ return ""
288+ }
289+ return version .FinalizeVersion ()
290+ }
291+
282292// visit recursively visits a map holding a tree structure and apply a function to nodes that hold a string.
283293func visit (keys []string , m map [string ]interface {}, apply func (string ) string ) {
284294 for k , v := range m {
0 commit comments