Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[receiver/vcenter] Fix multi cluster deployment resource attributes #31113

Merged
merged 25 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4bad57a
store cluster state on vcenter scraper in order to reverse lookup VM …
schmikei Feb 7, 2024
27da83f
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei Feb 7, 2024
c6531d4
govet fix
schmikei Feb 7, 2024
49f06f0
fix resource pool empty names
schmikei Feb 7, 2024
173dc89
update integration test file
schmikei Feb 8, 2024
5fa33c5
remove test print statement
schmikei Feb 8, 2024
05d8c37
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei Feb 8, 2024
adad6d0
newlines at ends of files
schmikei Feb 8, 2024
fe12911
Merge branch 'main' into vcenter-cluster-duplication
schmikei Feb 8, 2024
2faf14b
Merge branch 'main' into vcenter-cluster-duplication
schmikei Feb 8, 2024
874e14c
don't emit cluster name for vms that aren't in a clustered env
schmikei Feb 12, 2024
390fcdd
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei Feb 12, 2024
7e194e0
Merge branch 'vcenter-cluster-duplication' of github.com:schmikei/ope…
schmikei Feb 12, 2024
2c3cb46
update changelog
schmikei Feb 12, 2024
666d113
Merge branch 'main' into vcenter-cluster-duplication
schmikei Feb 13, 2024
ddeac22
no functionality changes; variable rename from cluster=>compute and c…
schmikei Feb 14, 2024
6bf3c32
Merge branch 'vcenter-cluster-duplication' of github.com:schmikei/ope…
schmikei Feb 14, 2024
c9597d3
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei Feb 22, 2024
67090f6
emit the vcenter.resource_pool.inventory_path
schmikei Feb 22, 2024
c0bd4aa
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
schmikei Feb 27, 2024
fb344b2
store vm => resource pool in a map as well, used for inventoryPath lo…
schmikei Feb 27, 2024
378f271
Merge branch 'main' into vcenter-cluster-duplication
schmikei Mar 7, 2024
f755de8
update changelog to link to PR
schmikei Mar 8, 2024
10b8f6a
Merge branch 'vcenter-cluster-duplication' of github.com:schmikei/ope…
schmikei Mar 8, 2024
e7e5acc
Merge branch 'main' into vcenter-cluster-duplication
schmikei Mar 8, 2024
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
29 changes: 29 additions & 0 deletions .chloggen/vcenter-cluster-duplication.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: vcenterreceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Fixed the resource attribute model to more accurately support multi-cluster deployments

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [30879]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext: |
For more information on impacts please refer https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/31113. The main impacts are that
the `vcenter.resource_pool.name`, `vcenter.resource_pool.inventory_path`, and `vcenter.cluster.name` are reported with more accuracy on VM metrics.

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
9 changes: 4 additions & 5 deletions receiver/vcenterreceiver/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,13 @@ func (vc *vcenterClient) Datacenters(ctx context.Context) ([]*object.Datacenter,
return datacenters, nil
}

// Clusters returns the clusterComputeResources of the vSphere SDK
func (vc *vcenterClient) Clusters(ctx context.Context, datacenter *object.Datacenter) ([]*object.ClusterComputeResource, error) {
func (vc *vcenterClient) Computes(ctx context.Context, datacenter *object.Datacenter) ([]*object.ComputeResource, error) {
vc.finder = vc.finder.SetDatacenter(datacenter)
clusters, err := vc.finder.ClusterComputeResourceList(ctx, "*")
computes, err := vc.finder.ComputeResourceList(ctx, "*")
if err != nil {
return []*object.ClusterComputeResource{}, fmt.Errorf("unable to get cluster lists: %w", err)
return []*object.ComputeResource{}, fmt.Errorf("unable to get compute lists: %w", err)
}
return clusters, nil
return computes, nil
}

// ResourcePools returns the resourcePools in the vSphere SDK
Expand Down
6 changes: 3 additions & 3 deletions receiver/vcenterreceiver/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"go.opentelemetry.io/collector/config/configtls"
)

func TestGetClusters(t *testing.T) {
func TestGetComputes(t *testing.T) {
simulator.Test(func(ctx context.Context, c *vim25.Client) {
finder := find.NewFinder(c)
client := vcenterClient{
Expand All @@ -27,9 +27,9 @@ func TestGetClusters(t *testing.T) {
}
dc, err := finder.DefaultDatacenter(ctx)
require.NoError(t, err)
clusters, err := client.Clusters(ctx, dc)
computes, err := client.Computes(ctx, dc)
require.NoError(t, err)
require.NotEmpty(t, clusters, 0)
require.NotEmpty(t, computes, 0)
})
}

Expand Down
2 changes: 1 addition & 1 deletion receiver/vcenterreceiver/internal/mockserver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ And then running the receiver against the proxy.
```yaml
receivers:
vcenter:
endpoint: https://localhost:56626
endpoint: http://localhost:55626
username: "otelu"
password: "otelp"
tls:
Expand Down
6 changes: 6 additions & 0 deletions receiver/vcenterreceiver/internal/mockserver/client_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ func routeRetreiveProperties(t *testing.T, body map[string]any) ([]byte, error)
}
}

if ps, ok := propSet["pathSet"].(string); ok {
if ps == "owner" {
return loadResponse("resource-pool-single.xml")
}
}

if ss, ok := objectSet["selectSet"].(map[string]any); ok && ss["path"] == "resourcePool" {
return loadResponse("resource-pool-group.xml")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<soapenv:Body>
<RetrievePropertiesResponse xmlns="urn:vim25">
<returnval>
<obj type="ResourcePool">resgroup-9</obj>
<propSet>
<name>owner</name>
<val type="ClusterComputeResource" xsi:type="ManagedObjectReference">domain-c8</val>
</propSet>
</returnval>
</RetrievePropertiesResponse>
</soapenv:Body>
</soapenv:Envelope>
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<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">
<soapenv:Body>
<RetrievePropertiesResponse xmlns="urn:vim25">
<returnval>
Expand Down Expand Up @@ -93,6 +96,15 @@
<compressedMemory>0</compressedMemory>
</val>
</propSet>
<propSet>
<name>vm</name>
<val xsi:type="ArrayOfManagedObjectReference">
<ManagedObjectReference type="VirtualMachine"
xsi:type="ManagedObjectReference">vm-1040</ManagedObjectReference>
<ManagedObjectReference type="VirtualMachine"
xsi:type="ManagedObjectReference">vm-6005</ManagedObjectReference>
</val>
</propSet>
</returnval>
</RetrievePropertiesResponse>
</soapenv:Body>
Expand Down
Loading
Loading