Skip to content

Commit b7eca0d

Browse files
author
OpenShift Bot
authored
Merge pull request #12057 from mmilata/bz1300949-buildconfig-deletion
Merged by openshift-bot
2 parents 5d5c1e9 + 0cfb747 commit b7eca0d

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

pkg/build/api/types.go

+5
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,10 @@ const (
309309
// StatusReasonDockerBuildFailed indicates that the docker build strategy has
310310
// failed.
311311
StatusReasonDockerBuildFailed StatusReason = "DockerBuildFailed"
312+
313+
// StatusReasonBuildPodExists indicates that the build tried to create a
314+
// build pod but one was already present.
315+
StatusReasonBuildPodExists = "BuildPodExists"
312316
)
313317

314318
// NOTE: These messages might change.
@@ -326,6 +330,7 @@ const (
326330
StatusMessageFetchSourceFailed = "Failed to fetch the input source"
327331
StatusMessageCancelledBuild = "The build was cancelled by the user"
328332
StatusMessageDockerBuildFailed = "Docker build strategy has failed"
333+
StatusMessageBuildPodExists = "The pod for this build already exists and is older than the build"
329334
)
330335

331336
// BuildSource is the input used for the build.

pkg/build/controller/controller.go

+8
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,14 @@ func (bc *BuildController) nextBuildPhase(build *buildapi.Build) error {
210210
if errors.IsAlreadyExists(err) {
211211
bc.Recorder.Eventf(build, kapi.EventTypeWarning, "FailedCreate", "Pod already exists: %s/%s", podSpec.Namespace, podSpec.Name)
212212
glog.V(4).Infof("Build pod already existed: %#v", podSpec)
213+
214+
// If the existing pod was created before this build, switch to Error state.
215+
existingPod, err := bc.PodManager.GetPod(podSpec.Namespace, podSpec.Name)
216+
if err == nil && existingPod.CreationTimestamp.Before(build.CreationTimestamp) {
217+
build.Status.Phase = buildapi.BuildPhaseError
218+
build.Status.Reason = buildapi.StatusReasonBuildPodExists
219+
build.Status.Message = buildapi.StatusMessageBuildPodExists
220+
}
213221
return nil
214222
}
215223
// Log an event if the pod is not created (most likely due to quota denial).

0 commit comments

Comments
 (0)