MCPcopy
hub / github.com/cortexlabs/cortex / getStatus

Method getStatus

pkg/async-gateway/service.go:138–171  ·  view source on GitHub ↗
(id string, apiName string)

Source from the content-addressed store, hash-verified

136}
137
138func (s *service) getStatus(id string, apiName string) (async.Status, error) {
139 prefix := async.StoragePath(s.clusterUID, apiName)
140 log := s.logger.With(zap.String("id", id))
141
142 // download workload status
143 statusPrefixPath := async.StatusPrefixPath(prefix, id)
144 log.Debug("checking status", zap.String("path", statusPrefixPath))
145 files, err := s.storage.List(statusPrefixPath)
146 if err != nil {
147 return "", err
148 }
149 if len(files) == 0 {
150 return async.StatusNotFound, nil
151 }
152
153 // determine request status
154 st := async.StatusInQueue
155 for _, file := range files {
156 fileStatus := async.Status(file)
157 if !fileStatus.Valid() {
158 st = fileStatus
159 return "", fmt.Errorf("invalid workload status: %s", st)
160 }
161 if fileStatus == async.StatusInProgress {
162 st = fileStatus
163 }
164 if fileStatus == async.StatusCompleted || fileStatus == async.StatusFailed {
165 st = fileStatus
166 break
167 }
168 }
169
170 return st, nil
171}

Callers 1

GetWorkloadMethod · 0.95

Calls 7

StoragePathFunction · 0.92
StatusPrefixPathFunction · 0.92
StatusTypeAlias · 0.92
ValidMethod · 0.80
ErrorfMethod · 0.80
ListMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected