Skip to content

Commit 3bd1d95

Browse files
author
Jan Wozniak
committed
Bug 1596440 - surface OOMKilled pod to build
1 parent ea877ac commit 3bd1d95

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

hack/build-rpms.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fi
3737
os::build::rpm::get_nvra_vars
3838

3939
OS_RPM_SPECFILE="$( find "${OS_ROOT}" -name *.spec )"
40-
OS_RPM_NAME="$( rpmspec -q --qf '%{name}\n' "${OS_RPM_SPECFILE}" | head -1 )"
40+
OS_RPM_NAME=origin
4141

4242
os::log::info "Building release RPMs for ${OS_RPM_SPECFILE} ..."
4343

pkg/build/apis/build/types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,9 @@ const (
514514
// range of build failures.
515515
StatusReasonGenericBuildFailed StatusReason = "GenericBuildFailed"
516516

517+
// StatusReasonOOMKilled indicates that the build pod was killed for memory consumption
518+
StatusReasonOOMKilled StatusReason = "OOMKilled"
519+
517520
// StatusCannotRetrieveServiceAccount is the reason associated with a failure
518521
// to look up the service account associated with the BuildConfig.
519522
StatusReasonCannotRetrieveServiceAccount StatusReason = "CannotRetrieveServiceAccount"
@@ -540,6 +543,7 @@ const (
540543
StatusMessageNoBuildContainerStatus = "The pod for this build has no container statuses indicating success or failure."
541544
StatusMessageFailedContainer = "The pod for this build has at least one container with a non-zero exit status."
542545
StatusMessageGenericBuildFailed = "Generic Build failure - check logs for details."
546+
StatusMessageOOMKilled = "Out of memory"
543547
StatusMessageUnresolvableEnvironmentVariable = "Unable to resolve build environment variable reference."
544548
StatusMessageCannotRetrieveServiceAccount = "Unable to look up the service account secrets for this build."
545549
)

pkg/build/controller/build/build_controller.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,8 @@ func (bc *BuildController) handleActiveBuild(build *buildapi.Build, pod *v1.Pod)
10061006
// soon be deleted. The build should be transitioned to the Error phase.
10071007
if pod.DeletionTimestamp != nil {
10081008
update = transitionToPhase(buildapi.BuildPhaseError, buildapi.StatusReasonBuildPodDeleted, buildapi.StatusMessageBuildPodDeleted)
1009+
} else if isOOMKilled(pod) {
1010+
update = transitionToPhase(buildapi.BuildPhaseFailed, buildapi.StatusReasonOOMKilled, buildapi.StatusMessageOOMKilled)
10091011
} else {
10101012
update = transitionToPhase(buildapi.BuildPhaseFailed, buildapi.StatusReasonGenericBuildFailed, buildapi.StatusMessageGenericBuildFailed)
10111013
}
@@ -1014,6 +1016,25 @@ func (bc *BuildController) handleActiveBuild(build *buildapi.Build, pod *v1.Pod)
10141016
return update, nil
10151017
}
10161018

1019+
func isOOMKilled(pod *v1.Pod) bool {
1020+
if pod.Status.Reason == "OOMKilled" {
1021+
return true
1022+
}
1023+
for _, c := range pod.Status.InitContainerStatuses {
1024+
terminated := c.State.Terminated
1025+
if terminated != nil && terminated.Reason == "OOMKilled" {
1026+
return true
1027+
}
1028+
}
1029+
for _, c := range pod.Status.ContainerStatuses {
1030+
terminated := c.State.Terminated
1031+
if terminated != nil && terminated.Reason == "OOMKilled" {
1032+
return true
1033+
}
1034+
}
1035+
return false
1036+
}
1037+
10171038
// handleCompletedBuild will only be called on builds that are already in a terminal phase. It is used to setup the
10181039
// completion timestamp and failure logsnippet as needed.
10191040
func (bc *BuildController) handleCompletedBuild(build *buildapi.Build, pod *v1.Pod) (*buildUpdate, error) {

0 commit comments

Comments
 (0)