Skip to content

Commit e56fd7b

Browse files
author
OpenShift Bot
committed
Merge pull request #3694 from gabemontero/issue1875
Merged by openshift-bot
2 parents a1345bb + ac49969 commit e56fd7b

17 files changed

+62
-4
lines changed

HACKING.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@ the `openshift/origin-base` image which is the common parent image for all OpenS
1010

1111
$ hack/build-release.sh
1212

13+
NOTE: Only committed code is built.
14+
1315
Once the release has been built the official Docker images can be generated with `hack/build-images.sh`.
1416
The resulting images can then be pushed to a Docker registry.
1517

1618
$ hack/build-images.sh
1719

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

2025
$ hack/build-base-images.sh
2126

docs/debugging-openshift.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ The most recent container in that list should be the one that ran your build. T
5757

5858
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).
5959

60-
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:
60+
One issue seen sometimes is not being able to resolve any hostname (for example github.com) from within running containers:
61+
62+
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
63+
64+
If this shows up in your build logs, restart docker and then resubmit a build:
6165

6266
$ sudo systemctl restart docker
6367
$ oc start-build <your build identifier>

hack/build-images.sh

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
# This script builds all images locally except the base and release images,
44
# which are handled by hack/build-base-images.sh.
55

6+
# NOTE: you only need to run this script if your code changes are part of
7+
# any images OpenShift runs internally such as origin-sti-builder, origin-docker-builder,
8+
# origin-deployer, etc.
9+
610
set -o errexit
711
set -o nounset
812
set -o pipefail

hack/build-release.sh

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# This script generates release zips into _output/releases. It requires the openshift/origin-release
44
# image to be built prior to executing this command via hack/build-base-images.sh.
55

6+
# NOTE: only committed code is built.
7+
68
set -o errexit
79
set -o nounset
810
set -o pipefail

pkg/api/deep_copy_generated.go

+2
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,7 @@ func deepCopy_api_DockerBuildStrategy(in buildapi.DockerBuildStrategy, out *buil
10311031
} else {
10321032
out.Env = nil
10331033
}
1034+
out.ForcePull = in.ForcePull
10341035
return nil
10351036
}
10361037

@@ -1088,6 +1089,7 @@ func deepCopy_api_SourceBuildStrategy(in buildapi.SourceBuildStrategy, out *buil
10881089
}
10891090
out.Scripts = in.Scripts
10901091
out.Incremental = in.Incremental
1092+
out.ForcePull = in.ForcePull
10911093
return nil
10921094
}
10931095

pkg/api/v1/conversion_generated.go

+4
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,7 @@ func convert_api_DockerBuildStrategy_To_v1_DockerBuildStrategy(in *buildapi.Dock
12701270
} else {
12711271
out.Env = nil
12721272
}
1273+
out.ForcePull = in.ForcePull
12731274
return nil
12741275
}
12751276

@@ -1334,6 +1335,7 @@ func convert_api_SourceBuildStrategy_To_v1_SourceBuildStrategy(in *buildapi.Sour
13341335
}
13351336
out.Scripts = in.Scripts
13361337
out.Incremental = in.Incremental
1338+
out.ForcePull = in.ForcePull
13371339
return nil
13381340
}
13391341

@@ -1769,6 +1771,7 @@ func convert_v1_DockerBuildStrategy_To_api_DockerBuildStrategy(in *buildapiv1.Do
17691771
} else {
17701772
out.Env = nil
17711773
}
1774+
out.ForcePull = in.ForcePull
17721775
return nil
17731776
}
17741777

@@ -1833,6 +1836,7 @@ func convert_v1_SourceBuildStrategy_To_api_SourceBuildStrategy(in *buildapiv1.So
18331836
}
18341837
out.Scripts = in.Scripts
18351838
out.Incremental = in.Incremental
1839+
out.ForcePull = in.ForcePull
18361840
return nil
18371841
}
18381842

pkg/api/v1/deep_copy_generated.go

+2
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,7 @@ func deepCopy_v1_DockerBuildStrategy(in buildapiv1.DockerBuildStrategy, out *bui
10121012
} else {
10131013
out.Env = nil
10141014
}
1015+
out.ForcePull = in.ForcePull
10151016
return nil
10161017
}
10171018

@@ -1069,6 +1070,7 @@ func deepCopy_v1_SourceBuildStrategy(in buildapiv1.SourceBuildStrategy, out *bui
10691070
}
10701071
out.Scripts = in.Scripts
10711072
out.Incremental = in.Incremental
1073+
out.ForcePull = in.ForcePull
10721074
return nil
10731075
}
10741076

