Skip to content

Commit

Permalink
Merge pull request #3694 from gabemontero/issue1875
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot committed Jul 14, 2015
2 parents a1345bb + ac49969 commit e56fd7b
Show file tree
Hide file tree
Showing 17 changed files with 62 additions and 4 deletions.
7 changes: 6 additions & 1 deletion HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ the `openshift/origin-base` image which is the common parent image for all OpenS

$ hack/build-release.sh

NOTE: Only committed code is built.

Once the release has been built the official Docker images can be generated with `hack/build-images.sh`.
The resulting images can then be pushed to a Docker registry.

$ hack/build-images.sh

Note: To build the base and release images, run:
NOTE: You only need to run this script if your code changes are part of any images OpenShift runs internally
such as origin-sti-builder, origin-docker-builder, origin-deployer, etc.

To build the base and release images, run:

$ hack/build-base-images.sh

Expand Down
6 changes: 5 additions & 1 deletion docs/debugging-openshift.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ The most recent container in that list should be the one that ran your build. T

Hopefully the logs will provide some indication of what it failed (e.g. failure to find the source repository, an actual build issue, failure to push the resulting image to the docker registry, etc).

One issue seen somewhat often is not being able to resolve any hostname (for example github.com) from within running containers. If this shows up in your build logs, restart docker and then resubmit a build:
One issue seen sometimes is not being able to resolve any hostname (for example github.com) from within running containers:

E0708 17:28:07.845231 1 git.go:102] fatal: unable to access 'https://github.com/gabemontero/cakephp-ex.git/': Could not resolve host: github.com; Unknown error

If this shows up in your build logs, restart docker and then resubmit a build:

$ sudo systemctl restart docker
$ oc start-build <your build identifier>
Expand Down
4 changes: 4 additions & 0 deletions hack/build-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
# This script builds all images locally except the base and release images,
# which are handled by hack/build-base-images.sh.

# NOTE: you only need to run this script if your code changes are part of
# any images OpenShift runs internally such as origin-sti-builder, origin-docker-builder,
# origin-deployer, etc.

set -o errexit
set -o nounset
set -o pipefail
Expand Down
2 changes: 2 additions & 0 deletions hack/build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# This script generates release zips into _output/releases. It requires the openshift/origin-release
# image to be built prior to executing this command via hack/build-base-images.sh.

# NOTE: only committed code is built.

set -o errexit
set -o nounset
set -o pipefail
Expand Down
2 changes: 2 additions & 0 deletions pkg/api/deep_copy_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,7 @@ func deepCopy_api_DockerBuildStrategy(in buildapi.DockerBuildStrategy, out *buil
} else {
out.Env = nil
}
out.ForcePull = in.ForcePull
return nil
}

Expand Down Expand Up @@ -1088,6 +1089,7 @@ func deepCopy_api_SourceBuildStrategy(in buildapi.SourceBuildStrategy, out *buil
}
out.Scripts = in.Scripts
out.Incremental = in.Incremental
out.ForcePull = in.ForcePull
return nil
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/api/v1/conversion_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,7 @@ func convert_api_DockerBuildStrategy_To_v1_DockerBuildStrategy(in *buildapi.Dock
} else {
out.Env = nil
}
out.ForcePull = in.ForcePull
return nil
}

Expand Down Expand Up @@ -1334,6 +1335,7 @@ func convert_api_SourceBuildStrategy_To_v1_SourceBuildStrategy(in *buildapi.Sour
}
out.Scripts = in.Scripts
out.Incremental = in.Incremental
out.ForcePull = in.ForcePull
return nil
}

Expand Down Expand Up @@ -1769,6 +1771,7 @@ func convert_v1_DockerBuildStrategy_To_api_DockerBuildStrategy(in *buildapiv1.Do
} else {
out.Env = nil
}
out.ForcePull = in.ForcePull
return nil
}

Expand Down Expand Up @@ -1833,6 +1836,7 @@ func convert_v1_SourceBuildStrategy_To_api_SourceBuildStrategy(in *buildapiv1.So
}
out.Scripts = in.Scripts
out.Incremental = in.Incremental
out.ForcePull = in.ForcePull
return nil
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/api/v1/deep_copy_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,7 @@ func deepCopy_v1_DockerBuildStrategy(in buildapiv1.DockerBuildStrategy, out *bui
} else {
out.Env = nil
}
out.ForcePull = in.ForcePull
return nil
}

