我正在使用 Heat 来实现自动缩放,下面是我的代码的一小部分:
heat_template_version: 2016-10-14
...
resources:
corey_server_group:
type: OS::Heat::AutoScalingGroup
depends_on: corey-server
properties:
min_size: 1
max_size: 5
resource:
type: CoreyLBSServer.yaml
properties:
......
CoreyLBSServer.yaml
heat_template_version: 2016-10-14
...
resources:
server:
type: OS::Nova::Server
properties:
flavor:
......
我正在寻找一种缩小特定实例的方法,这是我尝试过的一些方法,但都没有奏效,它总是缩小最旧的实例。
1.关闭实例,然后发出缩减策略信号。(X) 2.据此,从attribute中找到stack-id ,将resource标记为,然后发出
scaledown policy。(X)
3.从attribute中找到stack-id ,设置stack status为,然后signal scaledown policy。(X)refs_map
server
unhealthy
refs_map
FAILED
我试图找出 AutoScalingGroup 在缩减时使用什么策略,从代码heat/common/grouputils.py中,它按“created_time”然后按名称对成员进行排序,因此在缩减时将首先删除最旧的成员。但是有一个例外,如果include_failed
设置了,失败的成员将首先放入按 created_time 排序的列表中,然后按 name 排序。
更新
我终于成功地将我的目标设置为“失败”,这是命令:
# firstly, print the physical_resource_id of corey_server_group
openstack stack resource show -c physical_resource_id <parent_stack_id> corey_server_group
# secondly, list resources in the corey_server_group
openstack stack resource list <physical_resource_id>
# thirdly, mark the target as unhealthy
openstack stack resource mark unhealthy <physical_resource_id> <resource_name>
# after these commands, you will see the resource_status of the target becomes "Check Failed"
但它还有另一个问题,Heat 在缩减的同时会删除“失败”和“最旧”的资源!如何仅缩小“标记为失败”的目标?