diff --git a/pkg/reconciler/buildrun/buildrun.go b/pkg/reconciler/buildrun/buildrun.go index b5945cda9..1d37d61cb 100644 --- a/pkg/reconciler/buildrun/buildrun.go +++ b/pkg/reconciler/buildrun/buildrun.go @@ -132,6 +132,7 @@ func (r *ReconcileBuildRun) Reconcile(ctx context.Context, request reconcile.Req if getTaskRunErr != nil { if apierrors.IsNotFound(getTaskRunErr) { build = &buildv1beta1.Build{} + // BUG HERE! GetBuildObject ends up not setting build spec fields to inherit from BuildRun Spec fields correctly! if err := resources.GetBuildObject(ctx, r.client, buildRun, build); err != nil { if !resources.IsClientStatusUpdateError(err) && buildRun.Status.IsFailed(buildv1beta1.Succeeded) { return reconcile.Result{}, nil diff --git a/pkg/reconciler/buildrun/resources/build.go b/pkg/reconciler/buildrun/resources/build.go index fd0475991..0be1109d8 100644 --- a/pkg/reconciler/buildrun/resources/build.go +++ b/pkg/reconciler/buildrun/resources/build.go @@ -39,7 +39,11 @@ func GetBuildObject(ctx context.Context, client client.Client, buildRun *buildv1 build.Name = "" build.Namespace = buildRun.Namespace build.Status = buildv1beta1.BuildStatus{} + // BUG HERE: buildrun Spec fields do not get set on this object! therefore they are not actually validated! buildRun.Spec.Build.Spec.DeepCopyInto(&build.Spec) + // these fields can be specified on both Build and BuildRun objects, and still need to be validated in this case + build.Spec.NodeSelector = buildRun.Spec.NodeSelector + build.Spec.Tolerations = buildRun.Spec.Tolerations return nil } diff --git a/pkg/validate/tolerations.go b/pkg/validate/tolerations.go index 00b8043c6..281fb8629 100644 --- a/pkg/validate/tolerations.go +++ b/pkg/validate/tolerations.go @@ -46,17 +46,16 @@ func (b *TolerationsRef) ValidatePath(_ context.Context) error { b.Build.Status.Message = ptr.To(strings.Join(errs, ", ")) } // validate Effect, of which only "NoSchedule" is supported - // switch toleration.Effect { - // case "": - // // Effect was not specified, set it to the supported default - // b.Build.Spec.Tolerations[i].Effect = v1.TaintEffectNoSchedule - // case v1.TaintEffectNoSchedule: - // // Allowed value - // default: - // b.Build.Status.Reason = ptr.To(build.TolerationNotValid) - // b.Build.Status.Message = ptr.To(fmt.Sprintf("Only the '%v' toleration effect is supported.", v1.TaintEffectNoSchedule)) - // } - b.Build.Spec.Tolerations[i].Effect = v1.TaintEffectNoSchedule + switch toleration.Effect { + case "": + // Effect was not specified, set it to the supported default + b.Build.Spec.Tolerations[i].Effect = v1.TaintEffectNoSchedule + case v1.TaintEffectNoSchedule: + // Allowed value + default: + b.Build.Status.Reason = ptr.To(build.TolerationNotValid) + b.Build.Status.Message = ptr.To(fmt.Sprintf("Only the '%v' toleration effect is supported.", v1.TaintEffectNoSchedule)) + } // validate TolerationSeconds, which should not be specified if toleration.TolerationSeconds != nil {