From c2c951661c7a415b04c3daa0444451e0059e1420 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 2723571d955..c5baf95b650 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 d8962bb796f..2956ba39202 100644 --- a/pkg/asset/machines/master.go +++ b/pkg/asset/machines/master.go @@ -252,6 +252,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