Skip to content
Draft
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
6 changes: 6 additions & 0 deletions providers/vsphere/connection/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,9 @@ func (c *VsphereConnection) Asset() *inventory.Asset {
func (c *VsphereConnection) Client() *govmomi.Client {
return c.client
}

func (c *VsphereConnection) Close() {
if c.client != nil {
c.client.Logout(context.Background())
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

πŸ”΅ suggestion β€” Logout returns an error that is silently discarded. Consider logging it so failed logouts are visible in debug output:

if err := c.client.Logout(context.Background()); err != nil {
	log.Debug().Err(err).Msg("failed to logout vsphere session")
}

Not a correctness issue (the Closer interface is Close() with no return), but helpful for diagnosing connection-cleanup failures.

}
}
4 changes: 2 additions & 2 deletions providers/vsphere/resources/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func discoverDatacenter(conn *connection.VsphereConnection, datacenterResource *
}

platformID := connection.VsphereResourceID(instanceUuid, mqlHost.Moid.Data)
clonedConfig := conn.Conf.Clone(inventory.WithoutDiscovery())
clonedConfig := conn.Conf.Clone(inventory.WithoutDiscovery(), inventory.WithParentConnectionId(conn.Conf.Id))
clonedConfig.PlatformId = platformID

labels := map[string]string{
Expand Down Expand Up @@ -167,7 +167,7 @@ func discoverDatacenter(conn *connection.VsphereConnection, datacenterResource *
vm := vmList.Data[j].(*mqlVsphereVm)

platformID := connection.VsphereResourceID(instanceUuid, vm.Moid.Data)
clonedConfig := conn.Conf.Clone(inventory.WithoutDiscovery())
clonedConfig := conn.Conf.Clone(inventory.WithoutDiscovery(), inventory.WithParentConnectionId(conn.Conf.Id))
clonedConfig.PlatformId = platformID

labels := map[string]string{
Expand Down
Loading