Skip to content

Commit 33724f0

Browse files
authored
remove instance from placement group before destroy (#1205)
1 parent abd853a commit 33724f0

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

scaleway/resource_instance_server.go

+11
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,17 @@ func resourceScalewayInstanceServerDelete(ctx context.Context, d *schema.Resourc
983983
log.Print("[WARN] Failed to detach eip of server")
984984
}
985985
}
986+
// Remove instance from placement group to free it even if instance won't stop
987+
if _, ok := d.GetOk("placement_group_id"); ok {
988+
_, err := instanceAPI.UpdateServer(&instance.UpdateServerRequest{
989+
Zone: zone,
990+
PlacementGroup: &instance.NullableStringValue{Null: true},
991+
ServerID: ID,
992+
})
993+
if err != nil {
994+
log.Print("[WARN] Failed remove server from instance group")
995+
}
996+
}
986997
// reach stopped state
987998
err = reachState(ctx, instanceAPI, zone, ID, instance.ServerStateStopped)
988999
if is404Error(err) {

0 commit comments

Comments
 (0)