|
|
030326 |
From 523c4cee64b3b8ee9f603a940d83a6628531078d Mon Sep 17 00:00:00 2001
|
|
|
030326 |
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
|
|
|
030326 |
Date: Tue, 19 Jan 2021 10:56:47 +0100
|
|
|
030326 |
Subject: [PATCH 1/2] gcp-vpc-move-route: fix stop-action when route stopped,
|
|
|
030326 |
and fix check_conflicting_routes()
|
|
|
030326 |
|
|
|
030326 |
---
|
|
|
030326 |
heartbeat/gcp-vpc-move-route.in | 23 +++++++++++++++++------
|
|
|
030326 |
1 file changed, 17 insertions(+), 6 deletions(-)
|
|
|
030326 |
|
|
|
030326 |
diff --git a/heartbeat/gcp-vpc-move-route.in b/heartbeat/gcp-vpc-move-route.in
|
|
|
030326 |
index 179eba15a..9fe985832 100644
|
|
|
030326 |
--- a/heartbeat/gcp-vpc-move-route.in
|
|
|
030326 |
+++ b/heartbeat/gcp-vpc-move-route.in
|
|
|
030326 |
@@ -252,8 +252,19 @@ def validate(ctx):
|
|
|
030326 |
def check_conflicting_routes(ctx):
|
|
|
030326 |
fl = '(destRange = "%s*") AND (network = "%s") AND (name != "%s")' % (
|
|
|
030326 |
ctx.ip, ctx.vpc_network_url, ctx.route_name)
|
|
|
030326 |
- request = ctx.conn.routes().list(project=ctx.project, filter=fl)
|
|
|
030326 |
- response = request.execute()
|
|
|
030326 |
+ try:
|
|
|
030326 |
+ request = ctx.conn.routes().list(project=ctx.project, filter=fl)
|
|
|
030326 |
+ response = request.execute()
|
|
|
030326 |
+ except googleapiclient.errors.HttpError as e:
|
|
|
030326 |
+ if e.resp.status == 404:
|
|
|
030326 |
+ logger.error('VPC network not found')
|
|
|
030326 |
+ if 'stop' in sys.argv[1]:
|
|
|
030326 |
+ sys.exit(OCF_SUCCESS)
|
|
|
030326 |
+ else:
|
|
|
030326 |
+ sys.exit(OCF_ERR_CONFIGURED)
|
|
|
030326 |
+ else:
|
|
|
030326 |
+ raise
|
|
|
030326 |
+
|
|
|
030326 |
route_list = response.get('items', None)
|
|
|
030326 |
if route_list:
|
|
|
030326 |
logger.error(
|
|
|
030326 |
@@ -353,16 +364,16 @@ def route_monitor(ctx):
|
|
|
030326 |
logger.info('GCP route monitor: checking route table')
|
|
|
030326 |
|
|
|
030326 |
# Ensure that there is no route that we are not aware of that is also handling our IP
|
|
|
030326 |
- check_conflicting_routes
|
|
|
030326 |
+ check_conflicting_routes(ctx)
|
|
|
030326 |
|
|
|
030326 |
try:
|
|
|
030326 |
request = ctx.conn.routes().get(project=ctx.project, route=ctx.route_name)
|
|
|
030326 |
response = request.execute()
|
|
|
030326 |
except googleapiclient.errors.HttpError as e:
|
|
|
030326 |
- if 'Insufficient Permission' in e.content:
|
|
|
030326 |
- return OCF_ERR_PERM
|
|
|
030326 |
- elif e.resp.status == 404:
|
|
|
030326 |
+ if e.resp.status == 404:
|
|
|
030326 |
return OCF_NOT_RUNNING
|
|
|
030326 |
+ elif 'Insufficient Permission' in e.content:
|
|
|
030326 |
+ return OCF_ERR_PERM
|
|
|
030326 |
else:
|
|
|
030326 |
raise
|
|
|
030326 |
|
|
|
030326 |
|
|
|
030326 |
From 50dbfc3230e87b8d29163c235e6866d15fd6fc1b Mon Sep 17 00:00:00 2001
|
|
|
030326 |
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
|
|
|
030326 |
Date: Tue, 19 Jan 2021 11:50:22 +0100
|
|
|
030326 |
Subject: [PATCH 2/2] gcp-vpc-move-vip: correctly return error when no
|
|
|
030326 |
instances are returned
|
|
|
030326 |
|
|
|
030326 |
---
|
|
|
030326 |
heartbeat/gcp-vpc-move-vip.in | 20 +++++++++++++++-----
|
|
|
030326 |
1 file changed, 15 insertions(+), 5 deletions(-)
|
|
|
030326 |
|
|
|
030326 |
diff --git a/heartbeat/gcp-vpc-move-vip.in b/heartbeat/gcp-vpc-move-vip.in
|
|
|
030326 |
index e792f71d5..bbbd87b7a 100755
|
|
|
030326 |
--- a/heartbeat/gcp-vpc-move-vip.in
|
|
|
030326 |
+++ b/heartbeat/gcp-vpc-move-vip.in
|
|
|
030326 |
@@ -263,8 +263,14 @@ def get_instances_list(project, exclude):
|
|
|
030326 |
hostlist = []
|
|
|
030326 |
request = CONN.instances().aggregatedList(project=project)
|
|
|
030326 |
while request is not None:
|
|
|
030326 |
- response = request.execute()
|
|
|
030326 |
- zones = response.get('items', {})
|
|
|
030326 |
+ try:
|
|
|
030326 |
+ response = request.execute()
|
|
|
030326 |
+ zones = response.get('items', {})
|
|
|
030326 |
+ except googleapiclient.errors.HttpError as e:
|
|
|
030326 |
+ if e.resp.status == 404:
|
|
|
030326 |
+ logger.debug('get_instances_list(): no instances found')
|
|
|
030326 |
+ return ''
|
|
|
030326 |
+
|
|
|
030326 |
for zone in zones.values():
|
|
|
030326 |
for inst in zone.get('instances', []):
|
|
|
030326 |
if inst['name'] != exclude:
|
|
|
030326 |
@@ -303,9 +309,13 @@ def gcp_alias_start(alias):
|
|
|
030326 |
break
|
|
|
030326 |
|
|
|
030326 |
# Add alias IP range to localhost
|
|
|
030326 |
- add_alias(
|
|
|
030326 |
- project, my_zone, THIS_VM, alias,
|
|
|
030326 |
- os.environ.get('OCF_RESKEY_alias_range_name'))
|
|
|
030326 |
+ try:
|
|
|
030326 |
+ add_alias(
|
|
|
030326 |
+ project, my_zone, THIS_VM, alias,
|
|
|
030326 |
+ os.environ.get('OCF_RESKEY_alias_range_name'))
|
|
|
030326 |
+ except googleapiclient.errors.HttpError as e:
|
|
|
030326 |
+ if e.resp.status == 404:
|
|
|
030326 |
+ sys.exit(OCF_ERR_CONFIGURED)
|
|
|
030326 |
|
|
|
030326 |
# Verify that the IP range has been added
|
|
|
030326 |
my_aliases = get_localhost_aliases()
|