Skip to content

Conversation

@maigl
Copy link
Contributor

@maigl maigl commented Jul 25, 2023

Openstack offers multiple visibility levels. These level define if and how images can be shared between openstack projects.

This PR allows to also use images to create instances if visibility is community.
Unfortunately, there seems to be no VisibilityAll option, hence we search for public images first and then we search for community images in a 2nd step.

Consuming shared images may introduce security issues. For that reason we add a AllowedImageOwners config flag. If it is unset we allow all images, but one can also define a list allowed owners to protect against images of untrusted origin.

@maigl maigl force-pushed the community-images branch from 01905ab to 58a4ce9 Compare July 25, 2023 11:53
@gabriel-samfira
Copy link
Member

This sounds good for situations in which a pool uses image names instead of IDs. I think that if we add the extra step of sending a list of allowed owners, it's probably easier to just use image IDs instead of image names. The image ID will only ever match one image. I have nothing against adding this. I think you need to rebase. Some commits here seem to be shared with the PR I just merged.

@maigl maigl force-pushed the community-images branch from f62a289 to 80eb4b4 Compare July 26, 2023 15:14
client/client.go Outdated
}); err != nil {
return nil, fmt.Errorf("failed to get image with name or id %s: %w", nameOrID, err)
}
// try again but look for community images
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think there is no good way to search for public AND `community' visibility. so we have to duplicate the code ..

but we could also simply use images.ImageVisibility("all") ?! What do you think ?

Copy link
Member

Choose a reason for hiding this comment

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

I think that's a great idea. Better still, we could make this a flag in the config/extra-specs search-all-images or something. By default limit to public images, and we switch to all if the flag is set to true. We must take care because (I think) if we mistakingly use credentials for an admin user, all can truly include all images.

Copy link
Contributor Author

@maigl maigl Jul 27, 2023

Choose a reason for hiding this comment

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

Okay .. I'll change this.

The visibility thing is really tricky .. you have public, private, shared and community .. but the visibility is only important for listing the images not necessarily for using. E.g. you can boot from any community image .. and you can also boot from a shared image which you didn't accept (yet) or which you explicitly rejected.
Hence the allowed owners check is very crucial

Copy link
Contributor Author

Choose a reason for hiding this comment

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

visibility can now be explicitly set in config and/or extra specs

@maigl
Copy link
Contributor Author

maigl commented Jul 26, 2023

it's probably easier to just use image IDs instead of image names.

.. this is exactly our use-case .. we have multiple pools with the same image, but as we have many openstacks we have the same image with multiple different ids. We really would stick to image names as ids are not human friendly and having the same image with different ids can drive you crazy. :)

@maigl maigl marked this pull request as ready for review July 26, 2023 15:20
@gabriel-samfira
Copy link
Member

it's probably easier to just use image IDs instead of image names.

.. this is exactly our use-case .. we have multiple pools with the same image, but as we have many openstacks we have the same image with multiple different ids. We really would stick to image names as ids are not human friendly and having the same image with different ids can drive you crazy. :)

Ahh! That makes perfect sense!

}

// verify owner
if spec.AllowedImageOwners != nil && len(spec.AllowedImageOwners) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

I think we can drop the nil check here. The nil value of a slice is an empty slice, even if we explicitly set it to nil. So len() should be fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

m.UseConfigDrive = *spec.UseConfigDrive
}

if spec.AllowedImageOwners != nil {
Copy link
Member

@gabriel-samfira gabriel-samfira Jul 26, 2023

Choose a reason for hiding this comment

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

It should be fine to remove the if and just assign the value.

Wait, this is also a config value. Forget what I said.

@gabriel-samfira
Copy link
Member

This looks great. Let me know when you're done and I can merge it.

@maigl
Copy link
Contributor Author

maigl commented Jul 27, 2023

This looks great. Let me know when you're done and I can merge it.

I think you could have a look again now .. I also started adding some minimal unit tests.

@gabriel-samfira
Copy link
Member

Lgtm. Merging. We can iterate.

@gabriel-samfira gabriel-samfira merged commit 82395ec into cloudbase:main Jul 27, 2023
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.

2 participants