The operator errors out because there are multiple entries of HDFS_NAMENODE_OPTS in the final EnvVar vector.
2024-03-12T16:44:52.520017Z ERROR hdfs_controller: stackable_operator::logging::controller: Failed to reconcile object controller.name="hdfsclusters.hdfs.stackable.tech" error=reconciler for object HdfsCluster.v1alpha1.hdfs.stackable.tech/hdfs.
kuttl-test-needed-kingfish failed error.sources=[cannot create role group stateful set "hdfs-namenode-default", Kubernetes reported error: ApiError: failed to create typed patch object (kuttl-test-needed-kingfish/hdfs-namenode-default; apps/v1,
Kind=StatefulSet): .spec.template.spec.containers[name="namenode"].env: duplicate entries for key [name="HDFS_NAMENODE_OPTS"]: (ErrorResponse { status: "Failure", message: "failed to create typed patch object (kuttl-test-needed-kingfish/hdfs-
namenode-default; apps/v1, Kind=StatefulSet): .spec.template.spec.containers[name=\"namenode\"].env: duplicate entries for key [name=\"HDFS_NAMENODE_OPTS\"]", reason: "", code: 500 }), ApiError: failed to create typed patch object (kuttl-test-n
eeded-kingfish/hdfs-namenode-default; apps/v1, Kind=StatefulSet): .spec.template.spec.containers[name="namenode"].env: duplicate entries for key [name="HDFS_NAMENODE_OPTS"]: (ErrorResponse { status: "Failure", message: "failed to create typed
patch object (kuttl-test-needed-kingfish/hdfs-namenode-default; apps/v1, Kind=StatefulSet): .spec.template.spec.containers[name=\"namenode\"].env: duplicate entries for key [name=\"HDFS_NAMENODE_OPTS\"]", reason: "", code: 500 }), failed to cre
ate typed patch object (kuttl-test-needed-kingfish/hdfs-namenode-default; apps/v1, Kind=StatefulSet): .spec.template.spec.containers[name="namenode"].env: duplicate entries for key [name="HDFS_NAMENODE_OPTS"]: ]
This is because the operator treats env vars internally mostly as a Vector, therefore not replacing but appending overrides.
This is fine until env vars set by the operator are overriden.
If using ENV overrides of variables set by the operator, the mechanism is not working correctly. When trying to apply something like:
The operator errors out because there are multiple entries of
HDFS_NAMENODE_OPTS
in the finalEnvVar
vector.This is because the operator treats env vars internally mostly as a Vector, therefore not replacing but appending overrides. This is fine until env vars set by the operator are overriden.
This whole method should be reworked https://github.com/stackabletech/hdfs-operator/blob/c80034261ccce65eea2b5f38dee68349ef8e9964/rust/operator-binary/src/container.rs#L737 into using maps until the final override at the end.