-
Notifications
You must be signed in to change notification settings - Fork 20
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
refactor(eip): Refactor eip using egoscale v3 #642
base: master
Are you sure you want to change the base?
Conversation
// Comment for reviewer: | ||
// Is there a way to get the created Elastic IP address or UUID ??? | ||
// Listing all of them and comparing Addressfamily, Description,... doesn't really garantee uniquess | ||
// TODO: Remove comment before merging | ||
ElasticIP: "", | ||
Zone: c.Zone, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes you need to get the op
after waiting and there is the op.Reference.ID
check if reference not nil before using
// Message for reviewer: | ||
// It always returns the list of all instances. Why ??? | ||
// When no instance attached to Elastic IP, should returned an empty list | ||
// When some instances attached to elastic IP, should returns only the attached instances | ||
// Am I doing something wrong here ?? Is the ip-address parameter taking the Elastic IP into account ?? | ||
// TODO: remove comment before merging | ||
instances, err := client.ListInstances(ctx, v3.ListInstancesWithIPAddress(elasticIPID)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try to reproduce, thanks for reporting
// Message for reviewer: | ||
// I don't really like to use this function for only one this parameter, if you have a better solution, please feel free to suggest it | ||
// TODO: remove comment before merging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is not gorgeous I agree, it's hard to define what's an empty value for certain type if we are not relying on pointers, example for int or bool, probably for sting types, you can remove pointer and rely only omitempty tag fpr empty string.
Probably need to be verified for other types like int, if in this case we can consider 0 as an empty value...etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good change!!, we will do another review on it
op, err := client.DeleteElasticIP(ctx, elasticIP.ID) | ||
if err != nil { | ||
return fmt.Errorf("exoscale: error while deleting Elastic IP: %w", err) | ||
} | ||
|
||
_, err = client.Wait(ctx, op, v3.OperationStateSuccess) | ||
if err != nil { | ||
return fmt.Errorf("exoscale: error while waiting for Elastic IP deletion: %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I pointed out in another PR, if you decided to add more context on the error you can keep, it, I was pointing the change with no context added.
To stay consistent, everywhere, it's better if you not do a mix of sometime add error wrapping and sometime not, you decide, you wrap all and return the proper error, or you wrap not.
IMO, having error wrapping with more context is always better in case of error :) but make sure to respect the same behavior everywhere and stay consistent
Update the elastic ip using Egoscale v3.
Some stuff are not working yet: I put some comments in the code, you will see.
Checklist
(For exoscale contributors)
Testing
Create, delete, update ip,...