(id string, apiName string)
| 136 | } |
| 137 | |
| 138 | func (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 | } |
no test coverage detected