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

Adding retry for eni plugin to acquire mac address #62

Merged
merged 3 commits into from
Jan 2, 2018

Conversation

richardpen
Copy link
Contributor

This PR adds backoff retry logic for retrieving mac address of the eni from ec2 instance metadata.

@richardpen richardpen changed the base branch from dev to 2017.10.x December 27, 2017 21:41
Copy link
Contributor

@nmeyerhans nmeyerhans left a comment

Choose a reason for hiding this comment

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

Looks good in general. Just a couple of comments on style that you can choose to address or not.

// express or implied. See the License for the specific language governing
// permissions and limitations under the License.

package utils
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if now might be the right time to split this code out into a standalone library. Copy & Paste between projects is not so good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, I don't like copy and paste either, but it will require additional work which probably won't happen within this pr, I will create an issue to follow up.

@@ -152,6 +163,63 @@ func add(args *skel.CmdArgs, engine engine.Engine, dhclient engine.DHClient) err
return cnitypes.PrintResult(result, conf.CNIVersion)
}

// getMACAddressOfENIAndVerify acquires the mac address of eni and verify the ip address information
func getMACAddressOfENIAndVerify(conf *types.NetConf, engine engine.Engine, timeout time.Duration) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really like the name getMACAddressOfENIAndVerify. It feels unnecessarily verbose and isn't descriptive of the fact that we're also verifying IP info (not just MAC addr). I'd name this getENIMetadata and leave the "verify" part as implicit. Or getAndVerifyENIMetadata maybe, if you really want "verify" to be part of the function name.

return nil
}

_, ok := err.(*engine.UnmappedMACAddressError)
Copy link
Contributor

Choose a reason for hiding this comment

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

I realize that we don't actually have the issue here, but this style of type assertion gives me flashbacks to aws/amazon-ecs-agent#910. Interface conversions are a less error prone way to perform type assertions, IMO.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you address @nmeyerhans 's comment here as well?

ec2InstanceMetadataBackoffMax = 1 * time.Second
ec2InstanceMetadataBackoffMultiple = 2
ec2InstanceMetadataBackoffJitter = 0.2
ec2InstanceMetadataTimeout = 5 * time.Second
Copy link
Contributor

Choose a reason for hiding this comment

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

How did you arrive at a 5 second timeout?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aaithal and I did some tests, the worst case I saw is 1.5s. So I put 5s here to be safe, but it's changeable.

for {
select {
case <-ctx.Done():
return ctx.Err()
Copy link
Contributor

Choose a reason for hiding this comment

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

nice. we need to fix this in the agent repo as well.

@@ -27,6 +30,14 @@ import (
"github.com/pkg/errors"
)

const (
ec2InstanceMetadataBackoffMin = 500 * time.Millisecond
Copy link
Contributor

Choose a reason for hiding this comment

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

can you decrease this to 100ms? half a second seems really long to wait here.

return nil
}

_, ok := err.(*engine.UnmappedMACAddressError)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you address @nmeyerhans 's comment here as well?

@richardpen richardpen merged commit 7638fd7 into aws:2017.10.x Jan 2, 2018
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