Esempio n. 1
0
func convert_v1_BuildStatus_To_api_Build(in *BuildStatus, out *newer.Build, s conversion.Scope) error {
	out.Cancelled = in.Cancelled
	out.CompletionTimestamp = in.CompletionTimestamp
	if err := s.Convert(&in.Config, &out.Config, 0); err != nil {
		return err
	}
	out.Duration = in.Duration
	out.Message = in.Message
	out.StartTimestamp = in.StartTimestamp
	return nil
}
Esempio n. 2
0
// CancelBuild updates a build status to Cancelled, after its associated pod is deleted.
func (bc *BuildPodController) CancelBuild(build *buildapi.Build, pod *kapi.Pod) error {
	if !isBuildCancellable(build) {
		glog.V(4).Infof("Build %s/%s can be cancelled only if it has pending/running status, not %s.", build.Namespace, build.Name, build.Status)
		return nil
	}

	err := bc.PodManager.DeletePod(build.Namespace, pod)
	if err != nil && !errors.IsNotFound(err) {
		return err
	}

	glog.V(4).Infof("Build %s/%s is about to be cancelled", build.Namespace, build.Name)
	build.Status = buildapi.BuildStatusCancelled
	now := util.Now()
	build.CompletionTimestamp = &now
	if err := bc.BuildUpdater.Update(build.Namespace, build); err != nil {
		return err
	}

	glog.V(4).Infof("Build %s/%s was successfully cancelled.", build.Namespace, build.Name)
	return nil
}