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

Support operation clear on CloudObjectStoreContainer #14082

Merged
merged 1 commit into from
Mar 7, 2017

Conversation

miha-plesko
Copy link
Contributor

@miha-plesko miha-plesko commented Feb 27, 2017

Operation clear removes all CloudObjectStoreObjects from the CloudObjectStoreContainer. Since this kind of operation is not recognized by miq yet, I had to register it in supports_feature_mixin.rb.

@miha-plesko
Copy link
Contributor Author

@miq-bot add_label enhancement,wip

@miq-bot
Copy link
Member

miq-bot commented Mar 2, 2017

This pull request is not mergeable. Please rebase and repush.

@miha-plesko miha-plesko changed the title [WIP] Support operation "empty" on CloudObjectStoreContainer Support operation empty in CloudObjectStoreContainer Mar 3, 2017
@miha-plesko
Copy link
Contributor Author

@durandom could you peek at this one as well? It's just a tiny upgrade of yesterday's PR that introduced *delete*_cloud_object_store_container only it's for *empty*_cloud_object_store_container.

@durandom
Copy link
Member

durandom commented Mar 3, 2017

@miha-plesko how does S3 implement this? Is there an empty operation?
I'm a bit torn between empty and empty_object_store_container. I think its fine for CRUD operations to have the bareword. But empty has no distinct meaning...

@miha-plesko
Copy link
Contributor Author

miha-plesko commented Mar 3, 2017

@durandom aws-sdk names this operation "clear", see this line:
https://github.com/ManageIQ/manageiq-providers-amazon/pull/153/files#diff-26043fa5dbac3b44abc38abb3f0db938R9

I believe this operation could be reused on any model that groups other models. Like "empty orchestration stack" would mean to delete all instances within or "empty cloud network" would mean to remove all cloud subnets within.

I would go with empty_container to make is short. Would you insist on empty_object_store_container?

@miha-plesko miha-plesko force-pushed the empty_aws_bucket branch 2 times, most recently from 092691e to d3f99ae Compare March 3, 2017 14:35
@miha-plesko miha-plesko changed the title Support operation empty in CloudObjectStoreContainer Support operation empty_container on CloudObjectStoreContainer Mar 3, 2017
@miha-plesko miha-plesko closed this Mar 3, 2017
@miha-plesko miha-plesko reopened this Mar 3, 2017
@durandom
Copy link
Member

durandom commented Mar 6, 2017

@blomquisg @agrare @bzwei @Ladas whats your opinion wrt naming this?
I think either empty for the short operation or empty_object_store_container to be explicit.
I tend towards the longer version

@agrare
Copy link
Member

agrare commented Mar 6, 2017

@durandom @miha-plesko I tend to like the more descriptive name as well but this is somewhat subjective, I don't get why you would have the long name for the main method and the short name for the raw method though...I would think they should keep the same name scheme.
Maybe :empty_cloud_object_store_container and :raw_empty_cloud_object_store_container?

Also for QUERYABLE_FEATURES I think :empty_container is way too generic, think it should match the method name so :empty_cloud_object_store_container?

@miha-plesko
Copy link
Contributor Author

@durandom @agrare I've renamed to

cloud_object_store_container_empty
raw_cloud_object_store_container_empty

The reason I prefer suffix over prefix is miq_product_features.yml file where all the names are suffix-like:
https://github.com/ManageIQ/manageiq/pull/14082/files#diff-bccee92afbf0d3d195b7bcf343b1b6c4R622
Would this work for you?

(Should we decide to use prefix form empty_cloud_object_store_container, what would the product feature name be?)

@Fryguy Fryguy assigned agrare and unassigned Fryguy Mar 6, 2017
@blomquisg blomquisg self-requested a review March 6, 2017 18:51
end

def raw_cloud_object_store_container_empty
raise NotImplementedError, _("must be implemented in subclass")
Copy link
Member

Choose a reason for hiding this comment

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

It looks like the AWS API call is clear. I think that's more descriptive than empty.

My first impression with cloud_object_store_container_emtpy was that it was missing a question mark and it should be predicate method.

I think cloud_object_store_container_clear sounds like it's going to clear the container.

Or, do what @agrare said, and reverse the naming by putting the verb before the object: empty_cloud_object_store_container. In either case, I lean closer to sticking with clear instead of empty. But, I could live with either if the verb comes first.

Copy link
Member

Choose a reason for hiding this comment

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

My first impression with cloud_object_store_container_emtpy was that it was missing a question mark and it should be predicate method.

I thought the same thing when I saw :container_empty
I agree clear is more obvious especially if that is what the native method is called.

Copy link
Member

@blomquisg blomquisg left a comment

Choose a reason for hiding this comment

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

