Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def deploy_function(self, overwrite_function_if_exist: bool, body: dict[str, Any
else:
url = self.get_conn().host + self.DEPLOY_FUNCTION
self.log.info("Deploying function %s", url)
response = requests.post(url, body)
timeout = int(self.get_conn().extra_dejson.get("timeout", 60))
response = requests.post(url, body, timeout=timeout)
if response.status_code != OK_STATUS_CODE:
self.log.error("Response status %d", response.status_code)
self.log.error("Failed to deploy")
Expand All @@ -82,7 +83,8 @@ def invoke_async_function(self, body: dict[str, Any]) -> None:
"""Invoke function asynchronously."""
url = self.get_conn().host + self.INVOKE_ASYNC_FUNCTION + self.function_name
self.log.info("Invoking function asynchronously %s", url)
response = requests.post(url, body)
timeout = int(self.get_conn().extra_dejson.get("timeout", 60))
response = requests.post(url, body, timeout=timeout)
if response.ok:
self.log.info("Invoked %s", self.function_name)
else:
Expand All @@ -93,7 +95,8 @@ def invoke_function(self, body: dict[str, Any]) -> None:
"""Invoke function synchronously. This will block until function completes and returns."""
url = self.get_conn().host + self.INVOKE_FUNCTION + self.function_name
self.log.info("Invoking function synchronously %s", url)
response = requests.post(url, body)
timeout = int(self.get_conn().extra_dejson.get("timeout", 60))
response = requests.post(url, body, timeout=timeout)
if response.ok:
self.log.info("Invoked %s", self.function_name)
self.log.info("Response code %s", response.status_code)
Expand All @@ -106,7 +109,8 @@ def update_function(self, body: dict[str, Any]) -> None:
"""Update OpenFaaS function."""
url = self.get_conn().host + self.UPDATE_FUNCTION
self.log.info("Updating function %s", url)
response = requests.put(url, body)
timeout = int(self.get_conn().extra_dejson.get("timeout", 60))
response = requests.put(url, body, timeout=timeout)
if response.status_code != OK_STATUS_CODE:
self.log.error("Response status %d", response.status_code)
self.log.error("Failed to update response %s", response.content.decode("utf-8"))
Expand All @@ -116,8 +120,9 @@ def update_function(self, body: dict[str, Any]) -> None:
def does_function_exist(self) -> bool:
"""Whether OpenFaaS function exists or not."""
url = self.get_conn().host + self.GET_FUNCTION + self.function_name
timeout = int(self.get_conn().extra_dejson.get("timeout", 60))

response = requests.get(url)
response = requests.get(url, timeout=timeout)
if response.ok:
return True
self.log.error("Failed to find function %s", self.function_name)
Expand Down