pkg/api/v1beta3/conversion_generated.go

+4
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,7 @@ func convert_api_DockerBuildStrategy_To_v1beta3_DockerBuildStrategy(in *buildapi
12761276
} else {
12771277
out.Env = nil
12781278
}
1279+
out.ForcePull = in.ForcePull
12791280
return nil
12801281
}
12811282

@@ -1340,6 +1341,7 @@ func convert_api_SourceBuildStrategy_To_v1beta3_SourceBuildStrategy(in *buildapi
13401341
}
13411342
out.Scripts = in.Scripts
13421343
out.Incremental = in.Incremental
1344+
out.ForcePull = in.ForcePull
13431345
return nil
13441346
}
13451347

@@ -1743,6 +1745,7 @@ func convert_v1beta3_DockerBuildStrategy_To_api_DockerBuildStrategy(in *buildapi
17431745
} else {
17441746
out.Env = nil
17451747
}
1748+
out.ForcePull = in.ForcePull
17461749
return nil
17471750
}
17481751

@@ -1807,6 +1810,7 @@ func convert_v1beta3_SourceBuildStrategy_To_api_SourceBuildStrategy(in *buildapi
18071810
}
18081811
out.Scripts = in.Scripts
18091812
out.Incremental = in.Incremental
1813+
out.ForcePull = in.ForcePull
18101814
return nil
18111815
}
18121816

pkg/api/v1beta3/deep_copy_generated.go

+2
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,7 @@ func deepCopy_v1beta3_DockerBuildStrategy(in buildapiv1beta3.DockerBuildStrategy
10201020
} else {
10211021
out.Env = nil
10221022
}
1023+
out.ForcePull = in.ForcePull
10231024
return nil
10241025
}
10251026

@@ -1077,6 +1078,7 @@ func deepCopy_v1beta3_SourceBuildStrategy(in buildapiv1beta3.SourceBuildStrategy
10771078
}
10781079
out.Scripts = in.Scripts
10791080
out.Incremental = in.Incremental
1081+
out.ForcePull = in.ForcePull
10801082
return nil
10811083
}
10821084

pkg/build/api/types.go

+6
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ type DockerBuildStrategy struct {
263263

264264
// Env contains additional environment variables you want to pass into a builder container
265265
Env []kapi.EnvVar
266+
267+
// ForcePull describes if the builder should pull the images from registry prior to building.
268+
ForcePull bool
266269
}
267270

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

285288
// Incremental flag forces the Source build to do incremental builds if true.
286289
Incremental bool
290+
291+
// ForcePull describes if the builder should pull the images from registry prior to building.
292+
ForcePull bool
287293
}
288294

289295
// BuildOutput is input to a build strategy and describes the Docker image that the strategy

pkg/build/api/v1/types.go

+6
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ type DockerBuildStrategy struct {
252252

253253
// Env contains additional environment variables you want to pass into a builder container
254254
Env []kapi.EnvVar `json:"env,omitempty" description:"additional environment variables you want to pass into a builder container"`
255+
256+
// ForcePull describes if the builder should pull the images from registry prior to building.
257+
ForcePull bool `json:"forcePull,omitempty" description:"forces the source build to pull the image if true"`
255258
}
256259

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

274277
// Incremental flag forces the Source build to do incremental builds if true.
275278
Incremental bool `json:"incremental,omitempty" description:"forces the source build to do incremental builds if true"`
279+
280+
// ForcePull describes if the builder should pull the images from registry prior to building.
281+
ForcePull bool `json:"forcePull,omitempty" description:"forces the source build to pull the image if true"`
276282
}
277283

278284
// BuildOutput is input to a build strategy and describes the Docker image that the strategy

pkg/build/api/v1beta3/types.go

+6
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ type DockerBuildStrategy struct {
243243

244244
// Env contains additional environment variables you want to pass into a builder container
245245
Env []kapi.EnvVar `json:"env,omitempty" description:"additional environment variables you want to pass into a builder container"`
246+
247+
// ForcePull describes if the builder should pull the images from registry prior to building.
248+
ForcePull bool `json:"forcePull,omitempty" description:"forces the source build to pull the image if true"`
246249
}
247250

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

