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

Add optional property "cloud_info" for VMIs #637

Merged
merged 3 commits into from
Nov 7, 2024

Conversation

JAVGan
Copy link
Contributor

@JAVGan JAVGan commented Nov 6, 2024

This commit introduces a new optional property for all VMIPushItems named VMICloudInformation which stores the cloud's provider name and account alias into it.

The goal of this change is to be able to parse the patched clouds.json with this new property, which was introduced in
release-engineering/pubtools-marketplacesvm#71 , allowing the DeleteTask to have a more reliable way to retrieve the provider/account information.

Refers to SPSTRAT-363

@JAVGan
Copy link
Contributor Author

JAVGan commented Nov 6, 2024

@jajreidy @rohanpm PTAL

@jajreidy
Copy link
Contributor

jajreidy commented Nov 6, 2024

LGTM

default=None,
validator=optional((instance_of(VMICloudInformation))),
)
"""Cloud provider information of its short name and account alias."""
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer that this is worded in such a way that it doesn't imply these are the only attributes.

For example, instead of "of its" it could be something like:

Suggested change
"""Cloud provider information of its short name and account alias."""
"""Cloud provider information, such as the provider's short name and account alias."""

"such as" communicating that these are only examples and you should check the class docs if you want to know everything.

The reason for this is that, if someone later needs to add more attributes to VMICloudInformation, I think it's likely they will not come back and update this doc string. The doc string therefore would be best worded with future additions in mind to avoid becoming inaccurate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, thanks a lot!

@@ -24,6 +24,17 @@ def __repr__(self):
return f"{cls_name}.{self.name}"


@attr.s()
class VMICloudInformation(object):
Copy link
Member

Choose a reason for hiding this comment

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

Could you please use "Info" rather than "Information"?

There are already classes in this library using "Info" (KojiBuildInfo, ContainerImagePullInfo) so we should maintain consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, thanks for reminding me about that!

@@ -24,6 +24,17 @@ def __repr__(self):
return f"{cls_name}.{self.name}"


@attr.s()
class VMICloudInformation(object):
"""Inform the cloud provider's name and account alias of a given push item."""
Copy link
Member

Choose a reason for hiding this comment

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

Overall, I find the intended usage of it a bit unclear and would appreciate a more detailed doc string.

Specifically I find it unclear if this is meant to be used as:

  1. the cloud provider which should be used to publish the item, or:
  2. the cloud provider on which the item currently exists, or:
  3. both

The PR cover message talks about using this for "delete", which sounds like case (2) as you're going to use this to look up the image in a given provider. If it's indeed case (2) then this all looks good except that I request the doc string is fleshed out a bit with a sentence or two to explain the expected usage.

This is the kind of doc string I think we should have (and I'm assuming case 2 when writing this):

Information on the cloud provider associated with a given push item.

Cloud provider information is only available for VMIs which have previously
been published to a cloud. It may be used to locate an existing VMI for
manipulation, such as metadata updates or deletion.

This library doesn't define any specific cloud provider names or aliases.
Generally, a user of this library is expected to use the information here
to look up cloud access details from a configuration file or other source.

If the case is (1) or (3), as well as expanding the doc string, could we please rename the attribute to dest_cloud_info ?

The reason behind this is that I am concerned about the push item attributes becoming a confusing mix between attributes having the current state of some content, vs desired state. For example: there would be an attribute named build_info saying where the push item came from, and then a similarly named cloud_info saying where the push item should be pushed. There's no way a developer could be reasonably expected to remember which of these attributes represent the current vs desired state.

The last time this came up was ContainerImagePushItem.dest_signing_key, representing a signing key that an image should be signed with (not "is already signed with"), so the established convention is dest_*.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Our goal with this new optional property is really just for the case 2.

I've adjusted the docstring accordingly, thanks a lot for the suggestion, I really appreciate it. I've set it with the same value as it correctly represent the goal of this class.

This commit introduces a new optional property for all VMIPushItems
named `VMICloudInformation` which stores the cloud's provider name and
account alias into it.

The goal of this change is to be able to parse the patched `clouds.json`
with this new property, which was introduced in
release-engineering/pubtools-marketplacesvm#71, allowing
the DeleteTask to have a more reliable way to retrieve the provider/account
 information.

Refers to SPSTRAT-363
docs/model/vmi.rst Outdated Show resolved Hide resolved
src/pushsource/_impl/model/vms.py Outdated Show resolved Hide resolved
@rohanpm rohanpm enabled auto-merge (squash) November 7, 2024 22:10
@rohanpm rohanpm merged commit 0f0d0c0 into release-engineering:master Nov 7, 2024
6 checks 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.

3 participants