Skip to content

Commit

Permalink
tidy: additional metadata debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
actionshrimp committed Mar 5, 2024
1 parent efe2742 commit dfcd9c2
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/auth.ml
Original file line number Diff line number Diff line change
Expand Up @@ -580,13 +580,35 @@ let discover_credentials_with (discovery_mode : discovery_mode) =
(fun () ->
let open Lwt_result.Syntax in
let* resp, _body = Compute_engine.Metadata.ping () |> ok in
let* () = L.debug (fun m -> m "Got metadata response") |> ok in
let has_metadata_header =
Compute_engine.Metadata.response_has_metadata_header resp
in
match Cohttp.Response.status resp with
| `OK when Compute_engine.Metadata.response_has_metadata_header resp
->
| `OK when has_metadata_header ->
let* () =
L.debug (fun m -> m "Metadata response was ok with header")
|> ok
in
let* project_id = Compute_engine.Metadata.get_project_id () in
Lwt_result.return (GCE_metadata { project_id })
| _ -> Lwt.return_error `No_credentials)
(fun _exn -> Lwt.return_error `No_credentials)
| code ->
let* () =
L.debug (fun m ->
m "Metadata response was: (%d, header: %b)"
(Cohttp.Code.code_of_status code)
has_metadata_header)
|> ok
in

Lwt.return_error `No_credentials)
(fun exn ->
let* () =
L.debug (fun m ->
let s = Printexc.to_string exn in
m "Exception while pinging metadata endpoint: %s" s)
in
Lwt.return_error `No_credentials)
in
let timeout =
let* () =
Expand Down

0 comments on commit dfcd9c2

Please sign in to comment.