(jobKey spec.JobKey)
| 163 | } |
| 164 | |
| 165 | func GetJobState(jobKey spec.JobKey) (*State, error) { |
| 166 | s3Objects, err := config.AWS.ListS3Prefix(config.ClusterConfig.Bucket, jobKey.Prefix(config.ClusterConfig.ClusterUID), false, nil, nil) |
| 167 | if err != nil { |
| 168 | return nil, errors.Wrap(err, "failed to get job state", jobKey.UserString()) |
| 169 | } |
| 170 | |
| 171 | if len(s3Objects) == 0 { |
| 172 | return nil, errors.Wrap(ErrorJobNotFound(jobKey), "failed to get job state") |
| 173 | } |
| 174 | |
| 175 | lastUpdatedMap := map[string]time.Time{} |
| 176 | for _, object := range s3Objects { |
| 177 | lastUpdatedMap[filepath.Base(*object.Key)] = *object.LastModified |
| 178 | } |
| 179 | |
| 180 | jobState := getJobStateFromFiles(jobKey, lastUpdatedMap) |
| 181 | return &jobState, nil |
| 182 | } |
| 183 | |
| 184 | func getJobStateFromFiles(jobKey spec.JobKey, lastUpdatedFileMap map[string]time.Time) State { |
| 185 | var statusCode status.JobCode |
no test coverage detected