Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.
This repository is currently being migrated. It's locked while the migration is in progress.

operator-sdk build storageos/cluster-operator:test fails #116

Open
SKD-SKD opened this issue Apr 30, 2019 · 11 comments
Open

operator-sdk build storageos/cluster-operator:test fails #116

SKD-SKD opened this issue Apr 30, 2019 · 11 comments

Comments

@SKD-SKD
Copy link

SKD-SKD commented Apr 30, 2019

from readme :
$GOPATH/bin/operator-sdk build storageos/cluster-operator:test
INFO[0000] Building Docker image storageos/cluster-operator:test
Sending build context to Docker daemon 281.3 MB
Step 1/19 : ARG BUILD_IMAGE=golang:1.11.5
Please provide a source image with from prior to commit
Error: failed to output build image storageos/cluster-operator:test: (failed to exec []string{"docker", "build", ".", "-f", "build/Dockerfile", "-t", "storageos/cluster-operator:test"}: exit status 1)

trying :
:~/go/src/github.com/storageos/cluster-operator# docker build . -f build/Dockerfile -t storageos/cluster-operator:test
Sending build context to Docker daemon 281.3 MB
Step 1/19 : ARG BUILD_IMAGE=golang:1.11.5
Please provide a source image with from prior to commit

@darkowlzz
Copy link
Contributor

Hi, thanks for reporting. Sorry that we haven't kept the setup docs up-to-date.
Please use make to build the container.
make image/cluster-operator will download all the required tools and build everything in a container.

I tried the above command with sdk cli v0.5.0 and it still seems to work fine:

$ operator-sdk build storageos/cluster-operator:test
INFO[0043] Building Docker image storageos/cluster-operator:test 
Sending build context to Docker daemon  555.1MB
Step 1/19 : ARG BUILD_IMAGE=golang:1.11.5
Step 2/19 : ARG BASE_IMAGE=storageos/base-image:0.1.0
Step 3/19 : ARG OPERATOR_IMAGE=storageos/cluster-operator:test
Step 4/19 : FROM ${BUILD_IMAGE} AS build
 ---> 1454e2b3d01f
Step 5/19 : ARG OPERATOR_IMAGE
 ---> Using cache
 ---> 4397c83947a9
Step 6/19 : WORKDIR /go/src/github.com/storageos/cluster-operator/
 ---> Using cache
 ---> 4fabc099bf85
Step 7/19 : COPY . /go/src/github.com/storageos/cluster-operator/
 ---> 68932543c697
Step 8/19 : RUN make operator-sdk
 ---> Running in 09b01c85b500
# Download sdk only if it's not available.
Removing intermediate container 09b01c85b500
 ---> d45490ef315d
Step 9/19 : RUN make generate
 ---> Running in 03ea2698f1c5
./build/operator-sdk generate k8s
time="2019-05-01T08:23:12Z" level=info msg="Running code-generation for Custom Resource group versions: [storageos:v1, ]\n"
Generating deepcopy funcs
time="2019-05-01T08:23:17Z" level=info msg="Code-generation complete."
Removing intermediate container 03ea2698f1c5
 ---> ba0e3d11622f
Step 10/19 : RUN make build/cluster-operator OPERATOR_IMAGE=$OPERATOR_IMAGE
 ---> Running in bb7890cbe173
Building cluster-operator
GOOS=linux CGO_ENABLED=0 go build -v -ldflags "-X github.com/storageos/cluster-operator/pkg/controller/storageosupgrade.operatorImage=storageos/cluster-operator:test" \
        -o ./build/_output/bin/cluster-operator \
        ./cmd/manager
github.com/storageos/cluster-operator/vendor/github.com/operator-framework/operator-sdk/version
github.com/storageos/cluster-operator/vendor/k8s.io/apimachinery/pkg/selection
...
...
Removing intermediate container bb7890cbe173
 ---> 235601d42f37
Step 11/19 : RUN make build/upgrader
 ---> Running in 862cd7cd6efd
