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
2 changes: 1 addition & 1 deletion e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require (
k8s.io/client-go v0.34.1
k8s.io/utils v0.0.0-20250820121507-0af2bda4dd1d
sigs.k8s.io/cluster-api v1.11.3
sigs.k8s.io/cluster-api-provider-aws/v2 v2.10.0
sigs.k8s.io/cluster-api-provider-aws/v2 v2.10.1-0.20251223195230-7aa98eaf0ba3
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Read the full e2e/go.mod file to see the context
cat e2e/go.mod

Repository: openshift/cluster-capi-operator

Length of output: 7048


🏁 Script executed:

# Search for the commit hash and PR references in the codebase
rg "7aa98eaf0ba3|5801" -C 3

Repository: openshift/cluster-capi-operator

Length of output: 29898


Add TODO comment for consistency with other temporary dependencies.

This pseudo-version should include a TODO comment documenting that it depends on an upstream PR fix, following the pattern used for other temporary dependencies in lines 5-10. The module is properly vendored, but lacks documentation explaining its temporary status.

Suggested change
+// TODO: Update to released version once upstream fix is available
	sigs.k8s.io/cluster-api-provider-aws/v2 v2.10.1-0.20251223195230-7aa98eaf0ba3
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
sigs.k8s.io/cluster-api-provider-aws/v2 v2.10.1-0.20251223195230-7aa98eaf0ba3
// TODO: Update to released version once upstream fix is available
sigs.k8s.io/cluster-api-provider-aws/v2 v2.10.1-0.20251223195230-7aa98eaf0ba3
🤖 Prompt for AI Agents
In @e2e/go.mod at line 27, Add a TODO comment above the pseudo-version
dependency line for sigs.k8s.io/cluster-api-provider-aws/v2
v2.10.1-0.20251223195230-7aa98eaf0ba3 noting this is a temporary workaround that
depends on an upstream PR fix (include PR number/link and an expected removal
condition), mirroring the style and placement used for other temporary
dependencies in lines 5-10 so future maintainers know why this pseudo-version is
vendored and when to revert it.

sigs.k8s.io/cluster-api-provider-azure v0.0.0-20251202084521-c2e0e38d1e0e
sigs.k8s.io/cluster-api-provider-gcp v1.11.0-beta.0
sigs.k8s.io/cluster-api-provider-ibmcloud v0.12.0
Expand Down
4 changes: 2 additions & 2 deletions e2e/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ k8s.io/utils v0.0.0-20250820121507-0af2bda4dd1d h1:wAhiDyZ4Tdtt7e46e9M5ZSAJ/MnPG
k8s.io/utils v0.0.0-20250820121507-0af2bda4dd1d/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
sigs.k8s.io/cluster-api v1.11.3 h1:apxfugbP1X8AG7THCM74CTarCOW4H2oOc6hlbm1hY80=
sigs.k8s.io/cluster-api v1.11.3/go.mod h1:CA471SACi81M8DzRKTlWpHV33G0cfWEj7sC4fALFVok=
sigs.k8s.io/cluster-api-provider-aws/v2 v2.10.0 h1:E28NopVRAtnenHsfh54VwS2uEpGAkW0bv6Y19bqAwCg=
sigs.k8s.io/cluster-api-provider-aws/v2 v2.10.0/go.mod h1:cuuFljMXGat8qW+lvSdYEWReR0DSauv19/rh+bpobl4=
sigs.k8s.io/cluster-api-provider-aws/v2 v2.10.1-0.20251223195230-7aa98eaf0ba3 h1:iXVmV2TbrOrMAKJqMOmlEJVKXIiRsLFfe3NqhIN0xeY=
sigs.k8s.io/cluster-api-provider-aws/v2 v2.10.1-0.20251223195230-7aa98eaf0ba3/go.mod h1:cuuFljMXGat8qW+lvSdYEWReR0DSauv19/rh+bpobl4=
sigs.k8s.io/cluster-api-provider-gcp v1.11.0-beta.0 h1:PedFCYmcZRGa+0x8jDw6DYpm1rikyzP8CTQNHvydWtw=
sigs.k8s.io/cluster-api-provider-gcp v1.11.0-beta.0/go.mod h1:BR9XUljy5o4V6MNTZva4XFh7Gj++4d5G8AnKa6iB6Tc=
sigs.k8s.io/cluster-api-provider-ibmcloud v0.12.0 h1:0+jfWLg+UmnGOdHZ9SrEpnUJgQPyyXpcjXGdkN5E5M4=
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ require (
k8s.io/klog/v2 v2.130.1
k8s.io/utils v0.0.0-20250820121507-0af2bda4dd1d
sigs.k8s.io/cluster-api v1.11.3
sigs.k8s.io/cluster-api-provider-aws/v2 v2.10.0
sigs.k8s.io/cluster-api-provider-aws/v2 v2.10.1-0.20251223195230-7aa98eaf0ba3
sigs.k8s.io/cluster-api-provider-azure v0.0.0-20251202084521-c2e0e38d1e0e
sigs.k8s.io/cluster-api-provider-gcp v1.11.0-beta.0
sigs.k8s.io/cluster-api-provider-ibmcloud v0.12.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -852,8 +852,8 @@ sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.32.0 h1:XotDXzqvJ8Nx5
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.32.0/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw=
sigs.k8s.io/cluster-api v1.11.3 h1:apxfugbP1X8AG7THCM74CTarCOW4H2oOc6hlbm1hY80=
sigs.k8s.io/cluster-api v1.11.3/go.mod h1:CA471SACi81M8DzRKTlWpHV33G0cfWEj7sC4fALFVok=
sigs.k8s.io/cluster-api-provider-aws/v2 v2.10.0 h1:E28NopVRAtnenHsfh54VwS2uEpGAkW0bv6Y19bqAwCg=
sigs.k8s.io/cluster-api-provider-aws/v2 v2.10.0/go.mod h1:cuuFljMXGat8qW+lvSdYEWReR0DSauv19/rh+bpobl4=
sigs.k8s.io/cluster-api-provider-aws/v2 v2.10.1-0.20251223195230-7aa98eaf0ba3 h1:iXVmV2TbrOrMAKJqMOmlEJVKXIiRsLFfe3NqhIN0xeY=
sigs.k8s.io/cluster-api-provider-aws/v2 v2.10.1-0.20251223195230-7aa98eaf0ba3/go.mod h1:cuuFljMXGat8qW+lvSdYEWReR0DSauv19/rh+bpobl4=
sigs.k8s.io/cluster-api-provider-gcp v1.11.0-beta.0 h1:PedFCYmcZRGa+0x8jDw6DYpm1rikyzP8CTQNHvydWtw=
sigs.k8s.io/cluster-api-provider-gcp v1.11.0-beta.0/go.mod h1:BR9XUljy5o4V6MNTZva4XFh7Gj++4d5G8AnKa6iB6Tc=
sigs.k8s.io/cluster-api-provider-ibmcloud v0.12.0 h1:0+jfWLg+UmnGOdHZ9SrEpnUJgQPyyXpcjXGdkN5E5M4=
Expand Down
398 changes: 398 additions & 0 deletions go.work.sum

Large diffs are not rendered by default.

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.27.2
sigs.k8s.io/kustomize/kustomize/v5 v5.4.1
sigs.k8s.io/kustomize/kustomize/v5 v5.7.1
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's check the current state of the go.mod file to see the actual versions
cat hack/tools/go.mod | head -30

Repository: openshift/cluster-capi-operator

Length of output: 206


🌐 Web query:

kustomize v5.4.1 v5.7.1 breaking changes release notes

💡 Result:

Summary of breaking changes between kustomize v5.4.1 and v5.7.1:

  • v5.4.0 (fixed in v5.4.1): null YAML values were being replaced by the string "null" (breaking change introduced in v5.4.0). [1]. (newreleases.io)
  • v5.5.0: removal of Starlark support for KRM functions (breaking change). [2]. (newreleases.io)
  • v5.7.1: no new breaking behavior called out in the v5.7.1 release notes; the release primarily drops the shlex dependency and updates libraries (note: if your workflows rely on the exec plugin argument parsing, test after upgrading). [3]. (github.com)

Sources:
[1] kustomize v5.4.1 / v5.4.0 release notes. (newreleases.io)
[2] kustomize v5.5.0 release notes (breaking: Starlark support removed). (newreleases.io)
[3] kustomize v5.7.1 release notes (drop shlex dependency; dependency updates). (github.com)

Would you like links to the specific GitHub release pages or a short upgrade checklist?

Citations:


🌐 Web query:

sigs.k8s.io/kustomize/kustomize/v5 v5.7.1 changelog

💡 Result:

Summary of kustomize v5.7.1 (sigs.k8s.io/kustomize/kustomize/v5)

  • Drops the shlex dependency (replace shlex-based arg parsing for exec plugin).
  • Updates dependencies: kyaml → v0.20.1, cmd/config → v0.20.1, api → v0.20.1.
  • Note: release message warns to file an issue if existing manifests become corrupted by the exec-plugin arg parsing change.

Source: GitHub release for kustomize v5.7.1. [1]

[1] kubernetes-sigs/kustomize — Releases (kustomize/v5.7.1).


Kustomize v5.5.0 removed Starlark support for KRM functions and v5.7.1 changed exec plugin argument parsing due to dropping the shlex dependency.

The update path (v5.4.1 → v5.7.1) introduces breaking changes in v5.5.0 (Starlark support removal) and a behavioral change in v5.7.1 (shlex dependency drop affecting exec plugin arg parsing). Verify whether:

  • Your kustomize configurations or plugins use Starlark for KRM functions
  • Your workflows rely on the exec plugin—if so, test argument parsing after upgrading
🤖 Prompt for AI Agents
In @hack/tools/go.mod at line 11, Your updated dependency line
"sigs.k8s.io/kustomize/kustomize/v5 v5.7.1" introduces breaking changes: v5.5.0
removed Starlark KRM function support and v5.7.1 changed exec plugin arg
parsing; inspect any use of Starlark-based KRM functions and any exec plugins in
your kustomize overlays/plugins, run end-to-end builds to validate behavior, and
either (a) adapt those plugins/manifests to native Go functions or alternative
scripting or adjust exec plugin invocation to the new argument parsing, or (b)
pin the kustomize version to a compatible release (e.g., v5.4.1) in the go.mod
until you’ve migrated and tested.

)

require (
Expand Down Expand Up @@ -216,7 +216,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.20.1 // indirect
sigs.k8s.io/kustomize/cmd/config v0.14.0 // indirect
sigs.k8s.io/kustomize/cmd/config v0.20.1 // indirect
sigs.k8s.io/kustomize/kyaml v0.20.1 // indirect
sigs.k8s.io/yaml v1.6.0 // indirect
)
8 changes: 4 additions & 4 deletions hack/tools/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -627,10 +627,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.20.1 h1:iWP1Ydh3/lmldBnH/S5RXgT98vWYMaTUL1ADcr+Sv7I=
sigs.k8s.io/kustomize/api v0.20.1/go.mod h1:t6hUFxO+Ph0VxIk1sKp1WS0dOjbPCtLJ4p8aADLwqjM=
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.20.1 h1:4APUORmZe2BYrsqgGfEKdd/r7gM6i43egLrUzilpiFo=
sigs.k8s.io/kustomize/cmd/config v0.20.1/go.mod h1:R7rQ8kxknVlXWVUIbxWtMgu8DCCNVtl8V0KrmeVd/KE=
sigs.k8s.io/kustomize/kustomize/v5 v5.7.1 h1:sYJsarwy/SDJfjjLMUqwFDGPwzUtMOQ1i1Ed49+XSbw=
sigs.k8s.io/kustomize/kustomize/v5 v5.7.1/go.mod h1:+5/SrBcJ4agx1SJknGuR/c9thwRSKLxnKoI5BzXFaLU=
sigs.k8s.io/kustomize/kyaml v0.20.1 h1:PCMnA2mrVbRP3NIB6v9kYCAc38uvFLVs8j/CD567A78=
sigs.k8s.io/kustomize/kyaml v0.20.1/go.mod h1:0EmkQHRUsJxY8Ug9Niig1pUMSCGHxQ5RklbpV/Ri6po=
sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU=
Expand Down
1 change: 1 addition & 0 deletions manifests/0000_30_cluster-api_01_credentials-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ spec:
- ec2:DescribeDhcpOptions
- ec2:DescribeImages
- ec2:DescribeInstances
- ec2:DescribeInstanceTypes
Copy link

Choose a reason for hiding this comment

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

I believe it would be nice to add this change to a new commit referencing the reason of adding it (upstream PR, jira feature, etc).

this would be used to document in the future and/or in managed services to eventually update the managed IAM.

Copy link
Author

Choose a reason for hiding this comment

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

Sure! There is a warning message that is caused by this missing. I am not 100% sure this feature introduced it, but I am happy to put into a separate commit.

- ec2:DescribeInternetGateways
- ec2:DescribeSecurityGroups
- ec2:DescribeSubnets
Expand Down
80 changes: 75 additions & 5 deletions pkg/conversion/capi2mapi/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"errors"
"fmt"
"math"
"regexp"
"strings"

mapiv1beta1 "github.com/openshift/api/machine/v1beta1"
Expand All @@ -39,14 +40,27 @@ var (
errCAPIMachineSetAWSMachineTemplateAWSClusterCannotBeNil = errors.New("provided MachineSet, AWSMachineTemplate and AWSCluster can not be nil")
errNilLoadBalancer = errors.New("nil load balancer")
errUnsupportedLoadBalancerType = errors.New("unsupported load balancer type")

// awsDedicatedHostNamePattern is used to validate the id of a dedicated host.
awsDedicatedHostNamePattern = regexp.MustCompile(`^h-(?:[0-9a-f]{8}|[0-9a-f]{17})$`)
)

const (
errUnsupportedCAPATenancy = "unable to convert tenancy, unknown value"
errUnsupportedCAPAMarketType = "unable to convert market type, unknown value"
errUnsupportedHTTPTokensState = "unable to convert httpTokens state, unknown value" //nolint:gosec // This is an error message, not a credential
defaultIdentityName = "default"
defaultCredentialsSecretName = "aws-cloud-credentials" //#nosec G101 -- False positive, not actually a credential.
errUnsupportedCAPATenancy = "unable to convert tenancy, unknown value"
errUnsupportedCAPAMarketType = "unable to convert market type, unknown value"
errUnsupportedHTTPTokensState = "unable to convert httpTokens state, unknown value" //nolint:gosec // This is an error message, not a credential
defaultIdentityName = "default"
defaultCredentialsSecretName = "aws-cloud-credentials" //#nosec G101 -- False positive, not actually a credential.
errUnsupportedHostAffinityType = "unable to convert hostAffinity, unknown value"
errHostIDRequired = "id is required and must start with 'h-' followed by 8 or 17 lowercase hexadecimal characters (0-9 and a-f)"
errHostIDInvalidFormat = "id must start with 'h-' followed by 8 or 17 lowercase hexadecimal characters (0-9 and a-f)"

// TenancyDefault default setting for tenancy.
TenancyDefault = "default"
// TenancyDedicated dedicated setting for tenancy.
TenancyDedicated = "dedicated"
// TenancyHost host setting for tenancy.
TenancyHost = "host"
)

// machineAndAWSMachineAndAWSCluster stores the details of a Cluster API Machine and AWSMachine and AWSCluster.
Expand Down Expand Up @@ -170,6 +184,12 @@ func (m machineAndAWSMachineAndAWSCluster) toProviderSpec() (*mapiv1beta1.AWSMac
MarketType: mapiAWSMarketType,
}

// Dedicated host support
mapaProviderConfig.Placement.Host, errs = convertAWSDedicatedHostToMAPI(m.awsMachine.Spec, fldPath)
if len(errs) > 0 {
errors = append(errors, errs...)
}

secretRef, errs := handleAWSIdentityRef(fldPath.Child("identityRef"), m.awsCluster.Spec.IdentityRef)

if len(errs) > 0 {
Expand Down Expand Up @@ -219,6 +239,56 @@ func (m machineAndAWSMachineAndAWSCluster) toProviderStatus() *mapiv1beta1.AWSMa
return s
}

func convertAWSDedicatedHostToMAPI(spec awsv1.AWSMachineSpec, fldPath *field.Path) (*mapiv1beta1.HostPlacement, field.ErrorList) {
var (
errorList field.ErrorList
host *mapiv1beta1.HostPlacement
)

if spec.HostAffinity == nil {
return host, errorList
}

switch *spec.HostAffinity {
case "host":
// For "host", host id is required in mapi. Let's make sure it is set and id is valid
if spec.HostID == nil {
errorList = append(errorList, field.Required(fldPath.Child("dedicatedHost").Child("id"), errHostIDRequired))
break
} else if !awsDedicatedHostNamePattern.MatchString(*spec.HostID) {
errorList = append(errorList, field.Invalid(fldPath.Child("dedicatedHost").Child("id"), *spec.HostID, errHostIDRequired))
break
}

host = &mapiv1beta1.HostPlacement{
Affinity: ptr.To(mapiv1beta1.HostAffinityDedicatedHost),
DedicatedHost: &mapiv1beta1.DedicatedHost{
ID: *spec.HostID,
},
}
case "default":
host = &mapiv1beta1.HostPlacement{
Affinity: ptr.To(mapiv1beta1.HostAffinityAnyAvailable),
}

// For "default", host ID is optional, and in MAPI we treat host as option in relation to this. If it is set, lets validate it.
if spec.HostID != nil {
if !awsDedicatedHostNamePattern.MatchString(*spec.HostID) {
errorList = append(errorList, field.Invalid(fldPath.Child("dedicatedHost").Child("id"), *spec.HostID, errHostIDInvalidFormat))
break
}

host.DedicatedHost = &mapiv1beta1.DedicatedHost{
ID: *spec.HostID,
}
}
default:
errorList = append(errorList, field.Invalid(fldPath.Child("hostAffinity"), spec.HostAffinity, errUnsupportedHostAffinityType))
}

return host, errorList
}

func convertCAPAMachineConditionsToMAPIMachineAWSProviderConditions(awsMachine *awsv1.AWSMachine) []metav1.Condition {
if ptr.Deref(awsMachine.Status.InstanceState, "") == awsv1.InstanceStateRunning {
// Set conditionSuccess
Expand Down
31 changes: 24 additions & 7 deletions pkg/conversion/capi2mapi/aws_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
conversiontest "github.com/openshift/cluster-capi-operator/pkg/conversion/test/fuzz"

runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/utils/ptr"
awsv1 "sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -156,7 +157,7 @@ func awsMachineFuzzerFuncs(codecs runtimeserializer.CodecFactory) []interface{}
func(spec *awsv1.AWSMachineSpec, c randfill.Continue) {
c.FillNoCustom(spec)

fuzzAWSMachineSpecTenancy(&spec.Tenancy, c)
fuzzAWSMachineSpecTenancy(spec, c)
fuzzAWSMachineSpecMarketType(&spec.MarketType, c)
fuzzAWSMachineSpecCPUOptions(&spec.CPUOptions, c)

Expand Down Expand Up @@ -192,16 +193,32 @@ func awsMachineFuzzerFuncs(codecs runtimeserializer.CodecFactory) []interface{}
}
}

func fuzzAWSMachineSpecTenancy(tenancy *string, c randfill.Continue) {
switch c.Int31n(4) {
func fuzzAWSMachineSpecTenancy(spec *awsv1.AWSMachineSpec, c randfill.Continue) {
switch c.Int31n(6) {
case 0:
*tenancy = "default"
spec.Tenancy = capi2mapi.TenancyDefault
spec.HostAffinity = nil
spec.HostID = nil
case 1:
*tenancy = "dedicated"
spec.Tenancy = capi2mapi.TenancyDedicated
spec.HostAffinity = nil
spec.HostID = nil
case 2:
*tenancy = "host"
spec.Tenancy = capi2mapi.TenancyHost
spec.HostAffinity = ptr.To("default")
spec.HostID = nil
case 3:
*tenancy = ""
spec.Tenancy = capi2mapi.TenancyHost
spec.HostAffinity = ptr.To("default")
spec.HostID = ptr.To("h-0123456789abcdef0")
case 4:
spec.Tenancy = capi2mapi.TenancyHost
spec.HostAffinity = ptr.To("host")
spec.HostID = ptr.To("h-0123456789abcdef0")
case 5:
spec.Tenancy = ""
spec.HostAffinity = nil
spec.HostID = nil
}
}

Expand Down
141 changes: 141 additions & 0 deletions pkg/conversion/capi2mapi/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,147 @@ var _ = Describe("capi2mapi AWS conversion", func() {
expectedErrors: []string{},
expectedWarnings: []string{},
}),
Entry("With HostAffinity default", awsCAPI2MAPIMachineConversionInput{
awsClusterBuilder: awsCAPIAWSClusterBase,
awsMachineBuilder: awsCAPIAWSMachineBase.
WithHostAffinity(ptr.To("default")),
machineBuilder: awsCAPIMachineBase,
expectedErrors: []string{},
expectedWarnings: []string{},
}),
Entry("With HostAffinity host and HostID (17 characters)", awsCAPI2MAPIMachineConversionInput{
awsClusterBuilder: awsCAPIAWSClusterBase,
awsMachineBuilder: awsCAPIAWSMachineBase.
WithHostAffinity(ptr.To("host")).
WithHostID(ptr.To("h-1234567890abcdef0")),
machineBuilder: awsCAPIMachineBase,
expectedErrors: []string{},
expectedWarnings: []string{},
}),
Entry("With HostAffinity host and HostID (8 characters)", awsCAPI2MAPIMachineConversionInput{
awsClusterBuilder: awsCAPIAWSClusterBase,
awsMachineBuilder: awsCAPIAWSMachineBase.
WithHostAffinity(ptr.To("host")).
WithHostID(ptr.To("h-12345678")),
machineBuilder: awsCAPIMachineBase,
expectedErrors: []string{},
expectedWarnings: []string{},
}),
Entry("With HostAffinity default and HostID (8 characters)", awsCAPI2MAPIMachineConversionInput{
awsClusterBuilder: awsCAPIAWSClusterBase,
awsMachineBuilder: awsCAPIAWSMachineBase.
WithHostAffinity(ptr.To("default")).
WithHostID(ptr.To("h-abcdef12")),
machineBuilder: awsCAPIMachineBase,
expectedErrors: []string{},
expectedWarnings: []string{},
}),
Entry("With HostAffinity default and HostID (17 characters)", awsCAPI2MAPIMachineConversionInput{
awsClusterBuilder: awsCAPIAWSClusterBase,
awsMachineBuilder: awsCAPIAWSMachineBase.
WithHostAffinity(ptr.To("default")).
WithHostID(ptr.To("h-fedcba9876543210f")),
machineBuilder: awsCAPIMachineBase,
expectedErrors: []string{},
expectedWarnings: []string{},
}),
Entry("With HostAffinity host and invalid HostID (too short)", awsCAPI2MAPIMachineConversionInput{
awsClusterBuilder: awsCAPIAWSClusterBase,
awsMachineBuilder: awsCAPIAWSMachineBase.
WithHostAffinity(ptr.To("host")).
WithHostID(ptr.To("h-1234567")),
machineBuilder: awsCAPIMachineBase,
expectedErrors: []string{
"spec.dedicatedHost.id: Invalid value: \"h-1234567\": id is required and must start with 'h-' followed by 8 or 17 lowercase hexadecimal characters (0-9 and a-f)",
},
expectedWarnings: []string{},
}),
Entry("With HostAffinity host and invalid HostID (wrong length - 9 characters)", awsCAPI2MAPIMachineConversionInput{
awsClusterBuilder: awsCAPIAWSClusterBase,
awsMachineBuilder: awsCAPIAWSMachineBase.
WithHostAffinity(ptr.To("host")).
WithHostID(ptr.To("h-123456789")),
machineBuilder: awsCAPIMachineBase,
expectedErrors: []string{
"spec.dedicatedHost.id: Invalid value: \"h-123456789\": id is required and must start with 'h-' followed by 8 or 17 lowercase hexadecimal characters (0-9 and a-f)",
},
expectedWarnings: []string{},
}),
Entry("With HostAffinity host and invalid HostID (wrong length - 16 characters)", awsCAPI2MAPIMachineConversionInput{
awsClusterBuilder: awsCAPIAWSClusterBase,
awsMachineBuilder: awsCAPIAWSMachineBase.
WithHostAffinity(ptr.To("host")).
WithHostID(ptr.To("h-1234567890abcdef")),
machineBuilder: awsCAPIMachineBase,
expectedErrors: []string{
"spec.dedicatedHost.id: Invalid value: \"h-1234567890abcdef\": id is required and must start with 'h-' followed by 8 or 17 lowercase hexadecimal characters (0-9 and a-f)",
},
expectedWarnings: []string{},
}),
Entry("With HostAffinity host and invalid HostID (uppercase characters)", awsCAPI2MAPIMachineConversionInput{
awsClusterBuilder: awsCAPIAWSClusterBase,
awsMachineBuilder: awsCAPIAWSMachineBase.
WithHostAffinity(ptr.To("host")).
WithHostID(ptr.To("h-1234567890ABCDEF0")),
machineBuilder: awsCAPIMachineBase,
expectedErrors: []string{
"spec.dedicatedHost.id: Invalid value: \"h-1234567890ABCDEF0\": id is required and must start with 'h-' followed by 8 or 17 lowercase hexadecimal characters (0-9 and a-f)",
},
expectedWarnings: []string{},
}),
Entry("With HostAffinity host and invalid HostID (missing h- prefix)", awsCAPI2MAPIMachineConversionInput{
awsClusterBuilder: awsCAPIAWSClusterBase,
awsMachineBuilder: awsCAPIAWSMachineBase.
WithHostAffinity(ptr.To("host")).
WithHostID(ptr.To("12345678")),
machineBuilder: awsCAPIMachineBase,
expectedErrors: []string{
"spec.dedicatedHost.id: Invalid value: \"12345678\": id is required and must start with 'h-' followed by 8 or 17 lowercase hexadecimal characters (0-9 and a-f)",
},
expectedWarnings: []string{},
}),
Entry("With HostAffinity host and invalid HostID (non-hex characters)", awsCAPI2MAPIMachineConversionInput{
awsClusterBuilder: awsCAPIAWSClusterBase,
awsMachineBuilder: awsCAPIAWSMachineBase.
WithHostAffinity(ptr.To("host")).
WithHostID(ptr.To("h-1234567g")),
machineBuilder: awsCAPIMachineBase,
expectedErrors: []string{
"spec.dedicatedHost.id: Invalid value: \"h-1234567g\": id is required and must start with 'h-' followed by 8 or 17 lowercase hexadecimal characters (0-9 and a-f)",
},
expectedWarnings: []string{},
}),
Entry("With HostAffinity host but missing HostID", awsCAPI2MAPIMachineConversionInput{
awsClusterBuilder: awsCAPIAWSClusterBase,
awsMachineBuilder: awsCAPIAWSMachineBase.
WithHostAffinity(ptr.To("host")),
machineBuilder: awsCAPIMachineBase,
expectedErrors: []string{
"spec.dedicatedHost.id: Required value: id is required and must start with 'h-' followed by 8 or 17 lowercase hexadecimal characters (0-9 and a-f)",
},
expectedWarnings: []string{},
}),
Entry("With HostAffinity default and invalid HostID format", awsCAPI2MAPIMachineConversionInput{
awsClusterBuilder: awsCAPIAWSClusterBase,
awsMachineBuilder: awsCAPIAWSMachineBase.
WithHostAffinity(ptr.To("default")).
WithHostID(ptr.To("h-invalid")),
machineBuilder: awsCAPIMachineBase,
expectedErrors: []string{
"spec.dedicatedHost.id: Invalid value: \"h-invalid\": id must start with 'h-' followed by 8 or 17 lowercase hexadecimal characters (0-9 and a-f)",
},
expectedWarnings: []string{},
}),
Entry("With unsupported HostAffinity", awsCAPI2MAPIMachineConversionInput{
awsClusterBuilder: awsCAPIAWSClusterBase,
awsMachineBuilder: awsCAPIAWSMachineBase.
WithHostAffinity(ptr.To("unsupported")),
machineBuilder: awsCAPIMachineBase,
expectedErrors: []string{
"spec.hostAffinity: Invalid value: \"unsupported\": unable to convert hostAffinity, unknown value",
},
expectedWarnings: []string{},
}),
Entry("With unsupported EKSOptimizedLookupType", awsCAPI2MAPIMachineConversionInput{
awsClusterBuilder: awsCAPIAWSClusterBase,
awsMachineBuilder: capabuilder.AWSMachine().
Expand Down
Loading