Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cmd/machine-api-migration/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"os"
"time"

metal3v1 "github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1"
configv1 "github.com/openshift/api/config/v1"
mapiv1alpha1 "github.com/openshift/api/machine/v1alpha1"
mapiv1beta1 "github.com/openshift/api/machine/v1beta1"
Expand Down Expand Up @@ -68,6 +69,7 @@ func initScheme(scheme *runtime.Scheme) {
utilruntime.Must(mapiv1beta1.Install(scheme))
utilruntime.Must(configv1.Install(scheme))
utilruntime.Must(awsv1.AddToScheme(scheme))
utilruntime.Must(metal3v1.AddToScheme(scheme))
utilruntime.Must(openstackv1.AddToScheme(scheme))
utilruntime.Must(clusterv1.AddToScheme(scheme))
}
Expand Down Expand Up @@ -196,7 +198,7 @@ func main() {

// Currently we only plan to support AWS, so all others are a noop until they're implemented.
switch provider {
case configv1.AWSPlatformType, configv1.OpenStackPlatformType:
case configv1.AWSPlatformType, configv1.BareMetalPlatformType, configv1.OpenStackPlatformType:
klog.Infof("MachineAPIMigration: starting %s controllers", provider)

default:
Expand Down
2 changes: 1 addition & 1 deletion e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/onsi/gomega v1.38.0
github.com/openshift/api v0.0.0-20250731015415-ed654edbd7c6
github.com/openshift/cluster-api-actuator-pkg v0.0.0-20250729202911-167220318f40
github.com/openshift/cluster-api-provider-baremetal v0.0.0-20250619124612-fb678fec5f7e
github.com/openshift/cluster-api-provider-baremetal v0.0.0-20250930083252-4e6a729c5ac8
k8s.io/api v0.33.3
k8s.io/apimachinery v0.33.3
k8s.io/client-go v0.33.3
Expand Down
4 changes: 2 additions & 2 deletions e2e/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ github.com/openshift/cluster-api-actuator-pkg v0.0.0-20250729202911-167220318f40
github.com/openshift/cluster-api-actuator-pkg v0.0.0-20250729202911-167220318f40/go.mod h1:gYQH3j+az83vG5IuZZohskiBmqLDw7dzhmn1x5Zq5pg=
github.com/openshift/cluster-api-actuator-pkg/testutils v0.0.0-20250821122144-fd0936342469 h1:2Nb7w9xhgZg/ahmvrG4Y/+6Tp/Gfj7KGZZKAupKah8g=
github.com/openshift/cluster-api-actuator-pkg/testutils v0.0.0-20250821122144-fd0936342469/go.mod h1:9+FWWWLkVrnBo1eYhA/0Ehlq5JMgIAHtcB0IF+qV1AA=
github.com/openshift/cluster-api-provider-baremetal v0.0.0-20250619124612-fb678fec5f7e h1:kW+b46Js8hn2oZwsuaYzdX7KAH/Aa9Wy3v1iHGJ3l4o=
github.com/openshift/cluster-api-provider-baremetal v0.0.0-20250619124612-fb678fec5f7e/go.mod h1:xMvpaHoSmJ48WvX970zF82PPD9Wj8cMuZBFH6UxnvbE=
github.com/openshift/cluster-api-provider-baremetal v0.0.0-20250930083252-4e6a729c5ac8 h1:QMC+nokAQLdS8XK488fRlTNgbhuWytNUyRm2w0gsEBc=
github.com/openshift/cluster-api-provider-baremetal v0.0.0-20250930083252-4e6a729c5ac8/go.mod h1:xMvpaHoSmJ48WvX970zF82PPD9Wj8cMuZBFH6UxnvbE=
github.com/openshift/cluster-autoscaler-operator v0.0.1-0.20250702183526-4eb64d553940 h1:NCCRJ7JfGLpRu4IQSV7Qw9VoAdIgF1BiwospisP06a8=
github.com/openshift/cluster-autoscaler-operator v0.0.1-0.20250702183526-4eb64d553940/go.mod h1:zCklcJwbnaNx46KvR38Rh86uZdow5gvub4ATcNDopTM=
github.com/openshift/library-go v0.0.0-20250729191057-91376e1b394e h1:xYT+P++PSc9G+Y47pIcU9fm8IDV/tg6tMi3i+0m23pU=
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ require (
github.com/openshift/api v0.0.0-20250731015415-ed654edbd7c6
github.com/openshift/client-go v0.0.0-20250710075018-396b36f983ee
github.com/openshift/cluster-api-actuator-pkg/testutils v0.0.0-20250821122144-fd0936342469
github.com/openshift/cluster-api-provider-baremetal v0.0.0-20250930083252-4e6a729c5ac8
github.com/openshift/library-go v0.0.0-20250729191057-91376e1b394e
github.com/pkg/errors v0.9.1
github.com/spf13/pflag v1.0.6
Expand Down Expand Up @@ -303,3 +304,5 @@ require (
sigs.k8s.io/kube-storage-version-migrator v0.0.6-0.20230721195810-5c8923c5ff96 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.7.0 // indirect
)

replace github.com/metal3-io/cluster-api-provider-metal3/api => github.com/metal3-io/cluster-api-provider-metal3/api v1.10.1
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,8 @@ github.com/openshift/client-go v0.0.0-20250710075018-396b36f983ee h1:tOtrrxfDEW8
github.com/openshift/client-go v0.0.0-20250710075018-396b36f983ee/go.mod h1:zhRiYyNMk89llof2qEuGPWPD+joQPhCRUc2IK0SB510=
github.com/openshift/cluster-api-actuator-pkg/testutils v0.0.0-20250821122144-fd0936342469 h1:2Nb7w9xhgZg/ahmvrG4Y/+6Tp/Gfj7KGZZKAupKah8g=
github.com/openshift/cluster-api-actuator-pkg/testutils v0.0.0-20250821122144-fd0936342469/go.mod h1:9+FWWWLkVrnBo1eYhA/0Ehlq5JMgIAHtcB0IF+qV1AA=
github.com/openshift/cluster-api-provider-baremetal v0.0.0-20250930083252-4e6a729c5ac8 h1:QMC+nokAQLdS8XK488fRlTNgbhuWytNUyRm2w0gsEBc=
github.com/openshift/cluster-api-provider-baremetal v0.0.0-20250930083252-4e6a729c5ac8/go.mod h1:xMvpaHoSmJ48WvX970zF82PPD9Wj8cMuZBFH6UxnvbE=
github.com/openshift/library-go v0.0.0-20250729191057-91376e1b394e h1:xYT+P++PSc9G+Y47pIcU9fm8IDV/tg6tMi3i+0m23pU=
github.com/openshift/library-go v0.0.0-20250729191057-91376e1b394e/go.mod h1:tptKNust9MdRI0p90DoBSPHIrBa9oh+Rok59tF0vT8c=
github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw=
Expand Down
12 changes: 1 addition & 11 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,6 @@ github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJS
github.com/jessevdk/go-flags v1.6.1/go.mod h1:Mk8T1hIAWpOiJiHa9rJASDK2UGWji0EuPGBnNLMooyc=
github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af/go.mod h1:HEWGJkRDzjJY2sqdDwxccsGicWEf9BQOZsq2tV+xzM0=
github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jmespath/go-jmespath v0.4.1-0.20220621161143-b0104c826a24/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ=
github.com/jonboulle/clockwork v0.4.0/go.mod h1:xgRqUGwRcjKCO1vbZUEtSLrqKoPSsUpK7fnezOII0kc=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
Expand All @@ -633,7 +632,6 @@ github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
Expand All @@ -644,10 +642,7 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kyoh86/exportloopref v0.1.11/go.mod h1:qkV4UF1zGl6EkF1ox8L5t9SwyeBAZ3qLMd6up458uqA=
github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80/go.mod h1:imJHygn/1yfhB7XSJJKlFZKl/J+dCPAknuiaGOshXAs=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
Expand Down Expand Up @@ -790,7 +785,6 @@ github.com/sanathkr/go-yaml v0.0.0-20170819195128-ed9d249f429b/go.mod h1:8458kAa
github.com/sanathkr/yaml v0.0.0-20170819201035-0056894fa522/go.mod h1:tQTYKOQgxoH3v6dEmdHiz4JG+nbxWwM5fgPQUpSZqVQ=
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY=
github.com/seccomp/libseccomp-golang v0.10.0/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg=
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c/go.mod h1:/PevMnwAxekIXwN8qQyfc5gl2NlkB3CQlkizAbOkeBs=
github.com/shirou/gopsutil/v4 v4.25.2/go.mod h1:34gBYJzyqCDT11b6bMHP0XCvWeU3J61XRT7a2EmCRTA=
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
Expand Down Expand Up @@ -1384,7 +1378,6 @@ google.golang.org/protobuf v1.36.3/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojt
google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
Expand Down Expand Up @@ -1472,11 +1465,8 @@ sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h6
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo=
sigs.k8s.io/kind v0.27.0/go.mod h1:RZVFmy6qcwlSWwp6xeIUv7kXCPF3i8MXsEXxW/J+gJY=
sigs.k8s.io/kind v0.29.0/go.mod h1:ldWQisw2NYyM6k64o/tkZng/1qQW7OlzcN5a8geJX3o=
sigs.k8s.io/kustomize/api v0.19.0 h1:F+2HB2mU1MSiR9Hp1NEgoU2q9ItNOaBJl0I4Dlus5SQ=
sigs.k8s.io/kustomize/api v0.19.0/go.mod h1:/BbwnivGVcBh1r+8m3tH1VNxJmHSk1PzP5fkP6lbL1o=
sigs.k8s.io/kustomize/cmd/config v0.19.0/go.mod h1:29Vvdl26PidPLUDi7nfjYa/I0wHBkwCZp15Nlcc4y98=
sigs.k8s.io/kustomize/kustomize/v5 v5.6.0/go.mod h1:XuuZiQF7WdcvZzEYyNww9A0p3LazCKeJmCjeycN8e1I=
sigs.k8s.io/kustomize/kyaml v0.19.0 h1:RFge5qsO1uHhwJsu3ipV7RNolC7Uozc0jUBC/61XSlA=
sigs.k8s.io/kustomize/kyaml v0.19.0/go.mod h1:FeKD5jEOH+FbZPpqUghBP8mrLjJ3+zD3/rf9NNu1cwY=
sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4=
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
software.sslmate.com/src/go-pkcs12 v0.5.0/go.mod h1:Qiz0EyvDRJjjxGyUQa2cCNZn/wMyzrRJ/qcDXOQazLI=
4 changes: 2 additions & 2 deletions hack/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/golangci/golangci-lint v1.64.8
github.com/jstemmer/go-junit-report v0.9.1
github.com/onsi/ginkgo/v2 v2.23.4
sigs.k8s.io/kustomize/kustomize/v5 v5.4.1
sigs.k8s.io/kustomize/kustomize/v5 v5.6.0
)

require (
Expand Down Expand Up @@ -213,7 +213,7 @@ require (
mvdan.cc/unparam v0.0.0-20240528143540-8a5130ca722f // indirect
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
sigs.k8s.io/kustomize/api v0.19.0 // indirect
sigs.k8s.io/kustomize/cmd/config v0.14.0 // indirect
sigs.k8s.io/kustomize/cmd/config v0.19.0 // indirect
sigs.k8s.io/kustomize/kyaml v0.19.0 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
8 changes: 4 additions & 4 deletions hack/tools/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -599,10 +599,10 @@ sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 h1:gBQPwqORJ8d8/YNZWEjoZs7np
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg=
sigs.k8s.io/kustomize/api v0.19.0 h1:F+2HB2mU1MSiR9Hp1NEgoU2q9ItNOaBJl0I4Dlus5SQ=
sigs.k8s.io/kustomize/api v0.19.0/go.mod h1:/BbwnivGVcBh1r+8m3tH1VNxJmHSk1PzP5fkP6lbL1o=
sigs.k8s.io/kustomize/cmd/config v0.14.0 h1:TMKWBtk0Ox1EUwafT9hncg7EFrvrBlqDDHXmBHm51U8=
sigs.k8s.io/kustomize/cmd/config v0.14.0/go.mod h1:J+ukok4u7k8esCzEhRTygTW7dzDKYbC0kCDkpBK3VfI=
sigs.k8s.io/kustomize/kustomize/v5 v5.4.1 h1:97qXYnSngAvY+gUAzMfjJ73ClKZAD+JrKE+7OIMWYhw=
sigs.k8s.io/kustomize/kustomize/v5 v5.4.1/go.mod h1:nKouayWQbaro85jrNbcA+tZ6x63wYYxGPgniA/fEmgQ=
sigs.k8s.io/kustomize/cmd/config v0.19.0 h1:D3uASwjHWHmNiEHu3pPJBJMBIsb+auFvHrHql3HAarU=
sigs.k8s.io/kustomize/cmd/config v0.19.0/go.mod h1:29Vvdl26PidPLUDi7nfjYa/I0wHBkwCZp15Nlcc4y98=
sigs.k8s.io/kustomize/kustomize/v5 v5.6.0 h1:MWtRRDWCwQEeW2rnJTqJMuV6Agy56P53SkbVoJpN7wA=
sigs.k8s.io/kustomize/kustomize/v5 v5.6.0/go.mod h1:XuuZiQF7WdcvZzEYyNww9A0p3LazCKeJmCjeycN8e1I=
sigs.k8s.io/kustomize/kyaml v0.19.0 h1:RFge5qsO1uHhwJsu3ipV7RNolC7Uozc0jUBC/61XSlA=
sigs.k8s.io/kustomize/kyaml v0.19.0/go.mod h1:FeKD5jEOH+FbZPpqUghBP8mrLjJ3+zD3/rf9NNu1cwY=
sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU=
Expand Down
5 changes: 5 additions & 0 deletions pkg/controllers/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"errors"
"fmt"

metal3v1 "github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1"
configv1 "github.com/openshift/api/config/v1"
awsv1 "sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2"
ibmpowervsv1 "sigs.k8s.io/cluster-api-provider-ibmcloud/api/v1beta2"
Expand All @@ -42,6 +43,8 @@ func InitInfraMachineAndInfraClusterFromProvider(platform configv1.PlatformType)
switch platform {
case configv1.AWSPlatformType:
return &awsv1.AWSMachine{}, &awsv1.AWSCluster{}, nil
case configv1.BareMetalPlatformType:
return &metal3v1.Metal3Machine{}, &metal3v1.Metal3Cluster{}, nil
case configv1.OpenStackPlatformType:
return &openstackv1.OpenStackMachine{}, &openstackv1.OpenStackCluster{}, nil
case configv1.PowerVSPlatformType:
Expand All @@ -59,6 +62,8 @@ func InitInfraMachineTemplateAndInfraClusterFromProvider(platform configv1.Platf
switch platform {
case configv1.AWSPlatformType:
return &awsv1.AWSMachineTemplate{}, &awsv1.AWSCluster{}, nil
case configv1.BareMetalPlatformType:
return &metal3v1.Metal3MachineTemplate{}, &metal3v1.Metal3Cluster{}, nil
case configv1.OpenStackPlatformType:
return &openstackv1.OpenStackMachineTemplate{}, &openstackv1.OpenStackCluster{}, nil
case configv1.PowerVSPlatformType:
Expand Down
48 changes: 47 additions & 1 deletion pkg/controllers/machinesetsync/machineset_sync_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
utilerrors "k8s.io/apimachinery/pkg/util/errors"

"github.com/go-test/deep"
metal3v1 "github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1"
machinev1applyconfigs "github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
Expand Down Expand Up @@ -75,6 +76,9 @@ var (
// errAssertingCAPIAWSMachineTemplate is returned when we encounter an issue asserting a client.Object into a AWSMachineTemplate.
errAssertingCAPIAWSMachineTemplate = errors.New("error asserting the CAPI AWSMachineTemplate object")

// errAssertingCAPIMetal3MachineTemplate is returned when we encounter an issue asserting a client.Object into a Metal3MachineTemplate.
errAssertingCAPIMetal3MachineTemplate = errors.New("error asserting the CAPI Metal3MachineTemplate object")

// errAssertingCAPIPowerVSMachineTemplate is returned when we encounter an issue asserting a client.Object into a IBMPowerVSMachineTemplate.
errAssertingCAPIIBMPowerVSMachineTemplate = errors.New("error asserting the CAPI IBMPowerVSMachineTemplate object")

Expand Down Expand Up @@ -665,6 +669,20 @@ func (r *MachineSetSyncReconciler) convertCAPIToMAPIMachineSet(capiMachineSet *c
return capi2mapi.FromMachineSetAndAWSMachineTemplateAndAWSCluster( //nolint: wrapcheck
capiMachineSet, machineTemplate, cluster,
).ToMachineSet()
case configv1.BareMetalPlatformType:
machineTemplate, ok := infraMachineTemplate.(*metal3v1.Metal3MachineTemplate)
if !ok {
return nil, nil, fmt.Errorf("%w, expected Metal3MachineTemplate, got %T", errUnexpectedInfraMachineTemplateType, infraMachineTemplate)
}

cluster, ok := infraCluster.(*metal3v1.Metal3Cluster)
if !ok {
return nil, nil, fmt.Errorf("%w, expected Metal3Cluster, got %T", errUnexpectedInfraClusterType, infraCluster)
}

return capi2mapi.FromMachineSetAndMetal3MachineTemplateAndMetal3Cluster( //nolint: wrapcheck
capiMachineSet, machineTemplate, cluster,
).ToMachineSet()
case configv1.OpenStackPlatformType:
machineTemplate, ok := infraMachineTemplate.(*openstackv1.OpenStackMachineTemplate)
if !ok {
Expand Down Expand Up @@ -703,6 +721,8 @@ func (r *MachineSetSyncReconciler) convertMAPIToCAPIMachineSet(mapiMachineSet *m
switch r.Platform {
case configv1.AWSPlatformType:
return mapi2capi.FromAWSMachineSetAndInfra(mapiMachineSet, r.Infra).ToMachineSetAndMachineTemplate() //nolint:wrapcheck
case configv1.BareMetalPlatformType:
return mapi2capi.FromMetal3MachineSetAndInfra(mapiMachineSet, r.Infra).ToMachineSetAndMachineTemplate() //nolint:wrapcheck
case configv1.OpenStackPlatformType:
return mapi2capi.FromOpenStackMachineSetAndInfra(mapiMachineSet, r.Infra).ToMachineSetAndMachineTemplate() //nolint:wrapcheck
case configv1.PowerVSPlatformType:
Expand Down Expand Up @@ -1302,6 +1322,8 @@ func initInfraMachineTemplateListAndInfraClusterListFromProvider(platform config
switch platform {
case configv1.AWSPlatformType:
return &awsv1.AWSMachineTemplateList{}, &awsv1.AWSClusterList{}, nil
case configv1.BareMetalPlatformType:
return &metal3v1.Metal3MachineTemplateList{}, &metal3v1.Metal3ClusterList{}, nil
case configv1.OpenStackPlatformType:
return &openstackv1.OpenStackMachineTemplateList{}, &openstackv1.OpenStackClusterList{}, nil
case configv1.PowerVSPlatformType:
Expand All @@ -1313,7 +1335,7 @@ func initInfraMachineTemplateListAndInfraClusterListFromProvider(platform config

// compareCAPIInfraMachineTemplates compares CAPI infra machine templates a and b, and returns a list of differences, or none if there are none.
//
//nolint:funlen
//nolint:funlen,gocognit,cyclop
func compareCAPIInfraMachineTemplates(platform configv1.PlatformType, infraMachineTemplate1, infraMachineTemplate2 client.Object) (map[string]any, error) {
switch platform {
case configv1.AWSPlatformType:
Expand All @@ -1339,6 +1361,30 @@ func compareCAPIInfraMachineTemplates(platform configv1.PlatformType, infraMachi

// TODO: Evaluate if we want to add status comparison if needed in the future (e.g. for scale from zero capacity).

return diff, nil
case configv1.BareMetalPlatformType:
typedInfraMachineTemplate1, ok := infraMachineTemplate1.(*metal3v1.Metal3MachineTemplate)
if !ok {
return nil, errAssertingCAPIMetal3MachineTemplate
}

typedinfraMachineTemplate2, ok := infraMachineTemplate2.(*metal3v1.Metal3MachineTemplate)
if !ok {
return nil, errAssertingCAPIMetal3MachineTemplate
}

diff := make(map[string]any)

if diffSpec := deep.Equal(typedInfraMachineTemplate1.Spec, typedinfraMachineTemplate2.Spec); len(diffSpec) > 0 {
diff[".spec"] = diffSpec
}

if diffObjectMeta := util.ObjectMetaEqual(typedInfraMachineTemplate1.ObjectMeta, typedinfraMachineTemplate2.ObjectMeta); len(diffObjectMeta) > 0 {
diff[".metadata"] = diffObjectMeta
}

// TODO: Evaluate if we want to add status comparison if needed in the future (e.g. for scale from zero capacity).

Comment on lines +1366 to +1387
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix OpenStack error constant; consider consistent metadata diff

  • Line 1397: On OpenStack, wrong error constant is returned on type assertion failure (IBMPowerVS instead of OpenStack). Use errAssertingCAPIOpenStackMachineTemplate.
  • Optional: Use util.ObjectMetaEqual for metadata like other providers to avoid noisy diffs on transient fields.
 case configv1.OpenStackPlatformType:
   typedInfraMachineTemplate1, ok := infraMachineTemplate1.(*openstackv1.OpenStackMachineTemplate)
   if !ok {
-    return nil, errAssertingCAPIIBMPowerVSMachineTemplate
+    return nil, errAssertingCAPIOpenStackMachineTemplate
   }
 
   typedinfraMachineTemplate2, ok := infraMachineTemplate2.(*openstackv1.OpenStackMachineTemplate)
   if !ok {
     return nil, errAssertingCAPIOpenStackMachineTemplate
   }
 
   diff := make(map[string]any)
 
   if diffSpec := deep.Equal(typedInfraMachineTemplate1.Spec, typedinfraMachineTemplate2.Spec); len(diffSpec) > 0 {
     diff[".spec"] = diffSpec
   }
 
-  if diffObjectMeta := deep.Equal(typedInfraMachineTemplate1.ObjectMeta, typedinfraMachineTemplate2.ObjectMeta); len(diffObjectMeta) > 0 {
+  // Optional: keep consistent with other providers
+  if diffObjectMeta := util.ObjectMetaEqual(typedInfraMachineTemplate1.ObjectMeta, typedinfraMachineTemplate2.ObjectMeta); len(diffObjectMeta) > 0 {
     diff[".metadata"] = diffObjectMeta
   }

Also applies to: 1395-1403

🤖 Prompt for AI Agents
In pkg/controllers/machinesetsync/machineset_sync_controller.go around lines
1371-1392 (also apply to 1395-1403), fix the incorrect error constant used on
the type-assertion failure for the OpenStack provider by returning
errAssertingCAPIOpenStackMachineTemplate instead of the
IBMPowerVS/OpenStack-mismatched constant; additionally, make the metadata
comparison use util.ObjectMetaEqual (same approach as spec) to avoid noisy diffs
from transient metadata fields.

return diff, nil
case configv1.OpenStackPlatformType:
typedInfraMachineTemplate1, ok := infraMachineTemplate1.(*openstackv1.OpenStackMachineTemplate)
Expand Down
Loading