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

Implement disk creation during instance creation #812

Closed
jmpesp opened this issue Mar 25, 2022 · 10 comments · Fixed by #1873
Closed

Implement disk creation during instance creation #812

jmpesp opened this issue Mar 25, 2022 · 10 comments · Fixed by #1873

Comments

@jmpesp
Copy link
Contributor

jmpesp commented Mar 25, 2022

#771 adds support for attaching an already created disk during the instance creation saga but leaves out support for creating a disk during instance creation. This issue tracks that work.

@david-crespo
Copy link
Contributor

Would like to prioritize this so we can stop doing the workaround in console of making a separate request to create the disk before calling instance create.

@smklein
Copy link
Collaborator

smklein commented Jun 24, 2022

The reason we struggle to do this cleanly in Omicron right now is a lack of "sub-sagas". Basically:

Potential solutions:

  1. Doing so right now would require basically copy-pasting the entire disk-creation saga into the instance-creation saga, to flatten it into one. We could refactor functions a bit, but we will need to enumerate all the disk creation saga steps within the instance creation saga.
  2. Adding sub-sagas to steno - some way of saying "please run this other saga as a step within our own saga graph" - would be a solution that requires less boilerplate, and which leaves the instance creation saga mostly isolated from the details of "how do we actually create a disk".

@andrewjstone - you mentioned you were eyeing steno recently. Any interest in checking-in on the status of "sub-sagas"?

@davepacheco
Copy link
Collaborator

I don't want to discourage the subsaga work because that'll be really valuable.

We could refactor functions a bit, but we will need to enumerate all the disk creation saga steps within the instance creation saga.

I wonder if we could abstract this further so that there's a common function that accepts a SagaTemplateBuilder and adds a sequence of actions to it. Then there's very little that would be duplicated. The hard part seems like the fact that the sagas probably have different SagaTypes.

@andrewjstone
Copy link
Contributor

@smklein @davepacheco I am definitely interested in this problem. Steno could use some love and I'm fascinated by it. I didn't look too deeply into sub-sagas though, and was wondering about how dynamic they are. I was also wondering if there was a way to do what Dave suggests or #2 that Sean suggests where we can do something like #include saga type into other sagas for possible use. It would be great if we could chat about this so I can get my bearings. I'll ping you both.

@david-crespo
Copy link
Contributor

Posted in chat to clarify the priority:

What we have right now works in the console in the basic sense that we can create an instance that works. We do that by calling the disk create endpoint with the specified image and the passing that info to the instance create as an existing disk. on the other hand the API advertised by the OpenAPI spec is basically false, since creating a disk as part of the create instance is part of the API but always fails.

@andrewjstone andrewjstone self-assigned this Jun 24, 2022
@andrewjstone
Copy link
Contributor

andrewjstone commented Jun 26, 2022

I don't want to discourage the subsaga work because that'll be really valuable.

We could refactor functions a bit, but we will need to enumerate all the disk creation saga steps within the instance creation saga.

I wonder if we could abstract this further so that there's a common function that accepts a SagaTemplateBuilder and adds a sequence of actions to it. Then there's very little that would be duplicated. The hard part seems like the fact that the sagas probably have different SagaTypes.

I looked into this and different SagaTypes is indeed the problem with the sharing of actions. However, all sagas in nexus share a SagaContext, and so the only difference is the SagaParamsType associated type in each of SagaInstanceCreate and SagaDiskCreate. However, it looks like the saga params for SagaInstanceCreate include the DiskCreate params. So the instance disk create should have all the data it needs to do the creation, but the functions in SagaDiskCreate template actions refer directly to the fields on params.

I think If instead of accessing the params fields directly in the actions functions for SagaDiskCreate, we called a method on the params type that returned the proper params::DiskCreate despite which SagaType the builder was called with and made the disk create action functions be generic over SagaType, and added a constraint for the method that would return params::DiskCreate on the correct SagaType we could do what Dave suggests.

If I'm reading things correctly, this doesn't seem too hard to do, but it does start coupling SagaTypes which may set a bad precedent. I believe sub-sagas are the cleaner abstraction, and after reading all this code I now understand why. However, this code base hasn't used them yet, and I wouldn't mind cleaning up steno and adding automated tests before it did, so I can understand the rough edges first. I'm still just digging into this part of omicron and steno for the first time really and am not looking to break things without understanding :)

In summary, I believe I can probably get this working very short term by playing games with SagaTypes. And then I can go and retrofit it with subsagas later. I guess it depends how urgently we want this.

@andrewjstone
Copy link
Contributor

I realized I never updated this. I'm currently working on making steno more dynamic and fully supporting subsagas.

@andrewjstone
Copy link
Contributor

The Steno PR that enables subsagas is out for review: oxidecomputer/steno#29

@davepacheco davepacheco mentioned this issue Aug 2, 2022
5 tasks
@davepacheco
Copy link
Collaborator

The Steno PR is nearly ready to land! I'm updating Omicron to use it in #1532.

@zephraph
Copy link
Contributor

To close this out we need to utilized a sub-saga in the sic_create_disks_for_instances function.

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 a pull request may close this issue.

6 participants