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

EC2: Eni detach error #7697

Merged
merged 11 commits into from
May 19, 2024
Merged

EC2: Eni detach error #7697

merged 11 commits into from
May 19, 2024

Conversation

rafcio19
Copy link
Contributor

@rafcio19 rafcio19 commented May 16, 2024

Resolves #7678

@rafcio19 rafcio19 marked this pull request as ready for review May 16, 2024 09:13
@rafcio19
Copy link
Contributor Author

@bblommers I skipped the new test in server mode as it was failing and I couldn't repro locally.

Copy link
Collaborator

@bblommers bblommers left a comment

Choose a reason for hiding this comment

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

The ServerMode error can be reproduced by running the tests in parallel:

MOTO_CALL_RESET_API=false TEST_SERVER_MODE=true pytest -sv tests/test_ec2/test_elastic_network_interfaces.py -n 4

The reason it fails is because there will be other ENI's present (created by other tests) - so the len(enis) will always be greater than 0.

I think the logic should be changed so that we check the number of ENI's on that specific instance:

for eni ..:
    if eni.attachment_id..:
        if len(eni.instance.nics) ==1:
            raise LastEniDetachError
        detach_eni..

Copy link

codecov bot commented May 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.33%. Comparing base (fefe530) to head (b1511d4).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7697   +/-   ##
=======================================
  Coverage   94.33%   94.33%           
=======================================
  Files        1087     1087           
  Lines       92757    92765    +8     
=======================================
+ Hits        87500    87508    +8     
  Misses       5257     5257           
Flag Coverage Δ
servertests 29.45% <54.54%> (+<0.01%) ⬆️
unittests 94.30% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rafcio19 rafcio19 requested a review from bblommers May 19, 2024 14:02
Copy link
Collaborator

@bblommers bblommers left a comment

Choose a reason for hiding this comment

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

Great - thank you @rafcio19!

@bblommers bblommers added this to the 5.0.8 milestone May 19, 2024
@bblommers bblommers merged commit 86d23eb into getmoto:master May 19, 2024
40 checks passed
Copy link
Contributor

This is now part of moto >= 5.0.8.dev11

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.

EC2 detach_network_interface should return error when removing the primary network interface
2 participants