Skip to content

Commit 0aed7a9

Browse files
committed
Merge branch 'release-v5.8.12'
2 parents 683b37e + df0331c commit 0aed7a9

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

.github/workflows/main.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ jobs:
144144
- name: Build & Push Multi-Platform Container
145145
uses: docker/build-push-action@v2
146146
with:
147-
context: "{{defaultContext}}" # build context is workspace so we can copy artifacts from ./dist/
148-
file: docker/Dockerfile
147+
context: ${{ github.workspace }} # build context is workspace so we can copy artifacts from ./dist/
148+
file: ${{ github.workspace }}/docker/Dockerfile
149149
builder: ${{ steps.buildx.outputs.name }}
150150
platforms: linux/amd64,linux/arm64
151151
push: true

netfoundry/network.py

+28-28
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import logging
55
import re
66
import time
7+
from requests.exceptions import HTTPError, JSONDecodeError
78

89
from netfoundry.exceptions import UnknownResourceType, NetworkBoundaryViolation
910

@@ -597,17 +598,12 @@ def create_resource(self, type: str, post: dict, wait: int = 30, sleep: int = 2,
597598
headers=headers,
598599
json=post
599600
)
600-
response_code = response.status_code
601-
except Exception as e:
602-
raise RuntimeError(f"error POST to {self.audience}core/v2/{type}, caught {e}")
603-
604-
if response_code in [STATUS_CODES.codes.OK, STATUS_CODES.codes.ACCEPTED]:
605-
try:
606-
resource = response.json()
607-
except ValueError as e:
608-
raise RuntimeError(f"failed to load JSON from POST response, caught {e}")
601+
response.raise_for_status()
602+
except HTTPError as e:
603+
logging.error(f"failed POST to create resource, caught {e.response.text}")
604+
exit(1)
609605
else:
610-
raise RuntimeError(f"got unexpected HTTP code {STATUS_CODES._codes[response_code][0].upper()} ({response_code}) for post: {json.dumps(post, indent=2)}")
606+
resource = response.json()
611607

612608
if resource.get('_links') and resource['_links'].get('process-executions'):
613609
_links = resource['_links'].get('process-executions')
@@ -1955,25 +1951,29 @@ def delete_resource(self, type: str, id: str = None, wait: int = 0, sleep: int =
19551951
if response_code not in expected_responses:
19561952
raise RuntimeError(f"got unexpected HTTP code {STATUS_CODES._codes[response_code][0].upper()} ({response_code}) and response {response.text}")
19571953
else:
1958-
resource = response.json()
1959-
1960-
if resource.get('_links') and resource['_links'].get('process-executions'):
1961-
_links = resource['_links'].get('process-executions')
1962-
if isinstance(_links, list):
1963-
process_id = _links[0]['href'].split('/')[6]
1964-
else:
1965-
process_id = _links['href'].split('/')[6]
1966-
if wait:
1967-
self.wait_for_statuses(expected_statuses=RESOURCES["process-executions"].status_symbols['complete'], type="process-executions", id=process_id, wait=wait, sleep=sleep)
1968-
return(True)
1969-
else: # only wait for the process to start, not finish, or timeout
1970-
self.wait_for_statuses(expected_statuses=RESOURCES['process-executions'].status_symbols['progress'] + RESOURCES['process-executions'].status_symbols['complete'], type="process-executions", id=process_id, wait=9, sleep=2)
1954+
try:
1955+
resource = response.json()
1956+
except JSONDecodeError as e:
1957+
logging.debug("ignoring {e}")
19711958
return(True)
1972-
elif wait:
1973-
logging.warning("unable to wait for async complete because response did not provide a process execution id")
1974-
return(False)
1975-
else:
1976-
return(True)
1959+
else:
1960+
if resource.get('_links') and resource['_links'].get('process-executions'):
1961+
_links = resource['_links'].get('process-executions')
1962+
if isinstance(_links, list):
1963+
process_id = _links[0]['href'].split('/')[6]
1964+
else:
1965+
process_id = _links['href'].split('/')[6]
1966+
if wait:
1967+
self.wait_for_statuses(expected_statuses=RESOURCES["process-executions"].status_symbols['complete'], type="process-executions", id=process_id, wait=wait, sleep=sleep)
1968+
return(True)
1969+
else: # only wait for the process to start, not finish, or timeout
1970+
self.wait_for_statuses(expected_statuses=RESOURCES['process-executions'].status_symbols['progress'] + RESOURCES['process-executions'].status_symbols['complete'], type="process-executions", id=process_id, wait=9, sleep=2)
1971+
return(True)
1972+
elif wait:
1973+
logging.warning("unable to wait for async complete because response did not provide a process execution id")
1974+
return(False)
1975+
else:
1976+
return(True)
19771977

19781978

19791979
class Networks:

0 commit comments

Comments
 (0)