Skip to content

fix: reconsider behavior when providing a value lower than 500 for bu… #438

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

harsh082ip
Copy link

@harsh082ip harsh082ip commented Jul 9, 2024

As mentioned in issue #394, the following changes have been made:

The command will now fail immediately for values less than 500 GB with an appropriate error message.

Introduced a --yes flag to automatically adjust the bucket size to the nearest multiple of 500 without prompting the user.
For example:
Warning: The size to create an object store must be a multiple of 500. Would you like to create an object store of 1000 GB instead? (y/n)?
Using the --yes flag, users can bypass this prompt.

Improved the help message to make the minimum and default size requirements explicit:
-s, --size int Size of the Object store in GB (minimum: 500) (default 500)

Screenshot:
image

Please review and let me know if any changes are needed.
@haardikdharma10 @uzaxirr @RealHarshThakur @alejandrojnm

@alessandroargentieri
Copy link
Member

@fulviodenza are you free to give it a look?

@giornetta
Copy link
Member

Hi @harsh082ip, thanks for your contribution!

While the original issue has already been marked as closed and some parts of it were resolved, I think we should discuss whether we want to let the --yes flag automatically select an higher size in this context.
This could cause some confusion among customers and some churn when they receive an higher bill than they expected.

@alessandroargentieri @fulviodenza @uzaxirr thoughts?

@harsh082ip
Copy link
Author

Hii @giornetta ,

Thanks for the context! I agree, auto-selecting a higher size with --yes might lead to unexpected charges. Happy to align on the best approach.

@@ -45,10 +45,11 @@ func init() {
ObjectStoreCmd.AddCommand(objectStoreCredentialCmd)

//Flags for create cmd
objectStoreCreateCmd.Flags().Int64VarP(&bucketSize, "size", "s", 500, "Size of the Object store")
objectStoreCreateCmd.Flags().Int64VarP(&bucketSize, "size", "s", 500, "Size of the Object store in GB (minimum: 500)")
Copy link
Contributor

Choose a reason for hiding this comment

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

let's use a variable for this 500 value,

os.Exit(1)
}
if !accept {
os.Exit(0)
Copy link
Contributor

Choose a reason for hiding this comment

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

this indicates success, the operation, when not accepted is not a success, we need os.Exit(1) for this

utility.Error("Unable to parse the input: %s", err)
os.Exit(1)
if !yesFlag {
utility.YellowConfirm("The size to create an object store must be a multiple of 500. Would you like to create an %s of %d GB instead? (y/n) ? ", utility.Green("object store"), bucketSize+(500-bucketSize%500))
Copy link
Contributor

Choose a reason for hiding this comment

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

we should specify that 500 and 1000GB are the only allowed sizes

Copy link
Contributor

Choose a reason for hiding this comment

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

bucketSize+(500-bucketSize%500)) could be a small function

@giornetta giornetta added the enhancement New feature or request label May 6, 2025
@harsh082ip
Copy link
Author

Hi @fulviodenza, apologies for the delay — I've pushed the required changes. Let me know if anything else is needed.

@@ -45,10 +50,11 @@ func init() {
ObjectStoreCmd.AddCommand(objectStoreCredentialCmd)

//Flags for create cmd
objectStoreCreateCmd.Flags().Int64VarP(&bucketSize, "size", "s", 500, "Size of the Object store (Minimum size is 500GB)")
objectStoreCreateCmd.Flags().Int64VarP(&bucketSize, "size", "s", minBucketSizeGB, fmt.Sprintf("Size of the Object store (Allowed sizes: %dGB or 1000GB)", minBucketSizeGB))
Copy link
Contributor

Choose a reason for hiding this comment

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

why the 500 is set as constant while the 1000 isn't?


var objectStoreCreateCmd = &cobra.Command{
Use: "create",
Aliases: []string{"new", "add"},
Example: "civo objectstore create OBJECTSTORE_NAME --size SIZE",
Short: "Create a new Object Store",
Long: "Bucket size should be in Gigabytes (GB) and must be a multiple of 500, starting from 500.\n",
Long: "Bucket size should be in Gigabytes (GB) and must be either 500 or 1000.\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

couldn't we use the constants of before, declared in a common package?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants