add wait loop in invoke to make sure the update has been processed
This commit is contained in:
parent
91149957b5
commit
a7c72d5ad2
|
@ -52,6 +52,33 @@ fn make(step: *std.Build.Step, node: std.Progress.Node) anyerror!void {
|
|||
.client = client,
|
||||
.region = try self.options.region.region(),
|
||||
};
|
||||
var inx: usize = 10; // 200ms * 10
|
||||
while (inx > 0) : (inx -= 1) {
|
||||
var diagnostics = aws.Diagnostics{
|
||||
.http_code = undefined,
|
||||
.response_body = undefined,
|
||||
.allocator = self.step.owner.allocator,
|
||||
};
|
||||
const call = aws.Request(services.lambda.get_function).call(.{
|
||||
.function_name = self.options.name,
|
||||
}, options) catch |e| {
|
||||
// There seems an issue here, but realistically, we have an arena
|
||||
// so there's no leak leaving this out
|
||||
defer diagnostics.deinit();
|
||||
if (diagnostics.http_code == 404) continue; // function was just created...it's ok
|
||||
return step.fail(
|
||||
"Unknown error {} from Lambda GetFunction. HTTP code {}, message: {s}",
|
||||
.{ e, diagnostics.http_code, diagnostics.response_body },
|
||||
);
|
||||
};
|
||||
defer call.deinit();
|
||||
if (!std.mem.eql(u8, "InProgress", call.response.configuration.?.last_update_status.?))
|
||||
break; // We're ready to invoke!
|
||||
const ms: usize = if (inx == 5) 500 else 50;
|
||||
std.time.sleep(ms * std.time.ns_per_ms);
|
||||
}
|
||||
if (inx == 0)
|
||||
return step.fail("Timed out waiting for lambda to update function", .{});
|
||||
const call = try aws.Request(services.lambda.invoke).call(.{
|
||||
.function_name = self.options.name,
|
||||
.payload = self.options.payload,
|
||||
|
|
Loading…
Reference in New Issue
Block a user