Skip to content
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

Preventing build from inheriting master log level #9905

Merged
merged 1 commit into from
Aug 5, 2016
Merged

Preventing build from inheriting master log level #9905

merged 1 commit into from
Aug 5, 2016

Conversation

jupierce
Copy link
Contributor

@jupierce jupierce commented Jul 18, 2016

Fixes #8738
This implementation:

  • Prevents builds from inheriting the logging level of the master
  • Does not break any existing use of BuildDefaults (and does not change how proxy information is managed)
  • Ultimate default for builder is --loglevel=1 . This can be overridden multiple ways. In order of decreasing precedence:
    • Specifying --build-loglevel on start-build (except on binary builds, which has always been the case since the function relies on env variables)
    • BUILD_LOGLEVEL in buildconfig
    • BuildDefaults/env/BUILD_LOGLEVEL variable in master-config.

Example master-config entry:

kubernetesMasterConfig:
  admissionConfig:
    pluginConfig:
      BuildDefaults:
        configuration:
          apiVersion: v1
          kind: BuildDefaultsConfig
          env:
          - name: "BUILD_LOGLEVEL"
            value: "5"

@jupierce
Copy link
Contributor Author

Commit also includes minor modifications of sti -> s2i

@jupierce
Copy link
Contributor Author

@jupierce
Copy link
Contributor Author

For reference, the previous behavior was to apply the BUILD_LOGLEVEL at build pod creation time. The application was achieved by setting args=--loglevel=## directly in the build pod (e.g. https://github.com/openshift/origin/pull/9905/files#diff-5c9f2bf12ec684975c1fd68247f951dbL85).

As @csrwng points out in the issue, this means the BuildDefaults' env variables were too late to the party to affect logging since they are merged in after the pod is defined (and the loglevel already established as a pod/spec/args entry). I could have chosen to have the BuildDefaults plugin inspect and potentially modify the --loglevel arg in the pod definition, but this would have led to relatively complexity parsing code and, more importantly, established three areas of code all attempting to manage this one argument.

Instead, I moved the full responsibility of setting the loglevel to the BuildDefaults admission plugin.

@jupierce
Copy link
Contributor Author

[test]

@bparees
Copy link
Contributor

bparees commented Jul 18, 2016

Specifying --build-loglevel on start-build (except on binary builds, which has always been the case since the function relies on env variables)

binary builds still create build pods, why can't they set this env variable on the build pod that is being created?

err = applyBuildLogLevel(build, pod)
if err != nil {
return admission.NewForbidden(a, fmt.Errorf("unable to set loglevel in pod: %v", err))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be in its own function? SetBuild is for setting the BUILD env variable w/ the build json definition.

@jupierce
Copy link
Contributor Author

@bparees I had the same reaction since it seemed heavy handed. It is an architectural implication of the REST calls.

POST https://10.13.137.126:8443/oapi/v1/namespaces/default/buildconfigs/test/instantiatebinary?asFile=Dockerfile&name=test&namespace=default

vs non-binary:

 Request Body: {"kind":"BuildRequest","apiVersion":"v1","metadata":{"name":"ruby-hello-world","creationTimestamp":null},"env":[**{"name":"BUILD_LOGLEVEL","value":"17"}**],"triggeredBy":[{"message":"Manually triggered"}]}
POST https://10.13.137.126:8443/oapi/v1/namespaces/default/buildconfigs/ruby-hello-world/instantiate

And intentionally codified:
https://github.com/openshift/origin/blob/master/pkg/cmd/cli/cmd/startbuild.go#L284

@bparees
Copy link
Contributor

bparees commented Jul 18, 2016

@jupierce hm. I guess since the binaryinstantiate POST body is the files being sent in, there is nowhere to provide a request object that defines the log level for the build request. (unless we added support for query parameters)

@jupierce
Copy link
Contributor Author

@bparees Do we not support multipart form data?

@bparees
Copy link
Contributor

bparees commented Jul 18, 2016

@bparees Do we not support multipart form data?

I'm not actually sure.

@jupierce
Copy link
Contributor Author

jupierce commented Jul 18, 2016

New commit:

  • Fixes instances of BUILD_LOGLEVEL being out of place in testdata (unrelated to this Issue; just stemming the tide of copy and paste errors)
  • Sets uberdefault for build loglevel == 0
  • Adds unit test for new approach
  • Adds extended test for buildconfig BUILD_LOGLEVEL testing
  • Method extraction from SetBuild

@jupierce
Copy link
Contributor Author

[testextended][extended:core(BUILD_LOGLEVEL)]

@bparees
Copy link
Contributor

bparees commented Jul 18, 2016

lgtm pending passing tests.

@bparees
Copy link
Contributor

bparees commented Jul 18, 2016

[testextended][extended:core(builds)]

@bparees
Copy link
Contributor

bparees commented Jul 19, 2016

--- FAIL: TestSetBuildLogLevel (0.00s)
    buildpodutil_test.go:102: Build pod loglevel was not transferred from BUILD_LOGLEVEL environment

@jupierce
Copy link
Contributor Author

@bparees govet bombing on files I haven't changed...?

@bparees
Copy link
Contributor

bparees commented Jul 19, 2016

@jupierce known flake issue w/ travis, don't worry about it.

and the jenkins failures are yum repos you also can't do anything about.

i'll kick the travis test to run again, but the failure doesn't really matter.

@jupierce
Copy link
Contributor Author

[test]

@stevekuznetsov
Copy link
Contributor

re[test]

1 similar comment
@jupierce
Copy link
Contributor Author

jupierce commented Aug 2, 2016

re[test]

@jupierce
Copy link
Contributor Author

jupierce commented Aug 2, 2016

@bparees Just to get back on your radar.

fmt.Fprintf(g.GinkgoWriter, "\nbuild log:\n%s\n", buildLog)
o.Expect(err).NotTo(o.HaveOccurred())

g.By(fmt.Sprintf("verifying the build output is verbose"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is not verbose?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right, thanks. The correction actually applies to the subsequent test spec "BUILD_LOGLEVEL in buildconfig can be overridden by build-loglevel".

@bparees
Copy link
Contributor

bparees commented Aug 2, 2016

one nit and lgtm

@bparees
Copy link
Contributor

bparees commented Aug 2, 2016

(assuming tests start passing of course :) )

@bparees
Copy link
Contributor

bparees commented Aug 2, 2016

lgtm, will merge on passing extended tests

@openshift-bot
Copy link
Contributor

Evaluated for origin testextended up to fee7e4d

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/testextended SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin_extended/399/) (Extended Tests: core(builds), core(BUILD_LOGLEVEL))

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to fee7e4d

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/7523/)

@jupierce
Copy link
Contributor Author

jupierce commented Aug 5, 2016

@bparees All clear.

@bparees
Copy link
Contributor

bparees commented Aug 5, 2016

[merge]

@openshift-bot
Copy link
Contributor

openshift-bot commented Aug 5, 2016

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/7599/) (Image: devenv-rhel7_4770)

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to fee7e4d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants