Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE
cluster-glue.8724
bsc-1088656-High-external-ec2-Avoid-unicode-err...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File bsc-1088656-High-external-ec2-Avoid-unicode-errors-and-improve-p.patch of Package cluster-glue.8724
From 6734e0d0f6c20e44f31ab3f6664569adb3109dfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20Gr=C3=B6nlund?= <krig@koru.se> Date: Mon, 9 Apr 2018 14:47:49 +0200 Subject: [PATCH] High: external/ec2: Avoid unicode errors and improve performance (bsc#1088656) Originally by stsch@amazon.de: All AWS CLI describe commands have been changed to report the result directly. This has the following advantages: * No more unicode errors when other tags use UNICODE characters. * No more interpreatation errors with aws and grep if the text format changes. * Faster execution due to significantly reduced result sets. --- lib/plugins/stonith/external/ec2 | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/lib/plugins/stonith/external/ec2 b/lib/plugins/stonith/external/ec2 index 2fe59749..7ff4b512 100755 --- a/lib/plugins/stonith/external/ec2 +++ b/lib/plugins/stonith/external/ec2 @@ -22,6 +22,8 @@ If the tag containing the uname is not [Name], then it will need to be specified # +# Copyright (c) 2018 Stefan Schneider <stsch@amazon.de> +# Copyright (c) 2018 Kristoffer Gronlund <kgronlund@suse.com> # Copyright (c) 2011-2013 Andrew Beekhof # Copyright (c) 2014 NIPPON TELEGRAPH AND TELEPHONE CORPORATION # All Rights Reserved. @@ -174,11 +176,7 @@ function instance_for_port() local instance="" # Look for port name -n in the INSTANCE data - instance=`aws ec2 describe-instances $options | grep "^INSTANCES[[:space:]].*[[:space:]]$port[[:space:]]" | awk '{print $8}'` - if [ -z $instance ]; then - # Look for port name -n in the Name TAG - instance=`aws ec2 describe-tags $options | grep "^TAGS[[:space:]]$ec2_tag[[:space:]].*[[:space:]]instance[[:space:]]$port$" | awk '{print $3}'` - fi + instance=`aws ec2 describe-instances $options --filters "Name=tag-value,Values=${port}" "Name=tag-key,Values=${ec2_tag}" --query 'Reservations[*].Instances[*].InstanceId' ` if [ -z $instance ]; then instance_not_found=1 @@ -213,9 +211,7 @@ function instance_status() if [ "$unknown_are_stopped" = 1 -a $instance_not_found ]; then ha_log.sh info "$instance stopped (unknown)" else - status=`aws ec2 describe-instances $options --instance-ids $instance | awk '{ - if (/^STATE\t/) { printf "%s", $3 } - }'` + status=`aws ec2 describe-instances $options --instance-ids $instance --query 'Reservations[*].Instances[*].State.Name' ` rc=$? fi ha_log.sh info "status check for $instance is $status" @@ -226,7 +222,7 @@ function instance_status() function monitor() { # Is the device ok? - aws ec2 describe-instances $options | grep INSTANCES &> /dev/null + aws ec2 describe-instances $options --filters "Name=tag-key,Values=${ec2_tag}" | grep INSTANCES &> /dev/null } TEMP=`getopt -o qVho:e:p:n:t:U --long version,help,action:,port:,option:,profile:,tag:,quiet,unknown-are-stopped \ @@ -394,10 +390,7 @@ case $action in ;; gethosts|hostlist|list) # List of names we know about - a=`aws ec2 describe-instances $options | awk -v tag_pat="^TAGS\t$ec2_tag\t" -F '\t' '{ - if (/^INSTANCES/) { printf "%s\n", $8 } - else if ( $1"\t"$2"\t" ~ tag_pat ) { printf "%s\n", $3 } - }' | sort -u` + a=`aws ec2 describe-instances $options --filters "Name=tag-key,Values=${ec2_tag}" --query 'Reservations[*].Instances[*].Tags[?Key==\`'${ec2_tag}'\`].Value' | sort -u` echo $a ;; stat|status) -- 2.16.4
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor