-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reject build requests for binary builds if not providing binary inputs #9679
Conversation
1587b5d
to
868b80b
Compare
@gabemontero ptal. |
[test] |
868b80b
to
1dcb64c
Compare
Igtm (if the test failure was from the changes I missed how the changes On Friday, July 1, 2016, Ben Parees [email protected] wrote:
|
yeah appears to be a new flake, opened #9680 |
@smarterclayton can you ptal as well? i want to make sure i'm not missing something about the philosophy of binary builds. |
@@ -218,9 +218,11 @@ func (g *BuildGenerator) Instantiate(ctx kapi.Context, request *buildapi.BuildRe | |||
if err != nil { | |||
return nil, err | |||
} | |||
|
|||
if request.Binary == nil && bc.Spec.Source.Dockerfile == nil && bc.Spec.Source.Git == nil && len(bc.Spec.Source.Images) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this here and not in validation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what validation? client-side we don't even retrieve the buildconfig that i saw, so we can't do it there.
and the buildrequest object validation also doesn't currently have a need to retrieve the buildconfig object in order to do validation, it seems burdensome to introduce that call in the validation flow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(and the associated confusion of "what error do we return to a user when buildrequest validation failed because we got an spurious/temporary error retrieving the buildconfig associated with the buildrequest")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my approach allows for a nicer error message (in validation it's going to need to be a generic "everything is nil, you must specify one" message). but there's no doubt we were missing that validation, so i'll put it there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go figure, it turns out we do have that validation, but binary is not remaining nil because we copy the value from the buildconfig when creating the build. will fix that.
1dcb64c
to
c5107ed
Compare
@smarterclayton reworked, ptal. output is:
and for --from-build:
|
and yeah that means oc create operations for builds are going to see: which doesn't make a ton of sense. which is one reason it was nicer to have an error coming out of the rest endpoint. |
@smarterclayton bump |
@@ -142,7 +142,7 @@ func validateCommonSpec(spec *buildapi.CommonSpec, fldPath *field.Path) field.Er | |||
s := spec.Strategy | |||
|
|||
if s.DockerStrategy != nil && s.JenkinsPipelineStrategy == nil && spec.Source.Git == nil && spec.Source.Binary == nil && spec.Source.Dockerfile == nil && spec.Source.Images == nil { | |||
allErrs = append(allErrs, field.Invalid(fldPath.Child("source"), spec.Source, "must provide a value for at least one of source, binary, images, or dockerfile")) | |||
allErrs = append(allErrs, field.Invalid(fldPath.Child("source"), spec.Source, "must provide a value for at least one source input(git, binary, dockerfile, images). For binary builds, use --from-dir|--from-repo|--from-file")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't be sending command line instructions back from the API
eb92fd9
to
fcac803
Compare
[testextended][extended:core(starting a build using CLI)] |
@smarterclayton i am not doing checking inside the instantiate/clone code because at that point we're getting back a StatusError from the create call, which means instantiate/clone needs to:
then the instantiate/clone caller (client in this case) has to interpret the bad request error again, to present a useful error message to the user. imho the validation error being returned directly from the instantiate/clone api is sufficient for a client to do the right thing. They tried to instantiate a build, they got a validation error. |
@smarterclayton bump. |
if buildutil.IsPaused(bc) { | ||
return nil, errors.NewInternalError(&GeneratorFatalError{fmt.Sprintf("can't instantiate from BuildConfig %s/%s: BuildConfig is paused", bc.Namespace, bc.Name)}) | ||
return nil, errors.NewBadRequest(fmt.Sprintf("can't instantiate from BuildConfig %s/%s: BuildConfig is paused", bc.Namespace, bc.Name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be setting a cause on errors like this - can you open an issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what, against upstream?
d9cd307
to
b5bc3fd
Compare
if err != nil { | ||
if statusErr, ok := err.(*kerrors.StatusError); ok { | ||
if statusErr.ErrStatus.Reason == "Invalid" { | ||
for _, cause := range statusErr.ErrStatus.Details.Causes { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smarterclayton better? doesn't seem better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, just use the source field "spec.source" instead of the message (you get that separate from message). And don't check Reason against string "Invalid", check the error type against api/errors.IsInvalid
b5bc3fd
to
183e5b0
Compare
if statusErr, ok := err.(*kerrors.StatusError); ok { | ||
if kerrors.IsInvalid(statusErr) { | ||
for _, cause := range statusErr.ErrStatus.Details.Causes { | ||
if cause.Field == "spec.source" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smarterclayton how about now?
049712a
to
40bd5b6
Compare
40bd5b6
to
b13da08
Compare
LGTM |
b13da08
to
bc80045
Compare
Evaluated for origin testextended up to bc80045 |
Evaluated for origin test up to bc80045 |
continuous-integration/openshift-jenkins/testextended SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin_extended/317/) (Extended Tests: core(starting a build using CLI)) |
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/6084/) |
[merge] |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/6088/) (Image: devenv-rhel7_4572) |
Evaluated for origin merge up to bc80045 |
new output:
fixes #9261