Skip to content

Commit 3692c24

Browse files
schmikeiDougManton
authored andcommitted
[receiver/vcenter] Fix multi cluster deployment resource attributes (open-telemetry#31113)
**Description:** First pass at better contextualizing VMs in a multicluster deployment. ## The Problem For multicluster deployments the original scraper code incorrectly interpreted assumptions on VM ownership belonging to multiple clusters. ## The Solution The VM folder in a datacenter is completely separated from a cluster. Because of this we have to determine the VM's host system or resource polo in order to appropriate set the `vcenter.cluster.name` appropriately. ## Things that have changed - ClusterComputes are now retrieved as a superset Computes - For the resource attribute `vcenter.cluster.name` to show up, the inventory type must match the string "ClusterComputeResource" - The receiver now maintains a dynamic map of vm Managed Object Reference Value to compute name ## Customer impacts - VM metrics will more appropriately set the `vcenter.cluster.name` resource attribute in multi-cluster environments. This resource attribute will not be emitted for VMs on a runtime hosts outside of a cluster. - VM metrics will now emit with `vcenter.resource_pool.name` and `vcenter.resource_pool.inventory_path` when the VM is a member of one. **Link to tracking Issue:** Resolves open-telemetry#30879 **Testing:** **Documentation:** <Describe the documentation added.>
1 parent 5678708 commit 3692c24

File tree

9 files changed

+508
-270
lines changed

9 files changed

+508
-270
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: vcenterreceiver
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Fixed the resource attribute model to more accurately support multi-cluster deployments
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [30879]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext: |
19+
For more information on impacts please refer https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/31113. The main impacts are that
20+
the `vcenter.resource_pool.name`, `vcenter.resource_pool.inventory_path`, and `vcenter.cluster.name` are reported with more accuracy on VM metrics.
21+
22+
# If your change doesn't affect end users or the exported elements of any package,
23+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
24+
# Optional: The change log or logs in which this entry should be included.
25+
# e.g. '[user]' or '[user, api]'
26+
# Include 'user' if the change is relevant to end users.
27+
# Include 'api' if there is a change to a library API.
28+
# Default: '[user]'
29+
change_logs: []

receiver/vcenterreceiver/client.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,13 @@ func (vc *vcenterClient) Datacenters(ctx context.Context) ([]*object.Datacenter,
8989
return datacenters, nil
9090
}
9191

92-
// Clusters returns the clusterComputeResources of the vSphere SDK
93-
func (vc *vcenterClient) Clusters(ctx context.Context, datacenter *object.Datacenter) ([]*object.ClusterComputeResource, error) {
92+
func (vc *vcenterClient) Computes(ctx context.Context, datacenter *object.Datacenter) ([]*object.ComputeResource, error) {
9493
vc.finder = vc.finder.SetDatacenter(datacenter)
95-
clusters, err := vc.finder.ClusterComputeResourceList(ctx, "*")
94+
computes, err := vc.finder.ComputeResourceList(ctx, "*")
9695
if err != nil {
97-
return []*object.ClusterComputeResource{}, fmt.Errorf("unable to get cluster lists: %w", err)
96+
return []*object.ComputeResource{}, fmt.Errorf("unable to get compute lists: %w", err)
9897
}
99-
return clusters, nil
98+
return computes, nil
10099
}
101100

102101
// ResourcePools returns the resourcePools in the vSphere SDK

receiver/vcenterreceiver/client_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"go.opentelemetry.io/collector/config/configtls"
1919
)
2020

21-
func TestGetClusters(t *testing.T) {
21+
func TestGetComputes(t *testing.T) {
2222
simulator.Test(func(ctx context.Context, c *vim25.Client) {
2323
finder := find.NewFinder(c)
2424
client := vcenterClient{
@@ -27,9 +27,9 @@ func TestGetClusters(t *testing.T) {
2727
}
2828
dc, err := finder.DefaultDatacenter(ctx)
2929
require.NoError(t, err)
30-
clusters, err := client.Clusters(ctx, dc)
30+
computes, err := client.Computes(ctx, dc)
3131
require.NoError(t, err)
32-
require.NotEmpty(t, clusters, 0)
32+
require.NotEmpty(t, computes, 0)
3333
})
3434
}
3535

receiver/vcenterreceiver/internal/mockserver/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ And then running the receiver against the proxy.
3535
```yaml
3636
receivers:
3737
vcenter:
38-
endpoint: https://localhost:56626
38+
endpoint: http://localhost:55626
3939
username: "otelu"
4040
password: "otelp"
4141
tls:

receiver/vcenterreceiver/internal/mockserver/client_mock.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,12 @@ func routeRetreiveProperties(t *testing.T, body map[string]any) ([]byte, error)
206206
}
207207
}
208208

209+
if ps, ok := propSet["pathSet"].(string); ok {
210+
if ps == "owner" {
211+
return loadResponse("resource-pool-single.xml")
212+
}
213+
}
214+
209215
if ss, ok := objectSet["selectSet"].(map[string]any); ok && ss["path"] == "resourcePool" {
210216
return loadResponse("resource-pool-group.xml")
211217
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
3+
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
4+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
6+
<soapenv:Body>
7+
<RetrievePropertiesResponse xmlns="urn:vim25">
8+
<returnval>
9+
<obj type="ResourcePool">resgroup-9</obj>
10+
<propSet>
11+
<name>owner</name>
12+
<val type="ClusterComputeResource" xsi:type="ManagedObjectReference">domain-c8</val>
13+
</propSet>
14+
</returnval>
15+
</RetrievePropertiesResponse>
16+
</soapenv:Body>
17+
</soapenv:Envelope>

receiver/vcenterreceiver/internal/mockserver/responses/resource-pool-summary.xml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2+
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
3+
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
4+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
36
<soapenv:Body>
47
<RetrievePropertiesResponse xmlns="urn:vim25">
58
<returnval>
@@ -93,6 +96,15 @@
9396
<compressedMemory>0</compressedMemory>
9497
</val>
9598
</propSet>
99+
<propSet>
100+
<name>vm</name>
101+
<val xsi:type="ArrayOfManagedObjectReference">
102+
<ManagedObjectReference type="VirtualMachine"
103+
xsi:type="ManagedObjectReference">vm-1040</ManagedObjectReference>
104+
<ManagedObjectReference type="VirtualMachine"
105+
xsi:type="ManagedObjectReference">vm-6005</ManagedObjectReference>
106+
</val>
107+
</propSet>
96108
</returnval>
97109
</RetrievePropertiesResponse>
98110
</soapenv:Body>

0 commit comments

Comments
 (0)