Skip to content

server: set Default NIC when VM has no default NIC#7859

Merged
DaanHoogland merged 2 commits into
apache:4.18from
scclouds:default-first-nic
Oct 20, 2023
Merged

server: set Default NIC when VM has no default NIC#7859
DaanHoogland merged 2 commits into
apache:4.18from
scclouds:default-first-nic

Conversation

@hsato03

@hsato03 hsato03 commented Aug 11, 2023

Copy link
Copy Markdown
Member

Description

ACS allows you to add NICs to a VM without them, although it is not possible to set them as default since the updateDefaultNicForVirtualMachine API only updates the default NIC if a default NIC already exists, otherwise an exception is thrown.

For this reason, when a NIC is added and the VM that the NIC is being created for has no default NIC, the NIC will be marked as default.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

Imported a VM without NICs, added some NICs and the first one was set as default.

@codecov

codecov Bot commented Aug 12, 2023

Copy link
Copy Markdown

Codecov Report

Merging #7859 (8f8fbe0) into 4.18 (b4032d9) will increase coverage by 0.04%.
Report is 85 commits behind head on 4.18.
The diff coverage is 0.00%.

@@             Coverage Diff              @@
##               4.18    #7859      +/-   ##
============================================
+ Coverage     13.02%   13.06%   +0.04%     
- Complexity     9029     9108      +79     
============================================
  Files          2720     2720              
  Lines        257010   257548     +538     
  Branches      40083    40156      +73     
============================================
+ Hits          33467    33658     +191     
- Misses       219342   219660     +318     
- Partials       4201     4230      +29     
Files Coverage Δ
.../src/main/java/com/cloud/vm/UserVmManagerImpl.java 7.51% <0.00%> (+0.15%) ⬆️
...tack/engine/orchestration/NetworkOrchestrator.java 6.04% <0.00%> (-0.02%) ⬇️

... and 60 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@kiranchavala

Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@kiranchavala a [SF] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 6765

@weizhouapache

Copy link
Copy Markdown
Member

@hsato03
if you want this to be in 4.18.1.0, can you rebase with 4.18 ?

@DaanHoogland DaanHoogland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

clgtm, but can you extract the new code into separate methods for readability please

@hsato03 hsato03 force-pushed the default-first-nic branch from 6b4c1e3 to 7017eab Compare August 14, 2023 18:55
@hsato03 hsato03 changed the base branch from main to 4.18 August 14, 2023 18:59
@hsato03

hsato03 commented Aug 14, 2023

Copy link
Copy Markdown
Member Author

@hsato03 if you want this to be in 4.18.1.0, can you rebase with 4.18 ?

@weizhouapache Yes, done.

@DaanHoogland DaanHoogland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

clgtm

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@DaanHoogland a [SF] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 6777

@weizhouapache

Copy link
Copy Markdown
Member

@hsato03
code lgtm

can you describe how to reproduce the issue the PR aim to fix ?

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan test rocky8 vmware-70u3 keepEnv

@blueorangutan

Copy link
Copy Markdown

@DaanHoogland a [SF] Trillian-Jenkins test job (rocky8 mgmt + vmware-70u3) has been kicked to run smoke tests

@hsato03

hsato03 commented Aug 15, 2023

Copy link
Copy Markdown
Member Author

@hsato03 code lgtm

can you describe how to reproduce the issue the PR aim to fix ?

@weizhouapache If an error occurs with the network adapter while importing a VM, it's necessary to remove the NIC via VCenter and create a new one in ACS. You can reproduce this by doing the following:

  • Using VMWare, create a VM and unmanage it;
  • On VCenter, go to the VM settings and remove all NICs from it;
  • Import the VM without NICs, create a new NIC for it and try to set the NIC as default.

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-7420)
Environment: vmware-70u3 (x2), Advanced Networking with Mgmt server r8
Total time taken: 52641 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr7859-t7420-vmware-70u3.zip
Smoke tests completed. 108 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

@DaanHoogland

