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

refactor(eip): Refactor eip using egoscale v3 #642

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

Conversation

mlec1
Copy link
Contributor

@mlec1 mlec1 commented Oct 6, 2024

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)

  • Changelog updated (under Unreleased block)
  • Testing

Testing

Create, delete, update ip,...

Comment on lines +110 to +115
// 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,
Copy link
Member

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

Comment on lines +80 to +86
// 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))
Copy link
Member

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

Comment on lines +155 to +157
// 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
Copy link
Member

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

Copy link
Member

@pierre-emmanuelJ pierre-emmanuelJ left a 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)
Copy link
Member

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

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