Skip to content

Commit 456f651

Browse files
Merge pull request #1242 from chiragkyal/partition-number
CFE-1065: Add support for PlacementGroupPartition of placement group
2 parents 4ecb7fe + b5a3246 commit 456f651

16 files changed

+125
-58
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/google/uuid v1.6.0
1111
github.com/onsi/ginkgo/v2 v2.17.1
1212
github.com/onsi/gomega v1.32.0
13-
github.com/openshift/api v0.0.0-20240530053948-b01900f1982a
13+
github.com/openshift/api v0.0.0-20240613141850-76a71dac36a0
1414
github.com/openshift/client-go v0.0.0-20240528061634-b054aa794d87
1515
github.com/openshift/library-go v0.0.0-20240116081341-964bcb3f545c
1616
github.com/prometheus/client_golang v1.18.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,8 @@ github.com/onsi/ginkgo/v2 v2.17.1 h1:V++EzdbhI4ZV4ev0UTIj0PzhzOcReJFyJaLjtSF55M8
476476
github.com/onsi/ginkgo/v2 v2.17.1/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs=
477477
github.com/onsi/gomega v1.32.0 h1:JRYU78fJ1LPxlckP6Txi/EYqJvjtMrDC04/MM5XRHPk=
478478
github.com/onsi/gomega v1.32.0/go.mod h1:a4x4gW6Pz2yK1MAmvluYme5lvYTn61afQ2ETw/8n4Lg=
479-
github.com/openshift/api v0.0.0-20240530053948-b01900f1982a h1:EyLN5c8dxine8V9XaBzG76p1UEY8W0aP97EOvv36eOY=
480-
github.com/openshift/api v0.0.0-20240530053948-b01900f1982a/go.mod h1:OOh6Qopf21pSzqNVCB5gomomBXb8o5sGKZxG2KNpaXM=
479+
github.com/openshift/api v0.0.0-20240613141850-76a71dac36a0 h1:Kn16YZDBGwetg+pMQ0u0/3aOxRXQJi/1lu6rIlK+1So=
480+
github.com/openshift/api v0.0.0-20240613141850-76a71dac36a0/go.mod h1:OOh6Qopf21pSzqNVCB5gomomBXb8o5sGKZxG2KNpaXM=
481481
github.com/openshift/client-go v0.0.0-20240528061634-b054aa794d87 h1:JtLhaGpSEconE+1IKmIgCOof/Len5ceG6H1pk43yv5U=
482482
github.com/openshift/client-go v0.0.0-20240528061634-b054aa794d87/go.mod h1:3IPD4U0qyovZS4EFady2kqY32m8lGcbs/Wx+yprg9z8=
483483
github.com/openshift/library-go v0.0.0-20240116081341-964bcb3f545c h1:gLylEQQryG+A6nqWYIwE1wUzn1eFUmthjADvflMWKnM=

pkg/webhooks/machine_webhook.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,17 @@ func validateAWS(m *machinev1beta1.Machine, config *admissionConfig) (bool, []st
746746
)
747747
}
748748

749+
if providerSpec.PlacementGroupName == "" && providerSpec.PlacementGroupPartition != 0 {
750+
errs = append(
751+
errs,
752+
field.Invalid(
753+
field.NewPath("providerSpec", "placementGroupPartition"),
754+
providerSpec.PlacementGroupPartition,
755+
"providerSpec.placementGroupPartition is set but providerSpec.placementGroupName is empty",
756+
),
757+
)
758+
}
759+
749760
duplicatedTags := getDuplicatedTags(providerSpec.Tags)
750761
if len(duplicatedTags) > 0 {
751762
warnings = append(warnings, fmt.Sprintf("providerSpec.tags: duplicated tag names (%s): only the first value will be used.", strings.Join(duplicatedTags, ",")))

pkg/webhooks/machine_webhook_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2133,6 +2133,30 @@ func TestValidateAWSProviderSpec(t *testing.T) {
21332133
expectedOk: false,
21342134
expectedError: "providerSpec.tenancy: Invalid value: \"invalid\": Invalid providerSpec.tenancy, the only allowed options are: default, dedicated, host",
21352135
},
2136+
{
2137+
testCase: "fail if placementGroupPartition is set, but placementGroupName is empty",
2138+
modifySpec: func(p *machinev1beta1.AWSMachineProviderConfig) {
2139+
p.PlacementGroupName = ""
2140+
p.PlacementGroupPartition = 2
2141+
},
2142+
expectedOk: false,
2143+
expectedError: "providerSpec.placementGroupPartition: Invalid value: 2: providerSpec.placementGroupPartition is set but providerSpec.placementGroupName is empty",
2144+
},
2145+
{
2146+
testCase: "allow if only placementGroupName is set",
2147+
modifySpec: func(p *machinev1beta1.AWSMachineProviderConfig) {
2148+
p.PlacementGroupName = "placement-group"
2149+
},
2150+
expectedOk: true,
2151+
},
2152+
{
2153+
testCase: "allow if both placementGroupName and placementGroupPartition are set",
2154+
modifySpec: func(p *machinev1beta1.AWSMachineProviderConfig) {
2155+
p.PlacementGroupName = "placement-group"
2156+
p.PlacementGroupPartition = 2
2157+
},
2158+
expectedOk: true,
2159+
},
21362160
{
21372161
testCase: "with no iam instance profile",
21382162
modifySpec: func(p *machinev1beta1.AWSMachineProviderConfig) {

vendor/github.com/openshift/api/config/v1/types.go

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/openshift/api/config/v1/types_infrastructure.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/openshift/api/config/v1/zz_generated.crd-manifests/0000_10_config-operator_01_infrastructures-CustomNoUpgrade.crd.yaml

Lines changed: 11 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/openshift/api/config/v1/zz_generated.crd-manifests/0000_10_config-operator_01_infrastructures-Default.crd.yaml

Lines changed: 11 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/openshift/api/config/v1/zz_generated.crd-manifests/0000_10_config-operator_01_infrastructures-DevPreviewNoUpgrade.crd.yaml

Lines changed: 11 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/openshift/api/config/v1/zz_generated.crd-manifests/0000_10_config-operator_01_infrastructures-TechPreviewNoUpgrade.crd.yaml

Lines changed: 11 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)