Copy link
Copy Markdown
Contributor

@hsato03 , I am not allowed to import without NIC:
image
But I cannot select a network either as there is none to select.

I am trying your scenario from #7859 (comment)

@weizhouapache weizhouapache added this to the 4.18.2.0 milestone Aug 25, 2023
@hsato03

hsato03 commented Aug 29, 2023

Copy link
Copy Markdown
Member Author

@hsato03 , I am not allowed to import without NIC. But I cannot select a network either as there is none to select.

I am trying your scenario from #7859 (comment)

@DaanHoogland
Looks like you still have a NIC on your VM in VMware; this way, trying to import it without selecting the NIC makes ACS throw the exception.

The problem this PR intends to solve is that, when we have a VM without NIC and we add a NIC to it, we cannot set it as the default NIC. A way to reproduce this situation is importing a VM that does not have a NIC in VMware.
To reproduce the situation I did the following:

  1. created a VM in ACS;
  2. unmanaged the VM from ACS;
  3. via vCenter, I removed the VM's NIC. This is what the VM looks like in vCenter:
    image

Then, I imported the VM to ACS. This is the import form when a VM does not have NIC on vCenter (the Network adapter field is not presented):

image

With that, the VM is successfully imported to ACS, however, without NIC:

image

Without this patch, we can attach a NIC to the VM, however, it would not be the default NIC and we would not be able to set it as the default NIC; ACS returns the message Failed to find a nic profile for the existing default network. This is bad and probably means some sort of configuration corruption. With the patch, the first NIC of the VM is set as the default, and we can manage it afterwards.

@DaanHoogland, could you try following these steps?


Despite this PR solves the situation where we cannot set the default NIC of the VM (given the situation I mentioned), should ACS allow importing VMs without NICs, as ACS does not allow creating VMs without NIC neither remove the default NIC?. @DaanHoogland, what do you think? I can open the discussion in an issue or in the mailing list if valid.

@weizhouapache weizhouapache left a comment

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.

code lgtm

@weizhouapache weizhouapache changed the title Default NIC when VM has no default NIC server: set Default NIC when VM has no default NIC Aug 30, 2023
@hsato03

hsato03 commented Sep 26, 2023

Copy link
Copy Markdown
Member Author

Hello @DaanHoogland,

Did you manage to reproduce the situation?

Regarding importing the VM without NICs, do you think it is valid to open a discussion or we should block it?

@DaanHoogland

Copy link
Copy Markdown
Contributor

Did you manage to reproduce the situation?

I have not. I must admit I let other issues take precedence, however.

Regarding importing the VM without NICs, do you think it is valid to open a discussion or we should block it?

I think your question warrants a [DISCUSS] thread on dev@ . I am not against allowing it, but there may be some technical, procedural or plain historical objections. In that light it is always good to hide the behaviour of allowing VMs without NIC behind a global setting. A discuss thread should also resolve that question.

@DaanHoogland

Copy link
Copy Markdown
Contributor

@hsato03 I have seen no significant discussions on your thread. Let's proceed. I would say a good implementation displays a warning asking to stop or create a default NIC. What do you think?

@hsato03

hsato03 commented Oct 10, 2023

Copy link
Copy Markdown
Member Author

@DaanHoogland Good idea. I have added a warning message.

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@DaanHoogland a [SF] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@shwstppr

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@shwstppr a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@shwstppr shwstppr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code LGTM

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 7430

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan test alma8 vmware-70u3

@blueorangutan

Copy link
Copy Markdown

@DaanHoogland a [SL] Trillian-Jenkins test job (alma8 mgmt + vmware-70u3) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-8010)
Environment: vmware-70u3 (x2), Advanced Networking with Mgmt server a8
Total time taken: 55421 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr7859-t8010-vmware-70u3.zip
Smoke tests completed. 107 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_01_create_template Error 1800.76 test_templates.py

@DaanHoogland DaanHoogland merged commit a8700bf into apache:4.18 Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants