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

Add support for Gen2 VM resource disks #1654

Merged
merged 14 commits into from Oct 21, 2019

Conversation

trstringer
Copy link
Contributor

@trstringer trstringer commented Oct 3, 2019

Description

The current implementation for resource disks expects (requires) that the device ID has a prefix of 00000000-0001. For Gen2 VMs, this is not the case. They have a device ID of f8b3781a-1e82-4818-a1c3-63d806ec15bb. Because of this, prior to this PR waagent does not find the resource disk and therefore doesn't mount it.

Here is the output of lsblk:

    NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sda      8:0    0   30G  0 disk
    ├─sda1   8:1    0    2M  0 part
    ├─sda2   8:2    0  512M  0 part /boot/efi
    ├─sda3   8:3    0    1G  0 part /boot
    └─sda4   8:4    0 28.5G  0 part /
    sdb      8:16   0   64G  0 disk
    └─sdb1   8:17   0   64G  0 part
    sr0     11:0    1  628K  0 rom

As you can see, there is no mountpoint for sdb1.

This PR fixes that by looking first for a Gen1 VM resource disk device, and then trying a Gen2 VM resource disk device.


PR information

  • The title of the PR is clear and informative.
  • There are a small number of commits, each of which has an informative message. This means that previously merged commits do not appear in the history of the PR. For information on cleaning up the commits in your pull request, see this page.
  • Except for special cases involving multiple contributors, the PR is started from a fork of the main repository, not a branch.
  • If applicable, the PR references the bug/issue that it fixes in the description.
  • New Unit tests were added for the changes made and Travis.CI is passing.

Quality of Code and Contribution Guidelines


This change is Reviewable

azurelinuxagent/common/osutil/default.py Outdated Show resolved Hide resolved
azurelinuxagent/common/osutil/default.py Outdated Show resolved Hide resolved
@trstringer
Copy link
Contributor Author

@jasonzio can I get a review as well? Thanks!

@trstringer trstringer requested a review from vrdmr October 3, 2019 21:52
@codecov
Copy link

codecov bot commented Oct 3, 2019

Codecov Report

Merging #1654 into develop will increase coverage by 0.18%.
The diff coverage is 73.68%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1654      +/-   ##
===========================================
+ Coverage    66.86%   67.05%   +0.18%     
===========================================
  Files           78       78              
  Lines        11242    11272      +30     
  Branches      1572     1576       +4     
===========================================
+ Hits          7517     7558      +41     
+ Misses        3402     3383      -19     
- Partials       323      331       +8
Impacted Files Coverage Δ
azurelinuxagent/common/osutil/debian.py 79.54% <100%> (ø) ⬆️
azurelinuxagent/common/osutil/factory.py 97.29% <100%> (ø) ⬆️
azurelinuxagent/common/osutil/default.py 60.02% <65.51%> (+1.75%) ⬆️
azurelinuxagent/ga/exthandlers.py 84.05% <0%> (-0.02%) ⬇️
azurelinuxagent/common/protocol/imds.py 96.29% <0%> (+0.68%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1eddbf1...5808390. Read the comment docs.

Copy link
Member

@jasonzio jasonzio left a comment

Choose a reason for hiding this comment

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

Functionally adequate, but some refactoring, as described, would improve long-term maintainability.

azurelinuxagent/common/osutil/default.py Outdated Show resolved Hide resolved
azurelinuxagent/common/osutil/factory.py Outdated Show resolved Hide resolved
@vrdmr
Copy link
Member

vrdmr commented Oct 4, 2019

@trstringer - FYI - The Py2 builds are failing. Could you please take a look?

@trstringer
Copy link
Contributor Author

@vrdmr Yep I'll check that out and get it fixed up.

Copy link
Member

@jasonzio jasonzio left a comment

Choose a reason for hiding this comment

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

More nits.

@trstringer trstringer changed the title Add support for Gen2 VM resource disks (WIP) Add support for Gen2 VM resource disks Oct 10, 2019
@trstringer trstringer changed the title (WIP) Add support for Gen2 VM resource disks Add support for Gen2 VM resource disks Oct 10, 2019
Copy link
Member

@jasonzio jasonzio 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 now.

@trstringer
Copy link
Contributor Author

@anhvoms could I get a final review on this?

yield vmbus, guid

@staticmethod
def search_for_resource_disk(gen1_device_prefix, gen2_device_id):
Copy link
Collaborator

Choose a reason for hiding this comment

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

def search_for_resource_disk(gen1_device_prefix, gen2_device_id): [](start = 4, length = 65)

Is there an easy way to detect if this is a Gen2VM, if so would it make more sense to refactor this into a flow where we detect whether this is a Gen2 or Gen1, if it's Gen2 there is a different search_for_resource_disk function (sort of like function pointers, one for Gen1, one for Gen2).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question, I'll see if I can find that answer.

Choose a reason for hiding this comment

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

Not sure you still need it, just for your reference.
if [ -d /sys/firmware/efi/ ]; then
os_GENERATION=2
else
os_GENERATION=1
fi

Copy link
Collaborator

@anhvoms anhvoms left a comment

Choose a reason for hiding this comment

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

:shipit:

@trstringer
Copy link
Contributor Author

@narrieta let me know if you anything else from my end to get this PR merged in. Thanks!

Copy link
Member

@narrieta narrieta left a comment

Choose a reason for hiding this comment

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

LGTM; running automation, will merge after that.

@narrieta
Copy link
Member

Automation OK

Copy link
Member

@vrdmr vrdmr left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r3, 3 of 3 files at r5, 1 of 1 files at r9.
Reviewable status: all files reviewed, 9 unresolved discussions (waiting on @anhvoms, @jasonzio, @larohra, @pgombar, and @trstringer)

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.

None yet

6 participants