Skip to content

Commit

Permalink
Temp Bug Fix
Browse files Browse the repository at this point in the history
Signed-off-by: Dylan Orzel <dorzel@redhat.com>
  • Loading branch information
dorzel committed Jan 15, 2025
1 parent c8d6ab2 commit 25f190d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
1 change: 1 addition & 0 deletions pkg/reconciler/buildrun/buildrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions pkg/reconciler/buildrun/resources/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
21 changes: 10 additions & 11 deletions pkg/validate/tolerations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 25f190d

Please sign in to comment.