Skip to content

Commit

Permalink
s2i: s2i rebuild broken
Browse files Browse the repository at this point in the history
Bug 1366475
Bugzilla link https://bugzilla.redhat.com/show_bug.cgi?id=1366475
Detailed explanation
an attempt to pull the builder image to obtain labels was made; the correct thing was
to pull the locally build image we were rebuilding
  • Loading branch information
gabemontero committed Aug 12, 2016
1 parent df7de73 commit 4de98f1
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 13 deletions.
2 changes: 1 addition & 1 deletion cmd/s2i/main.go
Expand Up @@ -216,7 +216,7 @@ func newCmdRebuild(cfg *api.Config) *cobra.Command {
cfg.PullAuthentication = docker.LoadAndGetImageRegistryAuth(r, cfg.Tag)
}

err := build.GenerateConfigFromLabels(cfg)
err := build.GenerateConfigFromLabels(cfg, true)
checkErr(err)

if len(args) >= 2 {
Expand Down
15 changes: 6 additions & 9 deletions hack/test-stirunimage.sh
Expand Up @@ -62,15 +62,6 @@ function test_debug() {
echo
}

set +e
img_count=$(docker images | grep -c sti_test/sti-fake)
set -e

if [ "${img_count}" != "10" ]; then
echo "You do not have necessary test images, be sure to run 'hack/build-test-images.sh' beforehand."
exit 1
fi

trap cleanup EXIT SIGINT

echo "working dir: ${WORK_DIR}"
Expand Down Expand Up @@ -114,6 +105,12 @@ check_result $? ""
grep "Copying sources" "${WORK_DIR}/s2i-non-repo.log"
check_result $? "${WORK_DIR}/s2i-non-repo.log"

test_debug "s2i rebuild"
s2i build https://github.com/openshift/sti-php.git --context-dir=5.5/test/test-app registry.access.redhat.com/openshift3/php-55-rhel7 rack-test-app --incremental=true --loglevel=5 &> "${WORK_DIR}/s2i-pre-rebuild.log"
check_result $? "${WORK_DIR}/s2i-pre-rebuild.log"
s2i rebuild rack-test-app:latest rack-test-app:v1 --force-pull=false -p never --loglevel=5 &> "${WORK_DIR}/s2i-rebuild.log"
check_result $? "${WORK_DIR}/s2i-rebuild.log"

test_debug "s2i usage"

s2i usage openshift/ruby-20-centos7 &> "${WORK_DIR}/s2i-usage.log"
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/describe/describer.go
Expand Up @@ -97,7 +97,7 @@ func describeBuilderImage(config *api.Config, image string, out io.Writer) {
Tag: config.Tag,
IncrementalAuthentication: config.IncrementalAuthentication,
}
build.GenerateConfigFromLabels(c)
build.GenerateConfigFromLabels(c, false)
if len(c.DisplayName) > 0 {
fmt.Fprintf(out, "Builder Name:\t%s\n", c.DisplayName)
}
Expand Down
10 changes: 8 additions & 2 deletions pkg/build/config.go
Expand Up @@ -9,8 +9,14 @@ import (

// GenerateConfigFromLabels generates the S2I Config struct from the Docker
// image labels.
func GenerateConfigFromLabels(config *api.Config) error {
result, err := docker.GetBuilderImage(config)
func GenerateConfigFromLabels(config *api.Config, rebuild bool) error {
var result *docker.PullResult
var err error
if rebuild {
result, err = docker.GetRebuildImage(config)
} else {
result, err = docker.GetBuilderImage(config)
}
if err != nil {
return err
}
Expand Down
22 changes: 22 additions & 0 deletions pkg/docker/util.go
Expand Up @@ -286,6 +286,28 @@ func GetBuilderImage(config *api.Config) (*PullResult, error) {
return r, nil
}

// GetRebuildImage obtains the metadata information for the image
// specified in a s2i rebuild operation. Assumptions are made that
// the build is available locally since it should have been previously built.
func GetRebuildImage(config *api.Config) (*PullResult, error) {
d, err := New(config.DockerConfig, config.PullAuthentication)
if err != nil {
return nil, err
}

r, err := PullImage(config.Tag, d, api.PullNever, false)
if err != nil {
return nil, err
}

err = CheckAllowedUser(d, config.Tag, config.AllowedUIDs, r.OnBuild)
if err != nil {
return nil, err
}

return r, nil
}

// GetRuntimeImage processes the config and performs operations necessary to make
// the Docker image specified as RuntimeImage available locally.
func GetRuntimeImage(config *api.Config, docker Docker) error {
Expand Down

0 comments on commit 4de98f1

Please sign in to comment.