[英]AWS EC2 Spot request fulfillment waiter from PHP SDK waits indefinitely
I'm trying to get through the eventual consistency of a spot instance so I can assign it within my application. 我试图通过竞价型实例的最终一致性,以便可以在我的应用程序中分配它。 Here's what I've seen, from a fairly simple spot instance call.
这是我从一个非常简单的竞价实例调用中看到的内容。
The instance requested is immediately started (fast 15-30 second instance running state), but the waiter continues indefinitely. 所请求的实例将立即启动(15-30秒的快速实例运行状态),但等待者将无限期继续。
I'm not sure if the issue lies with my code, the SDK, or AWS not fulfilling the request quickly. 我不确定问题是否出在我的代码,SDK或AWS未能快速满足请求。
$spotEc2Client = $this->sdk->createEc2([]);
// Create instance via spot request
$result = $spotEc2Client->requestSpotInstances($spotConfig);
$spotResult = $result->getPath('SpotInstanceRequests');
$spotRequestId = $spotResult[0]['SpotInstanceRequestId'];
$now = date("F d, Y H:i:s A");
echo "Spot Request ID is: $spotRequestId\n";
echo "Starting at $now MST\n";
$spotEc2Client->waitUntil(
'SpotInstanceRequestFulfilled',
[
'SpotInstanceRequestId' => $spotRequestId,
'@waiter' => [
'before' => function (CommandInterface $command, $attempts) {
$now = date("H:i:s");
printf(
"[$now] About to send %s. Attempt %d\n",
$command->getName(),
$attempts
);
}
],
]
);
Output: 输出:
Spot Request ID is: sir-<my request id>
Starting at August 18, 2017 10:10:20 AM MST
[10:10:20] About to send DescribeSpotInstanceRequests. Attempt 1
[10:10:21] About to send DescribeSpotInstanceRequests. Attempt 2
[10:10:36] About to send DescribeSpotInstanceRequests. Attempt 3
[10:10:52] About to send DescribeSpotInstanceRequests. Attempt 4
[10:11:07] About to send DescribeSpotInstanceRequests. Attempt 5
[10:11:23] About to send DescribeSpotInstanceRequests. Attempt 6
[10:11:38] About to send DescribeSpotInstanceRequests. Attempt 7
Comparing the check times against the launch time: 将检查时间与启动时间进行比较:
I'm thinking I need to just do my own polling against describeInstances
looking specifically for spot instances that are at running or init, and handle it on my own - because the call to DescribeSpotInstanceRequests
goes on indefinitely as far as I've been able to tell. 我想我只需要对
describeInstances
自己的轮询,即可专门查找正在运行或init的竞价型实例,并自行处理-因为对DescribeSpotInstanceRequests
的调用会无限期地进行下去告诉。
I had misformatted my argument for the SpotRequestId
. 我已经将
SpotRequestId
参数SpotRequestId
错误。 This was quickly and kindly pointed out to me by someone on AWS PHP SDK's github! 有人在AWS PHP SDK的github上迅速友好地向我指出了这一点!
The formatting of my spot instance request required a plural and an array as an argument. 我的竞价型实例请求的格式需要复数和数组作为参数。
$spotEc2Client->waitUntil(
'SpotInstanceRequestFulfilled',
[
'SpotInstanceRequestId' => $spotRequestId,
]
...
To Be: 成为:
$spotEc2Client->waitUntil(
'SpotInstanceRequestFulfilled',
[
'SpotInstanceRequestIds' => [
$spotRequestId
]
...
I think as an API user I would prefer an exception or maybe a warning for the incorrect argument but that's a discussion for another place. 我认为,作为API用户,我更喜欢异常或警告错误的参数,但这是另一个地方的讨论。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.