Skip to content

Commit 512055c

Browse files
重试开机提示使用say而不是halt
1 parent 06e0bd9 commit 512055c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

builder/tencentcloud/cvm/step_run_instance.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ func (s *stepRunInstance) Run(ctx context.Context, state multistep.StateBag) mul
154154
}
155155
var resp *cvm.RunInstancesResponse
156156
for _, subnet := range subnets.([]*vpc.Subnet) {
157+
Say(state,
158+
fmt.Sprintf("instance-type: %s, subnet-id: %s, zone: %s",
159+
s.InstanceType, *subnet.SubnetId, *subnet.Zone,
160+
), "Try to create instance")
157161
req.VirtualPrivateCloud = &cvm.VirtualPrivateCloud{
158162
VpcId: &vpc_id,
159163
SubnetId: subnet.SubnetId,
@@ -168,8 +172,10 @@ func (s *stepRunInstance) Run(ctx context.Context, state multistep.StateBag) mul
168172
return e
169173
})
170174
if err != nil {
171-
// halt会返回终止信号,此处只需要记录日志,因此不需要return
172-
Halt(state, err, "Failed to run instance")
175+
// halt会返回终止信号并且记录error,存在error在state中会导致最终执行标记为失败
176+
// 此处只需要记录日志,因此使用say
177+
Say(state, fmt.Sprintf("%s", err), "Failed to run instance")
178+
continue
173179
}
174180

175181
if len(resp.Response.InstanceIdSet) != 1 {

0 commit comments

Comments
 (0)