Skip to content

Commit 738efd5

Browse files
author
tymuraheiev
committed
Added namespace existence check into 'sync_secret' function
1 parent 29ecf1a commit 738efd5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/kubernetes_utils.py

+7
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,13 @@ def sync_secret(
172172
annotations = cs_metadata.get('annotations', None)
173173
labels = cs_metadata.get('labels', None)
174174

175+
try:
176+
v1.read_namespace(name=namespace)
177+
except exceptions.ApiException as e:
178+
logger.debug(f'Namespace {namespace} not found while syncing secret {sec_name}. Never mind on this rare situation it will be handled in other place.')
179+
if e.status == 404:
180+
return
181+
175182
if 'data' not in body:
176183
raise kopf.TemporaryError('Property data is missing.')
177184

0 commit comments

Comments
 (0)