Skip to content

Unikernel name changes from string to Vmm_core.Name.Label.t#187

Merged
hannesm merged 9 commits intomainfrom
unikernel_names_b
Jan 25, 2026
Merged

Unikernel name changes from string to Vmm_core.Name.Label.t#187
hannesm merged 9 commits intomainfrom
unikernel_names_b

Conversation

@PizieDust
Copy link
Collaborator

closes #160

@PizieDust PizieDust requested review from hannesm December 8, 2025 07:27
@hannesm
Copy link
Contributor

hannesm commented Dec 9, 2025

I pushed a commit for albatross.ml to stick to the vmm_core.name.label.t a bit further.

@hannesm
Copy link
Contributor

hannesm commented Dec 9, 2025

I pushed some further commits, please check that they're ok. I'm still curious why this PR adds ~70 lines of code. I think the whole multipart - POST - handling should be improved so we don't end up in these deeply nested matches. Especially this create_or_upload_volume is really tough to read, as well as update_settings, and unikernel_prepare_update.

@hannesm
Copy link
Contributor

hannesm commented Dec 9, 2025

But it may be that if we just switch to vif, we get all the things for free. So maybe we should not invest too much into refactoring that right now.

Copy link
Collaborator Author

@PizieDust PizieDust left a comment

Choose a reason for hiding this comment

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

This looks okay for me. I will merge later today. Thanks for the updates @hannesm

PizieDust and others added 7 commits January 20, 2026 13:32
we avoid converting to string and back to label, and avoid errors
this checks the well-formedness earlier (in 'let unikernel = ...'), and thus
avoids code in the handler functions (they now receive a Vmm_core.Name.Label.t
directly)
| Ok instance_name -> (
match
( Configuration.name_of_str instance_name,
Configuration.name_of_str unikernel_name )
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe later we should take the time to push these Configuration.name_of_str further up.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sounds great. We can do this in a future PR for a general refactoring

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd appreciate more focussed PRs than "general refactoring".

| Ok _ -> Lwt.return (Ok ()))
| Ok res ->
Middleware.http_response reqd ~data:res `OK)
in
Copy link
Contributor

Choose a reason for hiding this comment

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

below here there's quite some refactoring that I don't fully grasp.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here I just tried to reduced the amount of nesting at call sites.

previously the add_block function only performed the Block_add operation and the calling code was responsible for chaining the next step stream_to_albatross if the addition was successful.

and in addition we had a duplicated match to get the body of the post request (getting block name, size and compressed) which was duplicated for creating a block device and the same code for uploading to a block device.

With the refactoring, we get the post request body once, and then we check if we are creating, we just call add_block (which now internally calls stream_to_albatross) and if we are uploading to a block device, we directly call stream_to_albatross

Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this refactoring in this PR, and not in a separate one?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Given that albatross_state.query now needs a Vmm_core.Name.Label.t value for the ~name parameter, we have an issue with creating or uploading data to a block device, as we now have to pass the block name, which was previously a string, i.e, we now have to conver the string block_name to a Vmm_core.Name.Label.t without which this PR wouldn't compile.

without refactoring, this will become:

match parse_json with 
| ok json_body ->
    match create_or_upload, json_body with
    | create, block_params ->
         match config.name_of_str block_name with
         | err -> error
         | ok block name
                match token_or_cokie with 
                | token -> 
                      match add_block with 
                      | ok -> stream_to_albatross
                      | error -> return unit
                | cookie -> 
                      csrf_verification >>= 
                              match add_block with 
                              | ok -> stream_to_albatross
                              | error -> return unit
    | upload, block_params_without_block_size ->
          match config.name_of_str block_name with
          | err -> error
          | ok block name
                match token_or_cokie with 
                | token -> 
                      stream_to_albatross
                 | cookie -> 
                      csrf_verification >>= 
                           stream_to_albatross
| _ -> error

which is very messy with a lot of nested matching.

So currently with a little refactoring, we have:

match parse_json with
| block_params 
    match config.name_of_str block_name with
    | err -> error
    | ok block_name ->
           match token_or_cookie with 
           | token -> 
                 match create_or_upload with 
                 | create -> add_block
                 | upload -> stream_to_albatross
            | cookie ->
                  match create_or_upload with
                  | create -> csrf_verification >>= add_block
                  | upload -> csrf_verification >>= stream_to_albatross
| _ -> error

which is not still great but reduces a bit the messiness

Copy link
Contributor

Choose a reason for hiding this comment

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

But additionally, the add_block and stream_to_albatross function definitions have been swapped, and in add_block, now stream_to_albatross is called. But I guess this is fine -- did you test this code esp. with the block_create and block_add operations?

@PizieDust PizieDust requested a review from hannesm January 22, 2026 03:50
@hannesm hannesm merged commit 2d58e36 into main Jan 25, 2026
2 checks passed
@hannesm hannesm deleted the unikernel_names_b branch January 25, 2026 19:20
@hannesm
Copy link
Contributor

hannesm commented Jan 25, 2026

Thanks, merged. We can fix potential upcoming issues later.

PizieDust added a commit that referenced this pull request Feb 3, 2026
* unikernel name changes from string to Vmm_core.Name.Label.t

* fix bug

* albatross: push the Vmm_core.Name.Label.t through a bit further

we avoid converting to string and back to label, and avoid errors

* treat the query parameter "unikernel" similar to "instance"

this checks the well-formedness earlier (in 'let unikernel = ...'), and thus
avoids code in the handler functions (they now receive a Vmm_core.Name.Label.t
directly)

* include the stream_to_albatross in add_block

* leave job as string

* fix merge conflicts

* fix all succesful typos

* uniform to unikernel_name_str

---------

Co-authored-by: Hannes Mehnert <hannes@mehnert.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Appropriate types for unikernel name

2 participants