From 04432ce4c8a10e2d69869580dcc5b9022343c57b Mon Sep 17 00:00:00 2001 From: Ajitem Date: Wed, 10 Sep 2025 16:21:20 +0200 Subject: [PATCH] fix: strip architecture suffix from Kafka image tags for semver parsing Newer Kafka Docker images include architecture suffixes in their tags (e.g. 7.5.0.arm64), which are not valid semver. This change normalises the tag by removing the architecture suffix before passing it to the semver parser, ensuring compatibility with golang.org/x/mod/semver. --- modules/kafka/kafka.go | 5 +++++ modules/kafka/kafka_helpers_test.go | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/modules/kafka/kafka.go b/modules/kafka/kafka.go index b1342de98f..9a99314f9d 100644 --- a/modules/kafka/kafka.go +++ b/modules/kafka/kafka.go @@ -212,6 +212,11 @@ func validateKRaftVersion(fqName string) error { version = "v" + version } + // remove the architecture suffix + if strings.HasSuffix(version, ".amd64") || strings.HasSuffix(version, ".arm64") { + version = version[:strings.LastIndex(version, ".")] + } + if semver.Compare(version, "v7.4.0") < 0 { // version < v7.4.0 return fmt.Errorf("version=%s. KRaft mode is only available since version 7.4.0", version) } diff --git a/modules/kafka/kafka_helpers_test.go b/modules/kafka/kafka_helpers_test.go index 6ef7deb60f..95d6cbc99a 100644 --- a/modules/kafka/kafka_helpers_test.go +++ b/modules/kafka/kafka_helpers_test.go @@ -93,6 +93,16 @@ func TestValidateKRaftVersion(t *testing.T) { image: "my-kafka:1.0.0", wantErr: false, }, + { + name: "Official: valid, with the amd64 architecture suffix", + image: "confluentinc/confluent-local:7.5.9.amd64", + wantErr: false, + }, + { + name: "Official: valid, with the arm64 architecture suffix", + image: "confluentinc/confluent-local:7.5.9.arm64", + wantErr: false, + }, } for _, test := range tests {