@miha-plesko miha-plesko changed the title Support operation empty_container on CloudObjectStoreContainer Support operation clear on CloudObjectStoreContainer Mar 6, 2017
@miha-plesko
Copy link
Contributor Author

@blomquisg thanks for the review, I totally agree to cloud_object_store_container_clear. Fixed and repushed, please let me know if you have any other comments.

@miq-bot remove_label sql migration

Copy link
Member

@durandom durandom left a comment

Choose a reason for hiding this comment

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

generally ok

suffix vs. prefix: the supports feature mixin has more features with the verb being the prefix. But the product_features.yml has more suffixes, so...

@@ -120,6 +120,7 @@ module SupportsFeatureMixin
:update_security_group => 'Security Group Update',
:block_storage => 'Block Storage',
:object_storage => 'Object Storage',
:cloud_object_store_container_clear => 'Clear Object Store Container',
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 put that in alphabetical order?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, will try although there is no real alphabetical order to put in 😄

@@ -15,4 +15,6 @@ class CloudObjectStoreContainer < ApplicationRecord
alias_attribute :name, :key

supports_not :delete, :reason => N_("Delete operation is not supported.")
supports_not :cloud_object_store_container_clear,
:reason => N_("Clear Object Store Container operation is not supported.")
Copy link
Member

Choose a reason for hiding this comment

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

you can omit the :reason and it will default to Operation not supported

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

Copy link
Contributor Author

@miha-plesko miha-plesko left a comment

Choose a reason for hiding this comment

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

@durandom thanks for the review, I've applied your latest minor comments.

Regarding suffix vs prefix: the button on UI triggers whatever is written in miq_product_features.yml so if the function in supports_feature_mixin.rb is named differently, the UI controller needs to perform a mapping. My thinking was that we should avoid the mapping is possible.

@@ -120,6 +120,7 @@ module SupportsFeatureMixin
:update_security_group => 'Security Group Update',
:block_storage => 'Block Storage',
:object_storage => 'Object Storage',
:cloud_object_store_container_clear => 'Clear Object Store Container',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, will try although there is no real alphabetical order to put in 😄

@@ -15,4 +15,6 @@ class CloudObjectStoreContainer < ApplicationRecord
alias_attribute :name, :key

supports_not :delete, :reason => N_("Delete operation is not supported.")
supports_not :cloud_object_store_container_clear,
:reason => N_("Clear Object Store Container operation is not supported.")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@durandom
Copy link
Member

durandom commented Mar 7, 2017

Regarding suffix vs prefix: the button on UI triggers whatever is written in miq_product_features.yml so if the function in supports_feature_mixin.rb is named differently, the UI controller needs to perform a mapping. My thinking was that we should avoid the mapping is possible.

Thats a great rationale 👍

@miha-plesko
Copy link
Contributor Author

@blomquisg @agrare I like it how we're converging towards excelence here. Is there anything else to be improved, or did we converge? 🥇

@@ -15,4 +15,5 @@ class CloudObjectStoreContainer < ApplicationRecord
alias_attribute :name, :key

supports_not :delete, :reason => N_("Delete operation is not supported.")
supports_not :cloud_object_store_container_clear
Copy link
Contributor

Choose a reason for hiding this comment

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

We might need the :reason here, to get a user friendly message?

Copy link
Member

Choose a reason for hiding this comment

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

Nah, I just asked @miha-plesko to drop the reason. This is most likely not displayed in the UI at all and only adds a burden to i18n to translate messages that are not used.

Actually I'm inclined to remove all supports_not reason that are on a base class

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, interesting

@Ladas
Copy link
Contributor

Ladas commented Mar 7, 2017

@miha-plesko looks good in general.

Also, when you add a new feature, it's good to list it in some default user roles, https://github.com/Ladas/manageiq/blob/497be4eb4bf197e603eb81e3cd7c87d4ce1c97ed/db/fixtures/miq_user_roles.yml#L8-L8

Otherwise, superadmin will be the only one that sees it by default.

Operation `clear` removes all CloudObjectStoreObjects from
the CloudObjectStoreContainer.

Signed-off-by: Miha Pleško <miha.plesko@xlab.si>
@miq-bot
Copy link
Member

miq-bot commented Mar 7, 2017

Checked commit xlab-si@92e7dfb with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
3 files checked, 0 offenses detected
Everything looks good. 👍

@agrare
Copy link
Member

agrare commented Mar 7, 2017

LGTM thanks @miha-plesko !

@agrare agrare merged commit 6d90d8d into ManageIQ:master Mar 7, 2017
@chessbyte chessbyte added this to the Sprint 56 Ending Mar 13, 2017 milestone Mar 17, 2017
@tadeboro tadeboro deleted the empty_aws_bucket branch March 30, 2018 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants