Skip to content

Commit 751e13a

Browse files
Merge pull request openshift#7905 from openshift-splat-team/SPLAT-1387
SPLAT-1387: enable additional tags to be associated with vsphere machines
2 parents eccd737 + 7d5d26a commit 751e13a

25 files changed

+331
-5
lines changed

data/data/install.openshift.io_installconfigs.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4420,6 +4420,14 @@ spec:
44204420
minLength: 1
44214421
pattern: ^/.*?/host/.*?/Resources.*
44224422
type: string
4423+
tagIDs:
4424+
description: tagIDs is an optional set of tags to add
4425+
to an instance. Specified tagIDs must use URN-notation
4426+
instead of display names. A maximum of 10 tag IDs
4427+
may be specified.
4428+
items:
4429+
type: string
4430+
type: array
44234431
template:
44244432
description: template is the inventory path of the virtual
44254433
machine or template that will be used for cloning.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ require (
5858
github.com/microsoftgraph/msgraph-sdk-go v0.47.0
5959
github.com/nutanix-cloud-native/prism-go-client v0.2.1-0.20220804130801-c8a253627c64
6060
github.com/onsi/gomega v1.29.0
61-
github.com/openshift/api v0.0.0-20240104110125-c7a2d3b41e1f
61+
github.com/openshift/api v0.0.0-20240115183315-0793e918179d
6262
github.com/openshift/assisted-image-service v0.0.0-20230829160050-0b98ec74397b
6363
github.com/openshift/assisted-service/api v0.0.0
6464
github.com/openshift/assisted-service/client v0.0.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1919,8 +1919,8 @@ github.com/opencontainers/selinux v1.10.1/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuh
19191919
github.com/openshift/api v0.0.0-20200326160804-ecb9283fe820/go.mod h1:RKMJ5CBnljLfnej+BJ/xnOWc3kZDvJUaIAEq2oKSPtE=
19201920
github.com/openshift/api v0.0.0-20200827090112-c05698d102cf/go.mod h1:M3xexPhgM8DISzzRpuFUy+jfPjQPIcs9yqEYj17mXV8=
19211921
github.com/openshift/api v0.0.0-20200829102639-8a3a835f1acf/go.mod h1:M3xexPhgM8DISzzRpuFUy+jfPjQPIcs9yqEYj17mXV8=
1922-
github.com/openshift/api v0.0.0-20240104110125-c7a2d3b41e1f h1:3BMVfQpz1xe8MmJprp1+NL8hrpl9I04JVP9EczdCOqE=
1923-
github.com/openshift/api v0.0.0-20240104110125-c7a2d3b41e1f/go.mod h1:CxgbWAlvu2iQB0UmKTtRu1YfepRg1/vJ64n2DlIEVz4=
1922+
github.com/openshift/api v0.0.0-20240115183315-0793e918179d h1:gtwDqGPf5QmsV8jvOUoDNbtyeby9QeLdsybNQ8mGqHQ=
1923+
github.com/openshift/api v0.0.0-20240115183315-0793e918179d/go.mod h1:CxgbWAlvu2iQB0UmKTtRu1YfepRg1/vJ64n2DlIEVz4=
19241924
github.com/openshift/assisted-image-service v0.0.0-20230829160050-0b98ec74397b h1:wLVEgmzQjs3t4Z96gZzSLF/ws6ULliAks7z1lozNJrE=
19251925
github.com/openshift/assisted-image-service v0.0.0-20230829160050-0b98ec74397b/go.mod h1:KTt/pnfs9gt0McDPrb0zVTkwd0xIFNik/ZJROIBzsbc=
19261926
github.com/openshift/assisted-service/api v0.0.0-20230831114549-1922eda29cf8 h1:+fZLKbycDo4JeLwPGVSAgf2XPaJGLM341l9ZfrrlxG0=

pkg/asset/machines/vsphere/machines.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ func provider(clusterID string, vcenter *vsphere.VCenter, failureDomain vsphere.
247247
Folder: folder,
248248
ResourcePool: resourcePool,
249249
},
250+
TagIDs: failureDomain.Topology.TagIDs,
250251
NumCPUs: mpool.NumCPUs,
251252
NumCoresPerSocket: mpool.NumCoresPerSocket,
252253
MemoryMiB: mpool.MemoryMiB,

pkg/types/vsphere/platform.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ type Topology struct {
212212
// +kubebuilder:validation:Pattern=`^/.*?/vm/.*?`
213213
// +optional
214214
Template string `json:"template,omitempty"`
215+
// tagIDs is an optional set of tags to add to an instance. Specified tagIDs
216+
// must use URN-notation instead of display names. A maximum of 10 tag IDs may be specified.
217+
// +kubebuilder:example=urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9578:GLOBAL
218+
// +optional
219+
TagIDs []string `json:"tagIDs,omitempty"`
215220
}
216221

217222
// VCenter stores the vCenter connection fields

pkg/types/vsphere/validation/platform.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ func validateVCenters(p *vsphere.Platform, fldPath *field.Path) field.ErrorList
117117

118118
func validateFailureDomains(p *vsphere.Platform, fldPath *field.Path, isLegacyUpi bool) field.ErrorList {
119119
var fdNames []string
120+
tagUrnPattern := regexp.MustCompile(`^(urn):(vmomi):(InventoryServiceTag):([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}):([^:]+)$`)
120121
allErrs := field.ErrorList{}
121122
topologyFld := fldPath.Child("topology")
122123
var associatedVCenter *vsphere.VCenter
@@ -172,6 +173,16 @@ func validateFailureDomains(p *vsphere.Platform, fldPath *field.Path, isLegacyUp
172173
}
173174
}
174175

176+
if len(failureDomain.Topology.TagIDs) > 10 {
177+
allErrs = append(allErrs, field.Invalid(topologyFld.Child("tagIDs"), failureDomain.Topology.TagIDs, "a maximum of 10 tags are allowed"))
178+
}
179+
180+
for _, tagID := range failureDomain.Topology.TagIDs {
181+
if tagUrnPattern.FindStringSubmatch(tagID) == nil {
182+
allErrs = append(allErrs, field.Invalid(topologyFld.Child("tagIDs"), failureDomain.Topology.TagIDs, "tag ID must be in the format of urn:vmomi:InventoryServiceTag:<UUID>:GLOBAL"))
183+
}
184+
}
185+
175186
if len(failureDomain.Topology.Networks) == 0 {
176187
if isLegacyUpi {
177188
logrus.Warn("network field empty is now deprecated, in later releases this field will be required.")

pkg/types/vsphere/validation/platform_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,29 @@ func TestValidatePlatform(t *testing.T) {
194194
}(),
195195
expectedError: `^test-path\.diskType: Invalid value: "invalidDiskType": diskType must be one of \[eagerZeroedThick thick thin\]$`,
196196
},
197+
{
198+
name: "Additional tag IDs provided",
199+
platform: func() *vsphere.Platform {
200+
p := validPlatform()
201+
p.FailureDomains[0].Topology.TagIDs = []string{
202+
"urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9578:GLOBAL",
203+
"urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9579:GLOBAL",
204+
}
205+
return p
206+
}(),
207+
},
208+
{
209+
name: "Additional invalid tag IDs provided",
210+
platform: func() *vsphere.Platform {
211+
p := validPlatform()
212+
p.FailureDomains[0].Topology.TagIDs = []string{
213+
"urn:bad:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9578:GLOBAL",
214+
"urn:bad:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9579:GLOBAL",
215+
}
216+
return p
217+
}(),
218+
expectedError: `^test-path\.failureDomains\.topology\.tagIDs\: Invalid value\:.*?: tag ID must be in the format of urn\:vmomi\:InventoryServiceTag\:<UUID>\:GLOBAL$`,
219+
},
197220

198221
{
199222
name: "Valid Multi-zone platform",

vendor/github.com/openshift/api/config/v1/0000_10_config-operator_01_authentication.crd-CustomNoUpgrade.yaml

Lines changed: 5 additions & 0 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/0000_10_config-operator_01_authentication.crd-TechPreviewNoUpgrade.yaml

Lines changed: 5 additions & 0 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/0000_10_config-operator_01_authentication.crd.yaml

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

0 commit comments

Comments
 (0)