Skip to content

Merge behavior overwriting manual addon version for CSI Driver #720

@fsgro

Description

@fsgro

I'd like to report an issue we encountered with the use of the merge function in ibm roks terraform module for managing ROKS addons.

When both var.addons and the detected addon list include "vpc-block-csi-driver", the detected version (retrieved from ibm_container_addons) always overrides the manual version defined in var.addons, due to how merge prioritizes later values.

addons = merge(
{ for addon_name, addon_version in(var.addons != null ? var.addons : {}) : addon_name =>
addon_version if addon_version != null },
length(local.csi_driver_version) > 0 ? { vpc-block-csi-driver = local.csi_driver_version[0] } : {}
)

By default, version 5.1 on the CSI Driver is installed, but we want to enforce the installation of version 5.2 explicitly defined in var.addons. Unfortunately, this is currently overwritten by the auto-detected version.

Workaround implemented:

To ensure user-defined versions take precedence, we now only add the detected version if it's not already defined :

addons = merge(length(local.csi_driver_version) > 0 && !contains(keys(var.addons), "vpc-block-csi-driver") ? { vpc-block-csi-driver = local.csi_driver_version[0] } : {},
{ for addon_name, addon_version in(var.addons != null ? var.addons : {}) : addon_name => addon_version if addon_version != null })

Module version used : 3.35.7

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions