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

fix: missing vmnic info with r/cluster import #232

Closed

Conversation

burnsjared0415
Copy link
Contributor

@burnsjared0415 burnsjared0415 commented Aug 21, 2024

In order to have a good experience with our community, we recommend that you read the contributing guidelines for making a pull request.

Summary of Pull Request

Fix missing vmnic info with r/cluster import.

Type of Pull Request

  • This is a bug fix.
  • This is an enhancement or feature.
  • This is a code style/formatting update.
  • This is a documentation update.
  • This is a refactoring update.
  • This is a chore update
  • This is something else.
    Please describe:

Related to Existing Issues

Ref: #210

Test and Documentation Coverage

For bug fixes or features:

  • Tests have been completed.
  • Documentation has been added/updated.

Breaking Changes?

  • Yes, there are breaking changes.
  • No, there are no breaking changes.

@github-actions github-actions bot added documentation Documentation needs-review Needs Review provider Provider labels Aug 21, 2024
@burnsjared0415 burnsjared0415 changed the title Bug: fix vds bug with data fix: missing vds info with r/cluster import" Aug 21, 2024
@tenthirtyam tenthirtyam added this to the On Deck milestone Aug 21, 2024
@tenthirtyam tenthirtyam changed the title fix: missing vds info with r/cluster import" fix: missing vds info with r/cluster import Aug 21, 2024
@tenthirtyam tenthirtyam force-pushed the bug/fix-vds-bug-with-data branch 3 times, most recently from 25b1826 to eb65bda Compare August 21, 2024 18:40
@vmwclabot vmwclabot added the dco-required DCO Required label Aug 21, 2024
@tenthirtyam tenthirtyam force-pushed the bug/fix-vds-bug-with-data branch from fffa6a7 to ca22241 Compare August 21, 2024 22:23
@vmwclabot vmwclabot removed the dco-required DCO Required label Aug 21, 2024
@burnsjared0415 burnsjared0415 force-pushed the bug/fix-vds-bug-with-data branch from ca22241 to cb4761b Compare August 22, 2024 13:37
@burnsjared0415 burnsjared0415 changed the title fix: missing vds info with r/cluster import fix: missing vmnic info with r/cluster import Aug 22, 2024
@tenthirtyam tenthirtyam changed the title fix: missing vmnic info with r/cluster import 🚧 fix: missing vmnic info with r/cluster import Aug 22, 2024
@tenthirtyam tenthirtyam removed the needs-review Needs Review label Aug 22, 2024
@github-actions github-actions bot added the needs-review Needs Review label Aug 22, 2024
@tenthirtyam tenthirtyam modified the milestones: On Deck, v0.11.0 Aug 22, 2024
@tenthirtyam tenthirtyam added bug Bug and removed needs-review Needs Review labels Aug 22, 2024
@tenthirtyam tenthirtyam modified the milestones: v0.11.0, On Deck Aug 22, 2024
@tenthirtyam tenthirtyam removed the documentation Documentation label Aug 22, 2024
Copy link
Collaborator

@tenthirtyam tenthirtyam left a comment

Choose a reason for hiding this comment

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

Just a small change to add it back.

Could you also share the result and state in the testing section?

@tenthirtyam tenthirtyam marked this pull request as ready for review August 23, 2024 00:06
@vmware vmware deleted a comment from vmwclabot Aug 23, 2024
@github-actions github-actions bot added the needs-review Needs Review label Aug 23, 2024
@tenthirtyam tenthirtyam force-pushed the bug/fix-vds-bug-with-data branch from 4f06167 to f13751d Compare August 27, 2024 18:24
@vmwclabot vmwclabot removed the dco-required DCO Required label Aug 27, 2024
@vmware vmware deleted a comment from vmwclabot Aug 27, 2024
Copy link
Contributor

@dimitarproynov dimitarproynov left a comment

Choose a reason for hiding this comment

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

I don't see any tests that verify that the vmnic attribute is set on cluster's hosts.

internal/cluster/host_spec_subresource.go Show resolved Hide resolved
internal/cluster/cluster_operations.go Outdated Show resolved Hide resolved
internal/cluster/cluster_operations.go Outdated Show resolved Hide resolved
@burnsjared0415 burnsjared0415 force-pushed the bug/fix-vds-bug-with-data branch 2 times, most recently from 54a5a65 to e7c2134 Compare September 4, 2024 13:57
@tenthirtyam tenthirtyam modified the milestones: v0.11.0, On Deck Sep 25, 2024
@tenthirtyam tenthirtyam force-pushed the bug/fix-vds-bug-with-data branch from e7c2134 to f5a2527 Compare October 9, 2024 20:00
Copy link
Collaborator

@tenthirtyam tenthirtyam left a comment

Choose a reason for hiding this comment

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