265268
// Incremental flag forces the Source build to do incremental builds if true.
266269
Incremental bool `json:"incremental,omitempty"`
270+
271+
// ForcePull describes if the builder should pull the images from registry prior to building.
272+
ForcePull bool `json:"forcePull,omitempty" description:"forces the source build to pull the image if true"`
267273
}
268274

269275
// BuildOutput is input to a build strategy and describes the Docker image that the strategy

pkg/build/builder/cmd/builder.go

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func run(builderFactory factoryFunc, scmAuths []scmauth.SCMAuth) {
3939
glog.Fatalf("Error obtaining docker client: %v", err)
4040
}
4141
buildStr := os.Getenv("BUILD")
42+
glog.V(4).Infof("$BUILD env var is %s \n", buildStr)
4243
build := api.Build{}
4344
if err := latest.Codec.DecodeInto([]byte(buildStr), &build); err != nil {
4445
glog.Fatalf("Unable to parse build: %v", err)

pkg/build/builder/docker.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -412,15 +412,17 @@ func (d *DockerBuilder) setupPullSecret() (*docker.AuthConfigurations, error) {
412412
// dockerBuild performs a docker build on the source that has been retrieved
413413
func (d *DockerBuilder) dockerBuild(dir string) error {
414414
var noCache bool
415+
var forcePull bool
415416
if d.build.Spec.Strategy.DockerStrategy != nil {
416417
if d.build.Spec.Source.ContextDir != "" {
417418
dir = filepath.Join(dir, d.build.Spec.Source.ContextDir)
418419
}
419420
noCache = d.build.Spec.Strategy.DockerStrategy.NoCache
421+
forcePull = d.build.Spec.Strategy.DockerStrategy.ForcePull
420422
}
421423
auth, err := d.setupPullSecret()
422424
if err != nil {
423425
return err
424426
}
425-
return buildImage(d.dockerClient, dir, noCache, d.build.Spec.Output.To.Name, d.tar, auth)
427+
return buildImage(d.dockerClient, dir, noCache, d.build.Spec.Output.To.Name, d.tar, auth, forcePull)
426428
}

pkg/build/builder/dockerutil.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func removeImage(client DockerClient, name string) error {
5959
}
6060

6161
// buildImage invokes a docker build on a particular directory
62-
func buildImage(client DockerClient, dir string, noCache bool, tag string, tar tar.Tar, pullAuth *docker.AuthConfigurations) error {
62+
func buildImage(client DockerClient, dir string, noCache bool, tag string, tar tar.Tar, pullAuth *docker.AuthConfigurations, forcePull bool) error {
6363
tarFile, err := tar.CreateTarFile("", dir)
6464
if err != nil {
6565
return err
@@ -75,6 +75,7 @@ func buildImage(client DockerClient, dir string, noCache bool, tag string, tar t
7575
OutputStream: os.Stdout,
7676
InputStream: tarStream,
7777
NoCache: noCache,
78+
Pull: forcePull,
7879
}
7980
if pullAuth != nil {
8081
opts.AuthConfigs = *pullAuth

pkg/build/builder/sti.go

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ func (s *STIBuilder) Build() error {
6666
ScriptsURL: s.build.Spec.Strategy.SourceStrategy.Scripts,
6767
Environment: getBuildEnvVars(s.build),
6868
Incremental: s.build.Spec.Strategy.SourceStrategy.Incremental,
69+
ForcePull: s.build.Spec.Strategy.SourceStrategy.ForcePull,
6970
}
7071
if s.build.Spec.Revision != nil && s.build.Spec.Revision.Git != nil &&
7172
s.build.Spec.Revision.Git.Commit != "" {

pkg/cmd/cli/describe/describer.go

+6
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ func describeSourceStrategy(s *buildapi.SourceBuildStrategy, out *tabwriter.Writ
242242
if s.Incremental {
243243
formatString(out, "Incremental Build", "yes")
244244
}
245+
if s.ForcePull {
246+
formatString(out, "Force Pull", "yes")
247+
}
245248
}
246249

247250
func describeDockerStrategy(s *buildapi.DockerBuildStrategy, out *tabwriter.Writer) {
@@ -258,6 +261,9 @@ func describeDockerStrategy(s *buildapi.DockerBuildStrategy, out *tabwriter.Writ
258261
if s.NoCache {
259262
formatString(out, "No Cache", "true")
260263
}
264+
if s.ForcePull {
265+
formatString(out, "Force Pull", "true")
266+
}
261267
}
262268

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

0 commit comments

Comments
 (0)