Skip to content

Commit 2323944

Browse files
committed
Add debug logging to IMDS PUT/GET paths
Log token PUT failures and non-success GET responses at debug level to aid diagnosing IMDS connectivity issues.
1 parent a787a2f commit 2323944

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎src/imds.zig‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
const std = @import("std");
99
const Allocator = std.mem.Allocator;
10+
const log = std.log.scoped(.aws_sdk);
1011

1112
const http = @import("http.zig");
1213
const date = @import("date.zig");
@@ -244,12 +245,14 @@ pub const Client = struct {
244245
return error.OutOfMemory;
245246

246247
var response = self.http_client.sendRequest(&request) catch |err| {
248+
log.debug("IMDS token PUT failed: {s}", .{@errorName(err)});
247249
fillDiagnosticFromError(options.diagnostic, err, "token request failed");
248250
return err;
249251
};
250252
defer response.deinit();
251253

252254
if (!response.isSuccess()) {
255+
log.debug("IMDS token PUT status={d} body={s}", .{ response.status, response.body });
253256
fillDiagnosticFromStatus(options.diagnostic, @intCast(response.status), "token request failed");
254257
return error.HttpError;
255258
}
@@ -308,12 +311,14 @@ pub const Client = struct {
308311
return error.OutOfMemory;
309312

310313
var response = self.http_client.sendRequest(&request) catch |err| {
314+
log.debug("IMDS GET {s} failed: {s}", .{ path, @errorName(err) });
311315
fillDiagnosticFromError(options.diagnostic, err, "metadata request failed");
312316
return err;
313317
};
314318
defer response.deinit();
315319

316320
if (!response.isSuccess()) {
321+
log.debug("IMDS GET {s} status={d} body={s}", .{ path, response.status, response.body });
317322
fillDiagnosticFromStatus(options.diagnostic, @intCast(response.status), "metadata request failed");
318323
return error.HttpError;
319324
}

0 commit comments

Comments
 (0)