Commit c1a2047
authored
sources/azure: ensure retries on IMDS request failure (#1271)
There are two issues with IMDS retries:
1. IMDS_VER_WANT will never be attempted if retries=0, such as
when fetching network metadata with infinite=True.
2. get_imds_data_with_api_fallback() will attempt one request with
IMDS_VER_WANT. If the connection fails due to a timeout, connection
issue, or error code other than 400, an empty dictionary will be
returned without attempting the requested number of retries.
This PR:
- Updates get_imds_data_with_api_fallback() to invoke
get_metadata_from_imds() with the specified retries and infinite
parameters.
- Updates retry_on_url_exc to take a configurable set of HTTP error
codes and exception types to retry on.
- Add IMDS_RETRY_CODES set to retry with when fetching data from IMDS:
- 404 not found (yet)
- 410 gone / unavailable (yet)
- 429 rate-limited/throttled
- 500 server error
- Replace default callback with imds_readurl_exception_callback,
which configures retry_on_url_exc() with these error codes and
instances.
- Add new pytests for IMDS to eventually replace the unittest
equivalents and improve existing coverage.
Signed-off-by: Chris Patterson <cpatterson@microsoft.com>1 parent f4404af commit c1a2047
File tree
3 files changed
+283
-56
lines changed- cloudinit
- sources
- tests/unittests/sources
3 files changed
+283
-56
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
70 | 82 | | |
71 | 83 | | |
72 | 84 | | |
| |||
725 | 737 | | |
726 | 738 | | |
727 | 739 | | |
728 | | - | |
729 | | - | |
730 | | - | |
731 | | - | |
732 | | - | |
733 | | - | |
734 | | - | |
735 | | - | |
736 | | - | |
737 | | - | |
738 | | - | |
739 | | - | |
740 | | - | |
741 | | - | |
742 | | - | |
743 | | - | |
744 | | - | |
745 | | - | |
746 | | - | |
747 | | - | |
748 | | - | |
749 | | - | |
750 | | - | |
751 | | - | |
752 | | - | |
753 | | - | |
754 | | - | |
755 | | - | |
756 | | - | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
757 | 746 | | |
758 | | - | |
759 | | - | |
760 | | - | |
761 | | - | |
762 | | - | |
763 | | - | |
764 | | - | |
765 | | - | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
766 | 783 | | |
767 | 784 | | |
768 | 785 | | |
| |||
2271 | 2288 | | |
2272 | 2289 | | |
2273 | 2290 | | |
2274 | | - | |
| 2291 | + | |
2275 | 2292 | | |
2276 | 2293 | | |
2277 | 2294 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
639 | 639 | | |
640 | 640 | | |
641 | 641 | | |
642 | | - | |
643 | | - | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
644 | 650 | | |
645 | | - | |
| 651 | + | |
646 | 652 | | |
647 | 653 | | |
648 | 654 | | |
649 | | - | |
| 655 | + | |
650 | 656 | | |
651 | | - | |
| 657 | + | |
652 | 658 | | |
653 | 659 | | |
654 | 660 | | |
| |||
0 commit comments