From 7c022f940fe00c023c4d0d555c3175288be62120 Mon Sep 17 00:00:00 2001 From: Thuan Vo Date: Mon, 22 Dec 2025 13:32:34 -0800 Subject: [PATCH] OCPBUGS-69923: ensure deterministic zone ordering for control plane machines Control plane machines were intermittently being created in different availability zones than specified in their machine specs. This occurred because the zone list returned from FilterZonesBasedOnInstanceType used a set's UnsortedList() func, which has a non-deterministic order. When CAPI and MAPI manifest generation independently called this func, they could receive zones in different orders, causing a mismatch in machine zone placements between CAPI and MAPI manifests. This commit ensures that we sort the zone slices before further processing. --- pkg/asset/machines/clusterapi.go | 3 +++ pkg/asset/machines/master.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/pkg/asset/machines/clusterapi.go b/pkg/asset/machines/clusterapi.go index 093cf662de2..5b661ca175b 100644 --- a/pkg/asset/machines/clusterapi.go +++ b/pkg/asset/machines/clusterapi.go @@ -157,6 +157,9 @@ func (c *ClusterAPI) Generate(ctx context.Context, dependencies asset.Parents) e if err != nil { logrus.Warn(errors.Wrap(err, "failed to filter zone list")) } + // Sort the zones by lexical order to ensure CAPI and MAPI machines + // are distributed to zones in the same order. + slices.Sort(mpool.Zones) } tags, err := aws.CapaTagsFromUserTags(clusterID.InfraID, installConfig.Config.Platform.AWS.UserTags) diff --git a/pkg/asset/machines/master.go b/pkg/asset/machines/master.go index caeedb850d4..b8a456e79f6 100644 --- a/pkg/asset/machines/master.go +++ b/pkg/asset/machines/master.go @@ -240,6 +240,9 @@ func (m *Master) Generate(ctx context.Context, dependencies asset.Parents) error if err != nil { logrus.Warn(errors.Wrap(err, "failed to filter zone list")) } + // Sort the zones by lexical order to ensure CAPI and MAPI machines + // are distributed to zones in the same order. + slices.Sort(mpool.Zones) } pool.Platform.AWS = &mpool