Expand Down Expand Up @@ -1069,6 +1070,7 @@ func deepCopy_v1_SourceBuildStrategy(in buildapiv1.SourceBuildStrategy, out *bui
}
out.Scripts = in.Scripts
out.Incremental = in.Incremental
out.ForcePull = in.ForcePull
return nil
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/api/v1beta3/conversion_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,7 @@ func convert_api_DockerBuildStrategy_To_v1beta3_DockerBuildStrategy(in *buildapi
} else {
out.Env = nil
}
out.ForcePull = in.ForcePull
return nil
}

Expand Down Expand Up @@ -1340,6 +1341,7 @@ func convert_api_SourceBuildStrategy_To_v1beta3_SourceBuildStrategy(in *buildapi
}
out.Scripts = in.Scripts
out.Incremental = in.Incremental
out.ForcePull = in.ForcePull
return nil
}

Expand Down Expand Up @@ -1743,6 +1745,7 @@ func convert_v1beta3_DockerBuildStrategy_To_api_DockerBuildStrategy(in *buildapi
} else {
out.Env = nil
}
out.ForcePull = in.ForcePull
return nil
}

Expand Down Expand Up @@ -1807,6 +1810,7 @@ func convert_v1beta3_SourceBuildStrategy_To_api_SourceBuildStrategy(in *buildapi
}
out.Scripts = in.Scripts
out.Incremental = in.Incremental
out.ForcePull = in.ForcePull
return nil
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/api/v1beta3/deep_copy_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,7 @@ func deepCopy_v1beta3_DockerBuildStrategy(in buildapiv1beta3.DockerBuildStrategy
} else {
out.Env = nil
}
out.ForcePull = in.ForcePull
return nil
}

Expand Down Expand Up @@ -1077,6 +1078,7 @@ func deepCopy_v1beta3_SourceBuildStrategy(in buildapiv1beta3.SourceBuildStrategy
}
out.Scripts = in.Scripts
out.Incremental = in.Incremental
out.ForcePull = in.ForcePull
return nil
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/build/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ type DockerBuildStrategy struct {

// Env contains additional environment variables you want to pass into a builder container
Env []kapi.EnvVar

// ForcePull describes if the builder should pull the images from registry prior to building.
ForcePull bool
}

// SourceBuildStrategy defines input parameters specific to an Source build.
Expand All @@ -284,6 +287,9 @@ type SourceBuildStrategy struct {

// Incremental flag forces the Source build to do incremental builds if true.
Incremental bool

// ForcePull describes if the builder should pull the images from registry prior to building.
ForcePull bool
}

// BuildOutput is input to a build strategy and describes the Docker image that the strategy
Expand Down
6 changes: 6 additions & 0 deletions pkg/build/api/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ type DockerBuildStrategy struct {

// Env contains additional environment variables you want to pass into a builder container
Env []kapi.EnvVar `json:"env,omitempty" description:"additional environment variables you want to pass into a builder container"`

// ForcePull describes if the builder should pull the images from registry prior to building.
ForcePull bool `json:"forcePull,omitempty" description:"forces the source build to pull the image if true"`
}

// SourceBuildStrategy defines input parameters specific to an Source build.
Expand All @@ -273,6 +276,9 @@ type SourceBuildStrategy struct {

// Incremental flag forces the Source build to do incremental builds if true.
Incremental bool `json:"incremental,omitempty" description:"forces the source build to do incremental builds if true"`

// ForcePull describes if the builder should pull the images from registry prior to building.
ForcePull bool `json:"forcePull,omitempty" description:"forces the source build to pull the image if true"`
}

// BuildOutput is input to a build strategy and describes the Docker image that the strategy
Expand Down
6 changes: 6 additions & 0 deletions pkg/build/api/v1beta3/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ type DockerBuildStrategy struct {

// Env contains additional environment variables you want to pass into a builder container
Env []kapi.EnvVar `json:"env,omitempty" description:"additional environment variables you want to pass into a builder container"`

// ForcePull describes if the builder should pull the images from registry prior to building.
ForcePull bool `json:"forcePull,omitempty" description:"forces the source build to pull the image if true"`
}

