Skip to content

Fix Async API invalid status (payload/results.json) #2106

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

Merged
merged 4 commits into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
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
7 changes: 3 additions & 4 deletions async-gateway/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (s *service) CreateWorkload(id string, payload io.Reader, contentType strin
return "", err
}

statusPath := fmt.Sprintf("%s/%s/%s", prefix, id, StatusInQueue)
statusPath := fmt.Sprintf("%s/%s/status/%s", prefix, id, StatusInQueue)
log.Debug(fmt.Sprintf("setting status to %s", StatusInQueue))
if err := s.storage.Upload(statusPath, strings.NewReader(""), "text/plain"); err != nil {
return "", err
Expand Down Expand Up @@ -124,8 +124,8 @@ func (s *service) getStatus(id string) (Status, error) {
log := s.logger.With(zap.String("id", id))

// download workload status
log.Debug("checking status", zap.String("path", fmt.Sprintf("%s/%s/*", prefix, id)))
files, err := s.storage.List(fmt.Sprintf("%s/%s", prefix, id))
log.Debug("checking status", zap.String("path", fmt.Sprintf("%s/%s/status/*", prefix, id)))
files, err := s.storage.List(fmt.Sprintf("%s/%s/status", prefix, id))
if err != nil {
return "", err
}
Expand All @@ -134,7 +134,6 @@ func (s *service) getStatus(id string) (Status, error) {
status := StatusInQueue
for _, file := range files {
fileStatus := Status(file)

if !fileStatus.Valid() {
status = fileStatus
return "", fmt.Errorf("invalid workload status: %s", status)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cortex/serve/cortex_internal/lib/api/async_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def statsd(self):
return self.__statsd

def update_status(self, request_id: str, status: str):
self.storage.put_str("", f"{self.storage_path}/{request_id}/{status}")
self.storage.put_str("", f"{self.storage_path}/{request_id}/status/{status}")

def upload_result(self, request_id: str, result: Dict[str, Any]):
if not isinstance(result, dict):
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/e2e/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,12 @@ def _retriever(request_id: str):
result_response = session.get(f"{api_info['endpoint']}/{request_id}")

if result_response.status_code != HTTPStatus.OK:
content = result_response.content.decode("utf-8")
if "error" in content:
event_stopper.set()
raise RuntimeError(
f"received {result_response.status_code} status code with the following message: {content}"
)
time.sleep(poll_sleep_seconds)
continue

Expand Down