Skip to content

Commit 88d0dbf

Browse files
committed
fix #370: run deployment_bastion_node_cleanup only on the same server uuid.
1 parent 2c1b721 commit 88d0dbf

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

fragments/bastion-node-cleanup.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if [ -e $INVENTORY -a "$node_type" == node ]; then
2020
export ANSIBLE_ROLES_PATH=/usr/share/ansible/openshift-ansible/roles
2121
export ANSIBLE_HOST_KEY_CHECKING=False
2222

23-
ansible-playbook -vvvv -e node=$node_name \
23+
ansible-playbook -vvvv -e node=$node_name -e node_id=$node_id \
2424
--inventory /var/lib/ansible/inventory \
2525
/var/lib/ansible/playbooks/scaledown.yml &>> /var/log/ansible-scaledown.$$ || true
2626
fi
@@ -32,9 +32,15 @@ if [ -e $NODESFILE ]; then
3232
grep -v "$node_name" ${NODESFILE}.bkp > $NODESFILE || true
3333
fi
3434

35-
# unregister the node if registered with subscription-manager
36-
[ -e $INVENTORY ] && ansible $node_name -m shell \
35+
# unregister the node if
36+
# - node_id matches the one defined in deployment_bastion_node_cleanup
37+
# - registered with subscription-manager
38+
if [ -e $INVENTORY ]; then
39+
echo "Cleanup node $node_name with $node_id" >> /var/log/ansible-node-cleanup.log
40+
ansible $node_name -m shell \
3741
-u $ssh_user --sudo -i $INVENTORY \
38-
-a "subscription-manager unregister && subscription-manager clean" || true
42+
-a "test -d /var/lib/cloud/instances/$node_id && subscription-manager unregister && subscription-manager clean" || true
43+
fi
44+
3945

40-
echo "Deleted node $node_name"
46+
echo "Deleted node $node_name with id $node_id"

infra.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ resources:
485485
properties:
486486
group: script
487487
inputs:
488+
- name: node_id
488489
- name: node_name
489490
- name: node_type
490491
- name: ssh_user
@@ -501,6 +502,7 @@ resources:
501502
properties:
502503
actions: ['DELETE']
503504
input_values:
505+
node_id: {get_resource: host}
504506
node_type: infra
505507
node_name:
506508
str_replace:

loadbalancer_dedicated.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ resources:
395395
properties:
396396
group: script
397397
inputs:
398+
- name: node_id
398399
- name: node_name
399400
- name: node_type
400401
- name: ssh_user
@@ -411,6 +412,7 @@ resources:
411412
properties:
412413
actions: ['DELETE']
413414
input_values:
415+
node_id: {get_resource: host}
414416
node_type: loadbalancer
415417
node_name:
416418
str_replace:

master.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ resources:
477477
properties:
478478
group: script
479479
inputs:
480+
- name: node_id
480481
- name: node_name
481482
- name: node_type
482483
- name: ssh_user
@@ -493,6 +494,7 @@ resources:
493494
properties:
494495
actions: ['DELETE']
495496
input_values:
497+
node_id: {get_resource: host}
496498
node_type: master
497499
node_name:
498500
str_replace:

node.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ resources:
587587
properties:
588588
group: script
589589
inputs:
590+
- name: node_id
590591
- name: node_name
591592
- name: node_type
592593
- name: ssh_user
@@ -603,6 +604,7 @@ resources:
603604
properties:
604605
actions: ['DELETE']
605606
input_values:
607+
node_id: {get_resource: host}
606608
node_type: node
607609
node_name:
608610
str_replace:

0 commit comments

Comments
 (0)