Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #370: run deployment_bastion_node_cleanup only on the same server uuid #371

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions fragments/bastion-node-cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if [ -e $INVENTORY -a "$node_type" == node ]; then
export ANSIBLE_ROLES_PATH=/usr/share/ansible/openshift-ansible/roles
export ANSIBLE_HOST_KEY_CHECKING=False

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

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


echo "Deleted node $node_name"
echo "Deleted node $node_name with id $node_id"
2 changes: 2 additions & 0 deletions infra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ resources:
properties:
group: script
inputs:
- name: node_id
- name: node_name
- name: node_type
- name: ssh_user
Expand All @@ -501,6 +502,7 @@ resources:
properties:
actions: ['DELETE']
input_values:
node_id: {get_resource: host}
node_type: infra
node_name:
str_replace:
Expand Down
2 changes: 2 additions & 0 deletions loadbalancer_dedicated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ resources:
properties:
group: script
inputs:
- name: node_id
- name: node_name
- name: node_type
- name: ssh_user
Expand All @@ -411,6 +412,7 @@ resources:
properties:
actions: ['DELETE']
input_values:
node_id: {get_resource: host}
node_type: loadbalancer
node_name:
str_replace:
Expand Down
2 changes: 2 additions & 0 deletions master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ resources:
properties:
group: script
inputs:
- name: node_id
- name: node_name
- name: node_type
- name: ssh_user
Expand All @@ -493,6 +494,7 @@ resources:
properties:
actions: ['DELETE']
input_values:
node_id: {get_resource: host}
node_type: master
node_name:
str_replace:
Expand Down
2 changes: 2 additions & 0 deletions node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ resources:
properties:
group: script
inputs:
- name: node_id
- name: node_name
- name: node_type
- name: ssh_user
Expand All @@ -603,6 +604,7 @@ resources:
properties:
actions: ['DELETE']
input_values:
node_id: {get_resource: host}
node_type: node
node_name:
str_replace:
Expand Down