Skip to content

move projects images to projects tag #872

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

Merged
merged 5 commits into from
Apr 6, 2022
Merged

move projects images to projects tag #872

merged 5 commits into from
Apr 6, 2022

Conversation

jessfraz
Copy link
Contributor

@jessfraz jessfraz commented Apr 4, 2022

Sorry about this after generating some stuff I think its better like this :)

@jessfraz jessfraz requested a review from smklein April 4, 2022 20:54
@smklein
Copy link
Collaborator

smklein commented Apr 4, 2022

Hey, so this is what I was asking about here:

#749 (comment)

I think I still have this question - what makes the cut on where tags go?

@smklein
Copy link
Collaborator

smklein commented Apr 4, 2022

ohhh is it like, related to "roles"? like, "people in the project can manage images", rather than specifying "this endpoint talks about images"?

@smklein
Copy link
Collaborator

smklein commented Apr 4, 2022

ohhh is it like, related to "roles"? like, "people in the project can manage images", rather than specifying "this endpoint talks about images"?

Actually, this doesn't make much sense to me, because disks and instances both are used as tags for their respective endpoints

@jessfraz
Copy link
Contributor Author

jessfraz commented Apr 4, 2022

Honestly I don't have a perscriptive formula yet i figure we will once we try a few things and what works and what doesn't .

But I can tell you how I am using them.

So tags are how the clients are generated so:

Go (https://pkg.go.dev/github.com/oxidecomputer/oxide.go) becomes

client.VPCs.get() // get a vpc where VPC is the main tag 
// OR
client.Instances.listDisks() // where instances in the main tag but we are listing the disks on an instance

Rust (https://docs.rs/crate/oxide-api/0.1.0-rc.31) is similar

client.vpcs().get()
// OR
client.instances().list_disks()

then for the CLI I am using it for generating only the CRUD commands (list, create, edit, delete, etc)

so I pass a macro the tag: https://github.com/oxidecomputer/cli/blob/main/src/cmd_disk.rs#L17

Now anything outside the root CRUD is manual.

in that instances disks to list the disks is a manually written command. Generating these just made it seem like it would be way harder to maintain in the future because the generation code is already really freaking complex

okay so...

lastly the tags determine how the docs are generated see the side bar and sections here:

https://docs.oxide.computer/api

So you can keep that all in mind and that's what I'm trying to do and playing with what is nice and what sucks given that's how all the generation works. Hope that's helps

@jessfraz
Copy link
Contributor Author

jessfraz commented Apr 4, 2022

honestly i was debating between this under projects or some sort of new tag for global images.

@jessfraz
Copy link
Contributor Author

jessfraz commented Apr 4, 2022

since for example instances arent under projects but also instances dont also have a global counterpart ya know

@jessfraz
Copy link
Contributor Author

jessfraz commented Apr 4, 2022

now im almost leaning towards the new tag for global images would make generating the cli a lot nicer too

@jessfraz
Copy link
Contributor Author

jessfraz commented Apr 4, 2022

the other thing we could do (cc @ahl) if we have over used tags we could do a string extension to determine various things, obviously none of the generation is set in stone and could easily be changed to read from a different string

@smklein
Copy link
Collaborator

smklein commented Apr 4, 2022

If I'm understanding correctly, it seems like the thing we want to be able to differentiate is the "global" vs "non-global" aspect?

This PR, as implemented, does the following:

  1. Global images are tagged with images
  2. Project-scoped images are tagged with projects
  3. Meanwhile, other resources like disks - which are also project-scoped - are tagged with disks

This format doesn't seem that consistent to me - examples (2) and (3) are both project-scoped, but are tagged differently (one refers to the resource, the other refers to the scope). Examples (1) and (3) are both tagged with the name of the resource, but one is global, and the other is project-scoped.
I dunno if this is what you meant by "new tag for global images", but perhaps it makes sense to distinguish between "the resource being acted upon" and "the scope in which the resource is contained"? Something like:

tag = "image"
scope = "global"

vs

tag = "image"
scope = "project"

That being said, all of this seems contingent on where that crud_gen macro is used in the CLI repo, so I suppose if it works for you, it works?

@jessfraz
Copy link
Contributor Author

jessfraz commented Apr 4, 2022

yeah for that we could do then an extension on the openapi spec to denote it basically but yes that would work to let me know one is one and one is the other which would be very helpful

none of the other resources have this global counterpart so its really only something that matters now, to your questions of desks versus this

@jessfraz
Copy link
Contributor Author

jessfraz commented Apr 4, 2022

I guess roles will also be both so its worth splitting it out versus me just hard coding some custom logic into everything for images

@jessfraz
Copy link
Contributor Author

jessfraz commented Apr 4, 2022

lets see what adam thinks too, idk if dropshot should define this extension scope of if dropshot can arbitrarily create extensions on the fly that might be a better route

@jessfraz jessfraz requested review from smklein and ahl April 4, 2022 23:23
@jessfraz
Copy link
Contributor Author

jessfraz commented Apr 4, 2022

The other thing is we programatically know the scope based on the path right, like anything under /projects etc, so I could code this in like 5 other repos to calculate the scope or we could calculate it at the generation of the spec, regardless it would never have to be manually written if that makes sense which avoids errors

@david-crespo
Copy link
Contributor

I think I'm with Sean — it doesn't feel consistent to me to have the project-scoped images be under the projects tag. Looking through the external endpoints, in almost every case, the tag refers to the resource being fetched/listed, whatever. But I can see how putting both global and project images under the same tag causes a conflict in the method names. I think a global_images tag is a good workaround that avoids complicating the client generators.

@jessfraz
Copy link
Contributor Author

jessfraz commented Apr 6, 2022

coool will update, maybe ill call it like "images:global" so I can parse it

jessfraz added 4 commits April 6, 2022 09:07
Signed-off-by: Jess Frazelle <github@jessfraz.com>
Signed-off-by: Jess Frazelle <github@jessfraz.com>
Signed-off-by: Jess Frazelle <github@jessfraz.com>
Signed-off-by: Jess Frazelle <github@jessfraz.com>
@jessfraz
Copy link
Contributor Author

jessfraz commented Apr 6, 2022

okay well, if I change it to global_images or global-images or images:global the tests panic:

---- integration_tests::commands::test_nexus_openapi stdout ----
writing temp config: /var/folders/bw/b2wm022n2c35rl5l0f87wmlr0000gn/T/test_commands_config.80676.1
thread 'integration_tests::commands::test_nexus_openapi' panicked at 'expected normal process exit with code 0, got Signaled(6)', nexus/tests/integration_tests/commands.rs:107:38
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

which makes me think there's some special character check somewhere? cc @ahl

@jessfraz
Copy link
Contributor Author

jessfraz commented Apr 6, 2022

that line if you are wondering is just it running --openapi

@jessfraz
Copy link
Contributor Author

jessfraz commented Apr 6, 2022

yeah theres a special character check: thread 'main' panicked at 'failed to register entrypoints: Invalid tag: global-images', nexus/src/external_api/http_entrypoints.rs:192:9

@jessfraz
Copy link
Contributor Author

jessfraz commented Apr 6, 2022

OH this is me being a dumbass abort

Signed-off-by: Jess Frazelle <github@jessfraz.com>
@jessfraz
Copy link
Contributor Author

jessfraz commented Apr 6, 2022

okay good to go now

Copy link
Collaborator

@smklein smklein 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 - I like this version!

@jessfraz jessfraz merged commit 325773d into main Apr 6, 2022
@jessfraz jessfraz deleted the change-some-tags branch April 6, 2022 20:00
gjcolombo added a commit that referenced this pull request Mar 5, 2025
Changes since the last update:

- lib: use correct MAXCPU value in CPUID specializer (#876)
- phd: wait for source to resume before asking to migrate again (#874)
- phd: add smoke test for VCR replacement (#872)
- lib: implement reference TSC enlightenment (#856)
- Update package deps for GHSAs
- Wire up viona for illumos#17032
- mock-server: add single-step API (#869)
- propolis-server should not crash when failing to start a VM (#866)
- propolis-cli: check for duplicate spec keys when parsing toml (#865)
- various new 1.85 clippy lints (#864)
- mock: attempt realistic state transitions (#860)
- lib: tidy up overlay page migration & reduce memory usage (#861)
- server: add state machine docs (#862)
- DTrace script to inspect VM exit reasons (#859)
- lib: add better management of Hyper-V overlay pages (#851)
- lib: emulate Hyper-V enlightenment stack (#849)
@gjcolombo gjcolombo mentioned this pull request Mar 5, 2025
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.

3 participants