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

[AWS] Fix: override disk when mounted on same device name #97

Merged
merged 3 commits into from
Sep 20, 2023

Conversation

obierlaire
Copy link
Collaborator

@obierlaire obierlaire commented Sep 20, 2023

Problem

When two disks are mounted on the same device name, we need to use the value of the override. Typically this happens when a root disk size is set in the AMI and the EC2 instance sets a bigger size of this root disk.

New storage mapping extension

So, in disk mapping we introduce two optional properties for storage items: key and override_priority :

        size: <...>
        type: <...>
        key:
          - paths: ".device_name | cbf::extract_disk_key"
        override_priority: 
          - default : 0

If we have many disks set on the same device name, they will be ordered by override_priority and pick the lowest. Typically the disk set in the EC2 instance definition on /dev/sda1 will override the disk set in the AMI on /dev/sda1

Those new properties are optional, if not see the key will be "" (empty string) and no override mechanism will be applied to storage with no key set (case of GCP or ephemeral storage)

Case AWS device naming

On AWS, device name can be either in form of or /dev/nvme1n1, and they are both the same (cf aws doc)! In that case, an other custom jq method is introduced:

  def extract_disk_key:
    if test("^/dev/sd[a-z]+") or test("^/dev/xvd[a-z]+") then
		    capture("^/dev/(?:sd|xvd)(?<letter>[a-z]+)").letter
    elif test("^/dev/nvme[0-2]?[0-9]n") then
		    capture("^/dev/nvme(?<number>[0-2]?[0-9])n").number | tonumber | (96 + .) | [.] | implode
    else
		    "Unknown format"
    end;

This function will pick the significative letter of the device name (example both /dev/sda1 or /dev/xvda will be translated to a ) or the corresponding letter for nvme (example: /dev/nvme3n1, the significative number is 3 and the corresponding letter will be c)

@obierlaire obierlaire merged commit 2621e25 into carboniferio:main Sep 20, 2023
1 check passed
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.

1 participant