Building upgrader
GOOS=linux CGO_ENABLED=0 go build -v \
        -o ./build/_output/bin/upgrader \
        ./cmd/upgrader
github.com/storageos/cluster-operator/cmd/upgrader
Removing intermediate container 862cd7cd6efd
 ---> fc63213880d6
Step 12/19 : FROM ${BASE_IMAGE}
 ---> be23d728480f
...
Step 17/19 : COPY --from=build /go/src/github.com/storageos/cluster-operator/build/_output/bin/cluster-operator /usr/local/bin/cluster-operator
 ---> d856c9675e46
Step 18/19 : COPY --from=build /go/src/github.com/storageos/cluster-operator/build/_output/bin/upgrader /usr/local/bin/upgrader
 ---> 1b3aebffe13d
Step 19/19 : COPY --from=build /go/src/github.com/storageos/cluster-operator/cmd/image-puller/docker-puller.sh /usr/local/bin/docker-puller.sh
 ---> 144dc9a83296
Successfully built 144dc9a83296
Successfully tagged storageos/cluster-operator:test
INFO[0124] Operator build complete.

Using the make file is the recommended way to develop, we don't guarantee operator-sdk build will continue working in the future because we need to pass certain build flags which are not natively supported by the sdk build command wrapper. I haven't checked the recent changes in the sdk build command, but the reason for not using it in the early versions of sdk was due to that limitation. Maybe the latest version of sdk cli does a better job and is able to build properly as above.

@SKD-SKD
Copy link
Author

SKD-SKD commented May 1, 2019

i have

 $GOPATH/bin/operator-sdk version
operator-sdk version: v0.6.0+git

make image/cluster-operator

# Download sdk only if it's not available.
docker build \
        --build-arg BUILD_IMAGE=go1.11.4 \
        --build-arg BASE_IMAGE=storageos/base-image:0.1.0 \
        --build-arg OPERATOR_IMAGE=storageos/cluster-operator:test \
        . -f build/Dockerfile -t storageos/cluster-operator:test
Sending build context to Docker daemon 281.3 MB
Step 1/19 : ARG BUILD_IMAGE=golang:1.11.5
Please provide a source image with `from` prior to commit
Makefile:33: recipe for target 'image/cluster-operator' failed
make: *** [image/cluster-operator] Error 1

fails

if i heck Dockerfile

#ARG BUILD_IMAGE=golang:1.11.5
#ARG BASE_IMAGE=storageos/base-image:0.1.0
#ARG OPERATOR_IMAGE=storageos/cluster-operator:test

FROM golang:1.11.5
#AS build
#${BUILD_IMAGE} AS build
# OPERATOR_IMAGE needs to be passed to build/cluster-operator for constructing
# the ldflags.

#ARG BUILD_IMAGE=golang:1.11.5
#ARG BASE_IMAGE=storageos/base-image:0.1.0
#ARG OPERATOR_IMAGE=storageos/cluster-operator:test



#ARG OPERATOR_IMAGE
WORKDIR /go/src/github.com/storageos/cluster-operator/
COPY . /go/src/github.com/storageos/cluster-operator/
RUN make operator-sdk
RUN make generate
RUN make build/cluster-operator OPERATOR_IMAGE=$OPERATOR_IMAGE
RUN make build/upgrader

FROM storageos/base-image:0.1.0
# ${BASE_IMAGE}
LABEL name="StorageOS Cluster Operator" \
      maintainer="[email protected]" \
      vendor="StorageOS" \
      version="1.1.0" \
      release="1" \
      distribution-scope="public" \
      architecture="x86_64" \
      url="https://docs.storageos.com" \
      io.k8s.description="The StorageOS Cluster Operator installs and manages StorageOS within a cluster." \
      io.k8s.display-name="StorageOS Cluster Operator" \
      io.openshift.tags="storageos,storage,operator,pv,pvc,storageclass,persistent,csi" \
      summary="Highly-available persistent block storage for containerized applications." \
      description="StorageOS transforms commodity server or cloud based disk capacity into enterprise-class storage to run persistent workloads such as databases in containers. Provides high availability, low late
