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

Update glogging to always set level, and to respect glog.level #8924

Merged
merged 1 commit into from
May 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/build/builder/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func updateBuildRevision(c client.BuildInterface, build *api.Build, sourceInfo *
glog.V(4).Infof("Setting build revision to %#v", build.Spec.Revision.Git)
_, err := c.UpdateDetails(build)
if err != nil {
glog.Infof("error: An error occurred saving build revision: %v", err)
glog.V(0).Infof("error: An error occurred saving build revision: %v", err)
}
}

Expand Down Expand Up @@ -137,7 +137,7 @@ func execPostCommitHook(client DockerClient, postCommitSpec api.BuildPostCommitS
// Post commit hook is not set, return early.
return nil
}
glog.Infof("Running post commit hook with image %s ...", image)
glog.V(1).Infof("Running post commit hook with image %s ...", image)
glog.V(4).Infof("Post commit hook spec: %+v", postCommitSpec)

if script != "" {
Expand Down
12 changes: 6 additions & 6 deletions pkg/build/builder/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (d *DockerBuilder) Build() error {
}

if err := removeImage(d.dockerClient, buildTag); err != nil {
glog.Infof("warning: Failed to remove temporary build tag %v: %v", buildTag, err)
glog.V(0).Infof("warning: Failed to remove temporary build tag %v: %v", buildTag, err)
}

if push {
Expand All @@ -116,11 +116,11 @@ func (d *DockerBuilder) Build() error {
if authPresent {
glog.V(4).Infof("Authenticating Docker push with user %q", pushAuthConfig.Username)
}
glog.Infof("Pushing image %s ...", pushTag)
glog.V(1).Infof("Pushing image %s ...", pushTag)
Copy link
Contributor

Choose a reason for hiding this comment

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

well you've got this push as a v(1) and the other push as a v(0)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

if err := pushImage(d.dockerClient, pushTag, pushAuthConfig); err != nil {
return fmt.Errorf("Failed to push image: %v", err)
}
glog.Infof("Push successful")
glog.V(1).Infof("Push successful")
}
return nil
}
Expand All @@ -135,10 +135,10 @@ func (d *DockerBuilder) copySecrets(secrets []api.SecretBuildSource, buildDir st
return err
}
srcDir := filepath.Join(strategy.SecretBuildSourceBaseMountPath, s.Secret.Name)
glog.Infof("Copying files from the build secret %q to %q", s.Secret.Name, filepath.Clean(s.DestinationDir))
glog.V(3).Infof("Copying files from the build secret %q to %q", s.Secret.Name, filepath.Clean(s.DestinationDir))
out, err := exec.Command("cp", "-vrf", srcDir+"/.", dstDir+"/").Output()
if err != nil {
glog.Infof("Secret %q failed to copy: %q", s.Secret.Name, string(out))
glog.V(4).Infof("Secret %q failed to copy: %q", s.Secret.Name, string(out))
return err
}
// See what is copied where when debugging.
Expand Down Expand Up @@ -239,7 +239,7 @@ func (d *DockerBuilder) buildLabels(dir string) []dockerfile.KeyValue {
sourceInfo, errors = d.gitClient.GetInfo(dir)
if len(errors) > 0 {
for _, e := range errors {
glog.Infof("warning: Unable to retrieve Git info: %v", e.Error())
glog.V(0).Infof("warning: Unable to retrieve Git info: %v", e.Error())
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/build/builder/dockerutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func dockerRun(client DockerClient, createOpts docker.CreateContainerOptions, lo
removeContainer := func() {
glog.V(4).Infof("Removing container %q ...", containerName)
if err := client.RemoveContainer(docker.RemoveContainerOptions{ID: c.ID}); err != nil {
glog.Infof("warning: Failed to remove container %q: %v", containerName, err)
glog.V(0).Infof("warning: Failed to remove container %q: %v", containerName, err)
} else {
glog.V(4).Infof("Removed container %q", containerName)
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/build/builder/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func fetchSource(dockerClient DockerClient, dir string, build *api.Build, urlTim
sourceInfo, errs = gitClient.GetInfo(dir)
if len(errs) > 0 {
for _, e := range errs {
glog.Infof("error: Unable to retrieve Git info: %v", e)
glog.V(0).Infof("error: Unable to retrieve Git info: %v", e)
}
}
}
Expand Down Expand Up @@ -176,7 +176,7 @@ func extractInputBinary(in io.Reader, source *api.BinaryBuildSource, dir string)
return nil
}

glog.Infof("Receiving source from STDIN as archive ...")
glog.V(1).Infof("Receiving source from STDIN as archive ...")

cmd := exec.Command("bsdtar", "-x", "-o", "-m", "-f", "-", "-C", dir)
cmd.Stdin = in
Expand All @@ -193,7 +193,7 @@ func extractGitSource(gitClient GitClient, gitSource *api.GitBuildSource, revisi
return false, nil
}

glog.Infof("Downloading %q ...", gitSource.URI)
glog.V(0).Infof("Downloading %q ...", gitSource.URI)

// Check source URI, trying to connect to the server only if not using a proxy.
if err := checkSourceURI(gitClient, gitSource.URI, timeout); err != nil {
Expand Down Expand Up @@ -315,7 +315,7 @@ func extractSourceFromImage(dockerClient DockerClient, image, buildDir string, i
}

if !exists || forcePull {
glog.Infof("Pulling image %q ...", image)
glog.V(0).Infof("Pulling image %q ...", image)
if err := dockerClient.PullImage(docker.PullImageOptions{Repository: image}, dockerAuth); err != nil {
return fmt.Errorf("error pulling image %v: %v", image, err)
}
Expand Down
19 changes: 9 additions & 10 deletions pkg/build/builder/sti.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ type S2IBuilder struct {
func NewS2IBuilder(dockerClient DockerClient, dockerSocket string, buildsClient client.BuildInterface, build *api.Build, gitClient GitClient, cgLimits *s2iapi.CGroupLimits) *S2IBuilder {
// delegate to internal implementation passing default implementation of builderFactory and validator
return newS2IBuilder(dockerClient, dockerSocket, buildsClient, build, gitClient, runtimeBuilderFactory{}, runtimeConfigValidator{}, cgLimits)

}

// newS2IBuilder is the internal factory function to create STIBuilder based on parameters. Used for testing.
Expand Down Expand Up @@ -252,7 +251,7 @@ func (s *S2IBuilder) Build() error {
}

if err := removeImage(s.dockerClient, buildTag); err != nil {
glog.Infof("warning: Failed to remove temporary build tag %v: %v", buildTag, err)
glog.V(0).Infof("warning: Failed to remove temporary build tag %v: %v", buildTag, err)
}

if push {
Expand All @@ -262,27 +261,27 @@ func (s *S2IBuilder) Build() error {
dockercfg.PushAuthType,
)
if authPresent {
glog.Infof("Using provided push secret for pushing %s image", pushTag)
glog.V(2).Infof("Using provided push secret for pushing %s image", pushTag)
} else {
glog.Infof("No push secret provided")
glog.V(2).Infof("No push secret provided")
}
glog.Infof("Pushing %s image ...", pushTag)
glog.V(1).Infof("Pushing %s image ...", pushTag)
if err := pushImage(s.dockerClient, pushTag, pushAuthConfig); err != nil {
// write extended error message to assist in problem resolution
msg := fmt.Sprintf("Failed to push image. Response from registry is: %v", err)
if authPresent {
glog.Infof("Registry server Address: %s", pushAuthConfig.ServerAddress)
glog.Infof("Registry server User Name: %s", pushAuthConfig.Username)
glog.Infof("Registry server Email: %s", pushAuthConfig.Email)
glog.V(0).Infof("Registry server Address: %s", pushAuthConfig.ServerAddress)
glog.V(0).Infof("Registry server User Name: %s", pushAuthConfig.Username)
glog.V(0).Infof("Registry server Email: %s", pushAuthConfig.Email)
passwordPresent := "<<empty>>"
if len(pushAuthConfig.Password) > 0 {
passwordPresent = "<<non-empty>>"
}
glog.Infof("Registry server Password: %s", passwordPresent)
glog.V(0).Infof("Registry server Password: %s", passwordPresent)
}
return errors.New(msg)
}
glog.Infof("Successfully pushed %s", pushTag)
glog.V(1).Infof("Successfully pushed %s", pushTag)
}
return nil
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/util/glog/glog.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,13 @@ func (f file) Is(level int) bool {
}

func (f file) V(level int) Logger {
// only log things that glog allows
if !glog.V(glog.Level(level)) {
return None
}
// send anything above our level to glog
if level > f.level {
return Log.V(level)
return Log
}
return f
}
Expand Down