cloudapi: add build job dependency checks
If an osbuild or koji-osbuild job has failed, add a check to see if it is a result of the build jobs dependencies and return the dependency failure job error furthest up the chain of errors & add this error to the details filed of the build job error.
This commit is contained in:
parent
596464e8a2
commit
e31fb36d65
3 changed files with 30 additions and 21 deletions
|
|
@ -61,6 +61,7 @@ const (
|
|||
ErrorGettingDepsolveJobStatus ServiceErrorCode = 1013
|
||||
ErrorDepsolveJobCanceled ServiceErrorCode = 1014
|
||||
ErrorUnexpectedNumberOfImageBuilds ServiceErrorCode = 1015
|
||||
ErrorGettingBuildDependencyStatus ServiceErrorCode = 1016
|
||||
|
||||
// Errors contained within this file
|
||||
ErrorUnspecified ServiceErrorCode = 10000
|
||||
|
|
@ -126,6 +127,7 @@ func getServiceErrors() serviceErrors {
|
|||
serviceError{ErrorGettingDepsolveJobStatus, http.StatusInternalServerError, "Unable to get depsolve job status"},
|
||||
serviceError{ErrorDepsolveJobCanceled, http.StatusInternalServerError, "Depsolve job was cancelled"},
|
||||
serviceError{ErrorUnexpectedNumberOfImageBuilds, http.StatusInternalServerError, "Compose has unexpected number of image builds"},
|
||||
serviceError{ErrorGettingBuildDependencyStatus, http.StatusInternalServerError, "Error checking status of build job dependencies"},
|
||||
|
||||
serviceError{ErrorUnspecified, http.StatusInternalServerError, "Unspecified internal error "},
|
||||
serviceError{ErrorNotHTTPError, http.StatusInternalServerError, "Error is not an instance of HTTPError"},
|
||||
|
|
|
|||
|
|
@ -513,11 +513,18 @@ func (h *apiHandlers) GetComposeStatus(ctx echo.Context, id string) error {
|
|||
|
||||
if jobType == "osbuild" {
|
||||
var result worker.OSBuildJobResult
|
||||
status, _, err := h.server.workers.OSBuildJobStatus(jobId, &result)
|
||||
status, deps, err := h.server.workers.OSBuildJobStatus(jobId, &result)
|
||||
if err != nil {
|
||||
return HTTPError(ErrorMalformedOSBuildJobResult)
|
||||
}
|
||||
|
||||
if result.JobError != nil && result.JobError.HasDependencyError() {
|
||||
err = h.server.workers.CheckBuildDependencies(deps[0], result.JobError)
|
||||
if err != nil {
|
||||
return HTTPError(ErrorGettingBuildDependencyStatus)
|
||||
}
|
||||
}
|
||||
|
||||
var us *UploadStatus
|
||||
if result.TargetResults != nil {
|
||||
// Only single upload target is allowed, therefore only a single upload target result is allowed as well
|
||||
|
|
@ -598,10 +605,16 @@ func (h *apiHandlers) GetComposeStatus(ctx echo.Context, id string) error {
|
|||
var buildJobStatuses []ImageStatus
|
||||
for i := 1; i < len(deps); i++ {
|
||||
var buildJobResult worker.OSBuildKojiJobResult
|
||||
buildJobStatus, _, err := h.server.workers.OSBuildKojiJobStatus(deps[i], &buildJobResult)
|
||||
buildJobStatus, buildDeps, err := h.server.workers.OSBuildKojiJobStatus(deps[i], &buildJobResult)
|
||||
if err != nil {
|
||||
return HTTPError(ErrorMalformedOSBuildJobResult)
|
||||
}
|
||||
if buildJobResult.JobError != nil && buildJobResult.JobError.HasDependencyError() {
|
||||
err = h.server.workers.CheckBuildDependencies(buildDeps[1], buildJobResult.JobError)
|
||||
if err != nil {
|
||||
return HTTPError(ErrorGettingBuildDependencyStatus)
|
||||
}
|
||||
}
|
||||
buildJobResults = append(buildJobResults, buildJobResult)
|
||||
buildJobStatuses = append(buildJobStatuses, ImageStatus{
|
||||
Status: imageStatusFromKojiJobStatus(buildJobStatus, &initResult, &buildJobResult),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue