Skip to content

Fix VM getters to work with shutdown VMs#257

Open
aravindhp wants to merge 1 commit into
oVirt:mainfrom
aravindhp:fix-vm-getters
Open

Fix VM getters to work with shutdown VMs#257
aravindhp wants to merge 1 commit into
oVirt:mainfrom
aravindhp:fix-vm-getters

Conversation

@aravindhp
Copy link
Copy Markdown

@aravindhp aravindhp commented Oct 23, 2024

Please describe the change you are making

convertSDKNicConfiguration() was assuming that VMs will have an active NIC configuration. This is not the case for shutdown VMs, so we need to account for that.

Fixes #256

Are you the owner of the code you are sending in, or do you have permission of the owner?

I am not the owner nor do I have permission of the owner

The code will be published under the BSD 3 clause license. Have you read and understood this license?

Yes

Comment thread vm.go
Comment thread vm.go Outdated
Copy link
Copy Markdown
Author

@aravindhp aravindhp left a comment

Choose a reason for hiding this comment

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

Thank you for the review, @dupondje

Comment thread vm.go
Comment thread vm.go Outdated
Copy link
Copy Markdown
Member

@dupondje dupondje left a comment

Choose a reason for hiding this comment

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

Looks good already. Some minor changes and we're done :)

Comment thread vm.go Outdated
gateway, _ := ipv6.Gateway()
netmask, _ := ipv6.Netmask()
if nicConfiguration == nil {
nicConfiguration = NewNicConfiguration(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would add this on top of the function.
And then for IPv4 do nicConfiguration.WithIP(...)

Comment thread vm.go Outdated
},
)
name, _ := sdkObject.Name()
var nicConfiguration BuildableNicConfiguration
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Initialize a new one here

Comment thread vm.go Outdated
address, _ := ipv4.Address()
gateway, _ := ipv4.Gateway()
netmask, _ := ipv4.Netmask()
nicConfiguration = NewNicConfiguration(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nicConfigration.WithIP() here

Copy link
Copy Markdown
Author

@aravindhp aravindhp left a comment

Choose a reason for hiding this comment

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

@dupondje I pushed another round of changes. Please review again and thank you for your patience.

Comment thread vm.go
Comment on lines +571 to +572
if !hasIPv4 && !hasIPv6 {
return nil
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I am not sure if I should be returning nil here or just remove this if block which will result in nicConfiguration being returned.

convertSDKNicConfiguration() was assuming that VMs will have an active
NIC configuration. This is not the case for shutdown VMs, so we need to
account for that.

Signed-off-by: Aravindh Puthiyaparambil <aravindh.foss@pm.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VM Getters panic on shutdown VMs

2 participants