Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check to make sure helpers need to be killed before sending kill signal #89

Merged
merged 4 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
31 changes: 18 additions & 13 deletions sidecar/app/query/ipa.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,25 @@ def send_kill_signals(self):
for helper in settings.helpers.values():
if helper.role == self.role:
continue
finish_url = urlunparse(
status_url = urlunparse(
helper.sidecar_url._replace(
scheme="https", path=f"/stop/kill/{self.query_id}"
scheme="https", path=f"/start/{self.query_id}/status"
eriktaubeneck marked this conversation as resolved.
Show resolved Hide resolved
),
)
r = httpx.get(status_url).json()
status = Status.from_json(r)
self.logger.info(
f"Helper {helper.role} status for query {self.query_id}: {status.name}"
)
if status < Status.COMPLETE:
eriktaubeneck marked this conversation as resolved.
Show resolved Hide resolved
finish_url = urlunparse(
helper.sidecar_url._replace(
scheme="https", path=f"/stop/kill/{self.query_id}"
),
)

r = httpx.post(finish_url)
self.logger.info(f"sent post request: {r.text}")
r = httpx.post(finish_url)
self.logger.info(f"sent post request: {r.text}")
eriktaubeneck marked this conversation as resolved.
Show resolved Hide resolved

def crash(self):
super().crash()
Expand Down Expand Up @@ -261,17 +272,11 @@ def run(self):
)
while True:
r = httpx.get(url).json()
status = r.get("status")
status = Status.from_json(r)
eriktaubeneck marked this conversation as resolved.
Show resolved Hide resolved
match status:
case Status.IN_PROGRESS.name:
case Status.IN_PROGRESS:
break
case Status.KILLED.name:
self.success = False
return
case Status.NOT_FOUND.name:
self.success = False
return
case Status.CRASHED.name:
case Status.KILLED | Status.NOT_FOUND | Status.CRASHED:
self.success = False
return

Expand Down
8 changes: 8 additions & 0 deletions sidecar/app/query/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ class Status(IntEnum):
KILLED = auto()
CRASHED = auto()

@classmethod
def from_json(cls, response: dict[str, str]):
status_str = response.get("status", "")
try:
return cls[status_str]
except ValueError:
return cls.UNKNOWN


StatusChangeEvent = NamedTuple(
"StatusChangeEvent", [("status", Status), ("timestamp", float)]
Expand Down
Loading