@burnsjared0415 could you address the following issues from the linter and check to see if this can be addressed in the test based on Dimitar's comment.

  Error: internal/cluster/cluster_operations.go:393:17: ineffectual assignment to err (ineffassign)
  	clusterResult, err := apiClient.Clusters.GetCluster(getClusterParams)
  	               ^
  Error: internal/cluster/cluster_operations.go:406:22: ineffectual assignment to err (ineffassign)
  	flattenedHostSpecs, err := getFlattenedHostSpecsForRefs(ctx, clusterObj.Hosts, apiClient)

@burnsjared0415 burnsjared0415 force-pushed the bug/fix-vds-bug-with-data branch from f51b6ac to cc28e28 Compare October 14, 2024 12:33
@tenthirtyam tenthirtyam force-pushed the bug/fix-vds-bug-with-data branch 2 times, most recently from 4687372 to 7b50744 Compare November 13, 2024 14:36
Fix missing `vmnic` info with `r/cluster` import.

Signed-off-by: Jared Burns <jared.burns@broadcom.com>
@tenthirtyam tenthirtyam force-pushed the bug/fix-vds-bug-with-data branch from 7b50744 to 97008d8 Compare November 13, 2024 14:39
@tenthirtyam
Copy link
Collaborator

Rebased based on the changes to main recently. Needs testing again.

@tenthirtyam tenthirtyam marked this pull request as draft November 13, 2024 14:40
@tenthirtyam tenthirtyam modified the milestones: On Deck, v.0.14.0 Nov 26, 2024
Comment on lines +112 to +131
if len(host.PhysicalNics) > 0 {
var physicalNics []map[string]interface{}
for _, nic := range host.PhysicalNics {
nicMap := make(map[string]interface{})
nicMap["name"] = nic.DeviceName
nicMap["mac_address"] = nic.MacAddress
physicalNics = append(physicalNics, nicMap)
}
result["vmnic"] = physicalNics
}
if len(host.PhysicalNics) > 0 {
var physicalNics []map[string]interface{}
for _, nic := range host.PhysicalNics {
nicMap := make(map[string]interface{})
nicMap["name"] = nic.DeviceName
nicMap["mac_address"] = nic.MacAddress
physicalNics = append(physicalNics, nicMap)
}
result["vmnic"] = physicalNics
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Repeated code block.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You might also consider the following:

func FlattenHost(host vcf.Host) map[string]interface{} {
	result := make(map[string]interface{})
	result["id"] = host.Id
	result["host_name"] = host.Fqdn

	if host.IpAddresses != nil {
		ipAddresses := *host.IpAddresses
		if len(ipAddresses) > 0 {
			result["ip_address"] = ipAddresses[0].IpAddress
		}
	}

	if host.PhysicalNics != nil {
		var physicalNics []map[string]interface{}
		for _, nic := range host.PhysicalNics {
			nicMap := make(map[string]interface{})
			nicMap["name"] = nic.DeviceName
			nicMap["mac_address"] = nic.MacAddress
			physicalNics = append(physicalNics, nicMap)
		}
		result["vmnic"] = physicalNics
	}

	return result
}

Copy link
Collaborator

@tenthirtyam tenthirtyam left a comment

Choose a reason for hiding this comment

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

Found some repeated logic.

Comment on lines +112 to +131
if len(host.PhysicalNics) > 0 {
var physicalNics []map[string]interface{}
for _, nic := range host.PhysicalNics {
nicMap := make(map[string]interface{})
nicMap["name"] = nic.DeviceName
nicMap["mac_address"] = nic.MacAddress
physicalNics = append(physicalNics, nicMap)
}
result["vmnic"] = physicalNics
}
if len(host.PhysicalNics) > 0 {
var physicalNics []map[string]interface{}
for _, nic := range host.PhysicalNics {
nicMap := make(map[string]interface{})
nicMap["name"] = nic.DeviceName
nicMap["mac_address"] = nic.MacAddress
physicalNics = append(physicalNics, nicMap)
}
result["vmnic"] = physicalNics
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

You might also consider the following:

func FlattenHost(host vcf.Host) map[string]interface{} {
	result := make(map[string]interface{})
	result["id"] = host.Id
	result["host_name"] = host.Fqdn

	if host.IpAddresses != nil {
		ipAddresses := *host.IpAddresses
		if len(ipAddresses) > 0 {
			result["ip_address"] = ipAddresses[0].IpAddress
		}
	}

	if host.PhysicalNics != nil {
		var physicalNics []map[string]interface{}
		for _, nic := range host.PhysicalNics {
			nicMap := make(map[string]interface{})
			nicMap["name"] = nic.DeviceName
			nicMap["mac_address"] = nic.MacAddress
			physicalNics = append(physicalNics, nicMap)
		}
		result["vmnic"] = physicalNics
	}

	return result
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug provider Provider
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants