@@ -746,26 +746,8 @@ region_from_availability_zone(Value) ->
746746% % @doc Attempt to obtain EC2 IMDSv2 token.
747747% % @end
748748load_imdsv2_token () ->
749- <<<<<<< HEAD
750- TokenUrl = imdsv2_token_url (),
751- ? LOG_INFO (" Attempting to obtain EC2 IMDSv2 token from ~tp ..." , [TokenUrl ]),
752- case httpc :request (put , {TokenUrl , [{? METADATA_TOKEN_TTL_HEADER , integer_to_list (? METADATA_TOKEN_TTL_SECONDS )}]},
753- [{timeout , ? DEFAULT_HTTP_TIMEOUT }], []) of
754- {ok , {{_ , 200 , _ }, _ , Value }} ->
755- ? LOG_DEBUG (" Successfully obtained EC2 IMDSv2 token." ),
756- Value ;
757- {error , {{_ , 400 , _ }, _ , _ }} ->
758- ? LOG_WARNING (" Failed to obtain EC2 IMDSv2 token: Missing or Invalid Parameters – The PUT request is not valid." ),
759- undefined ;
760- Other ->
761- ? LOG_WARNING (
762- get_instruction_on_instance_metadata_error (" Failed to obtain EC2 IMDSv2 token: ~tp . "
763- " Falling back to EC2 IMDSv1 for now. It is recommended to use EC2 IMDSv2." ), [Other ]),
764- undefined
765- end .
766- =======
767749 TokenUrl = imdsv2_token_url (),
768- rabbit_log : info (" Attempting to obtain EC2 IMDSv2 token from ~tp ..." , [TokenUrl ]),
750+ ? LOG_INFO (" Attempting to obtain EC2 IMDSv2 token from ~tp ..." , [TokenUrl ]),
769751 % Parse metadata service URL
770752 {Host , Port , Path } = rabbitmq_aws :parse_uri (TokenUrl ),
771753 % Simple Gun connection for metadata service
@@ -779,38 +761,38 @@ load_imdsv2_token() ->
779761 StreamRef = gun :put (ConnPid , Path , Headers , <<>>),
780762 Result = case gun :await (ConnPid , StreamRef , ? DEFAULT_HTTP_TIMEOUT ) of
781763 {response , fin , 200 , _RespHeaders } ->
782- rabbit_log : debug (" Successfully obtained EC2 IMDSv2 token." ),
764+ ? LOG_DEBUG (" Successfully obtained EC2 IMDSv2 token." ),
783765 <<>>; % Empty body for fin response
784766 {response , nofin , 200 , _RespHeaders } ->
785767 {ok , Body } = gun :await_body (ConnPid , StreamRef , ? DEFAULT_HTTP_TIMEOUT ),
786- rabbit_log : debug (" Successfully obtained EC2 IMDSv2 token." ),
768+ ? LOG_DEBUG (" Successfully obtained EC2 IMDSv2 token." ),
787769 binary_to_list (Body );
788770 {response , _ , 400 , _RespHeaders } ->
789- rabbit_log : warning (" Failed to obtain EC2 IMDSv2 token: Missing or Invalid Parameters – The PUT request is not valid." ),
771+ ? LOG_WARNING (" Failed to obtain EC2 IMDSv2 token: Missing or Invalid Parameters – The PUT request is not valid." ),
790772 undefined ;
791773 {error , Reason } ->
792- rabbit_log : warning (
793- get_instruction_on_instance_metadata_error (" Failed to obtain EC2 IMDSv2 token: ~tp . "
774+ ? LOG_WARNING (
775+ get_instruction_on_instance_metadata_error (" Failed to obtain EC2 IMDSv2 token: ~tp . "
794776 " Falling back to EC2 IMDSv1 for now. It is recommended to use EC2 IMDSv2." ), [Reason ]),
795777 undefined ;
796778 Other ->
797- rabbit_log : warning (
798- get_instruction_on_instance_metadata_error (" Failed to obtain EC2 IMDSv2 token: ~tp . "
779+ ? LOG_WARNING (
780+ get_instruction_on_instance_metadata_error (" Failed to obtain EC2 IMDSv2 token: ~tp . "
799781 " Falling back to EC2 IMDSv1 for now. It is recommended to use EC2 IMDSv2." ), [Other ]),
800782 undefined
801783 end ,
802784 gun :close (ConnPid ),
803785 Result ;
804786 {error , Reason } ->
805787 gun :close (ConnPid ),
806- rabbit_log : warning (
807- get_instruction_on_instance_metadata_error (" Failed to connect for EC2 IMDSv2 token: ~tp . "
788+ ? LOG_WARNING (
789+ get_instruction_on_instance_metadata_error (" Failed to connect for EC2 IMDSv2 token: ~tp . "
808790 " Falling back to EC2 IMDSv1 for now. It is recommended to use EC2 IMDSv2." ), [Reason ]),
809791 undefined
810792 end ;
811793 {error , Reason } ->
812- rabbit_log : warning (
813- get_instruction_on_instance_metadata_error (" Failed to open connection for EC2 IMDSv2 token: ~tp . "
794+ ? LOG_WARNING (
795+ get_instruction_on_instance_metadata_error (" Failed to open connection for EC2 IMDSv2 token: ~tp . "
814796 " Falling back to EC2 IMDSv1 for now. It is recommended to use EC2 IMDSv2." ), [Reason ]),
815797 undefined
816798 end .
0 commit comments