// SourceBuildStrategy defines input parameters specific to an Source build.
Expand All @@ -264,6 +267,9 @@ type SourceBuildStrategy struct {

// Incremental flag forces the Source build to do incremental builds if true.
Incremental bool `json:"incremental,omitempty"`

// ForcePull describes if the builder should pull the images from registry prior to building.
ForcePull bool `json:"forcePull,omitempty" description:"forces the source build to pull the image if true"`
}

// BuildOutput is input to a build strategy and describes the Docker image that the strategy
Expand Down
1 change: 1 addition & 0 deletions pkg/build/builder/cmd/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func run(builderFactory factoryFunc, scmAuths []scmauth.SCMAuth) {
glog.Fatalf("Error obtaining docker client: %v", err)
}
buildStr := os.Getenv("BUILD")
glog.V(4).Infof("$BUILD env var is %s \n", buildStr)
build := api.Build{}
if err := latest.Codec.DecodeInto([]byte(buildStr), &build); err != nil {
glog.Fatalf("Unable to parse build: %v", err)
Expand Down
4 changes: 3 additions & 1 deletion pkg/build/builder/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,15 +412,17 @@ func (d *DockerBuilder) setupPullSecret() (*docker.AuthConfigurations, error) {
// dockerBuild performs a docker build on the source that has been retrieved
func (d *DockerBuilder) dockerBuild(dir string) error {
var noCache bool
var forcePull bool
if d.build.Spec.Strategy.DockerStrategy != nil {
if d.build.Spec.Source.ContextDir != "" {
dir = filepath.Join(dir, d.build.Spec.Source.ContextDir)
}
noCache = d.build.Spec.Strategy.DockerStrategy.NoCache
forcePull = d.build.Spec.Strategy.DockerStrategy.ForcePull
}
auth, err := d.setupPullSecret()
if err != nil {
return err
}
return buildImage(d.dockerClient, dir, noCache, d.build.Spec.Output.To.Name, d.tar, auth)
return buildImage(d.dockerClient, dir, noCache, d.build.Spec.Output.To.Name, d.tar, auth, forcePull)
}
3 changes: 2 additions & 1 deletion pkg/build/builder/dockerutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func removeImage(client DockerClient, name string) error {
}

// buildImage invokes a docker build on a particular directory
func buildImage(client DockerClient, dir string, noCache bool, tag string, tar tar.Tar, pullAuth *docker.AuthConfigurations) error {
func buildImage(client DockerClient, dir string, noCache bool, tag string, tar tar.Tar, pullAuth *docker.AuthConfigurations, forcePull bool) error {
tarFile, err := tar.CreateTarFile("", dir)
if err != nil {
return err
Expand All @@ -75,6 +75,7 @@ func buildImage(client DockerClient, dir string, noCache bool, tag string, tar t
OutputStream: os.Stdout,
InputStream: tarStream,
NoCache: noCache,
Pull: forcePull,
}
if pullAuth != nil {
opts.AuthConfigs = *pullAuth
Expand Down
1 change: 1 addition & 0 deletions pkg/build/builder/sti.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func (s *STIBuilder) Build() error {
ScriptsURL: s.build.Spec.Strategy.SourceStrategy.Scripts,
Environment: getBuildEnvVars(s.build),
Incremental: s.build.Spec.Strategy.SourceStrategy.Incremental,
ForcePull: s.build.Spec.Strategy.SourceStrategy.ForcePull,
}
if s.build.Spec.Revision != nil && s.build.Spec.Revision.Git != nil &&
s.build.Spec.Revision.Git.Commit != "" {
Expand Down
6 changes: 6 additions & 0 deletions pkg/cmd/cli/describe/describer.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ func describeSourceStrategy(s *buildapi.SourceBuildStrategy, out *tabwriter.Writ
if s.Incremental {
formatString(out, "Incremental Build", "yes")
}
if s.ForcePull {
formatString(out, "Force Pull", "yes")
}
}

func describeDockerStrategy(s *buildapi.DockerBuildStrategy, out *tabwriter.Writer) {
Expand All @@ -258,6 +261,9 @@ func describeDockerStrategy(s *buildapi.DockerBuildStrategy, out *tabwriter.Writ
if s.NoCache {
formatString(out, "No Cache", "true")
}
if s.ForcePull {
formatString(out, "Force Pull", "true")
}
}

func describeCustomStrategy(s *buildapi.CustomBuildStrategy, out *tabwriter.Writer) {
Expand Down

0 comments on commit e56fd7b

Please sign in to comment.