ncy persistent block storage. No other hardware or software is required."

# Docker is required by the upgrader to pre-load images.  Only `docker pull` is
# used.  `podman` would be preferred but it's not available in the package repo,
# and there isn't a binary release that we can easily download into the image.
RUN \
    wget --no-check-certificate -q https://download.docker.com/linux/static/stable/x86_64/docker-17.03.0-ce.tgz && \
    tar -xvzf docker-17.03.0-ce.tgz && \
    cp docker/docker /bin/ && \
    rm -rf docker* && \
    chmod +x /bin/docker
RUN mkdir -p /licenses
COPY  LICENSE /licenses/
COPY  build/_output/bin/cluster-operator /usr/local/bin/cluster-operator
COPY  build/_output/bin/upgrader /usr/local/bin/upgrader
#COPY --from=build
COPY cmd/image-puller/docker-puller.sh /usr/local/bin/docker-puller.sh

then it works :

 docker images
REPOSITORY                                                TAG                            IMAGE ID            CREATED             SIZE
storageos/cluster-operator                                test                           20ac40a2199b        23 seconds ago      328 MB

@SKD-SKD
Copy link
Author

SKD-SKD commented May 1, 2019

$GOPATH/bin/operator-sdk build storageos/cluster-operator:test works and creates image as well

@darkowlzz
Copy link
Contributor

Interesting... I've seen this behavior in the redhat container build service. The container runtime doesn't support arguments and templates. And for that we have a separate Dockerfile. It looks similar to the changes you made.
Can you share more about the docker version or the container runtime you are using here?

@SKD-SKD
Copy link
Author

SKD-SKD commented May 1, 2019

sure, docker version

Client:
 Version:      17.03.2-ce
 API version:  1.27
 Go version:   go1.6.2
 Git commit:   f5ec1e2
 Built:        Thu Jul  5 23:07:48 2018
 OS/Arch:      linux/amd64

Server:
 Version:      17.03.2-ce
 API version:  1.27 (minimum version 1.12)
 Go version:   go1.6.2
 Git commit:   f5ec1e2
 Built:        Thu Jul  5 23:07:48 2018
 OS/Arch:      linux/amd64
 Experimental: false

@darkowlzz
Copy link
Contributor

Thanks. I'm using 18.09 on my development machine. But our CI uses 17.09 https://travis-ci.org/storageos/cluster-operator/jobs/526864684#L33-L48 and the image building works fine there https://travis-ci.org/storageos/cluster-operator/jobs/526864684#L856.
I'm not sure what's causing this issue. It would be great to know and fix it if possible.
What's your OS? I've a feeling that the redhat family (including centos/fedora) have something different that's causing this.

@SKD-SKD
Copy link
Author

SKD-SKD commented May 1, 2019

sure :

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.5 LTS
Release:        16.04
Codename:       xenial

@darkowlzz
Copy link
Contributor

CI also uses ubuntu. Now I've no clue why we are seeing different behaviors for the same major version of docker and OS.
For now, you can use the https://github.com/storageos/cluster-operator/blob/master/build/rhel-build-service/Dockerfile to build the container.

@SKD-SKD
Copy link
Author

SKD-SKD commented May 1, 2019

i am ok to build it with heck-ed Dockerfile
do you think it is my Docker version ?
do you know how i can upgrade version without stopping it / I run kube and it is my master :)

@darkowlzz
Copy link
Contributor

I usually just follow the official docs https://docs.docker.com/install/linux/docker-ce/ubuntu/ . AFAIK the docker daemon does everything and you have to restart the daemon process to enable the new version.

@SKD-SKD
Copy link
Author

SKD-SKD commented May 1, 2019

oh, this now can be a bit of the problem :) for me now, as i am running kube and it's apps on this cluster.
ones (at some point) it all may go down, i will do the Docker upgrade

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

No branches or pull requests

2 participants