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

ci/docker: Add !operator dir into Dockerfile.dockerignore #14069

Merged
merged 1 commit into from
Nov 19, 2020

Conversation

sayboras
Copy link
Member

@sayboras sayboras commented Nov 18, 2020

Description

This commit is to add operator directory in Dockerfile.dockerignore file to fix below issue

../pkg/aws/endpoints/resolver.go:18:2: cannot find package "." in:
#12 9.053       /go/src/github.com/cilium/cilium/operator/option

Signed-off-by: Tam Mach [email protected]

Full log can be found here https://github.com/cilium/cilium/runs/1417805368

Testing

Testing was done locally only as I just realise that image job in github action is kicked off only for master and tag (maybe we don't want to override the image in docker registries)

make -C images cilium-image
$ make -C images cilium-image
make: Entering directory '/home/tammach/go/src/github.com/cilium/cilium/images'
ROOT_CONTEXT=true scripts/build-image.sh cilium-dev images/cilium linux/amd64,linux/arm64 "type=image" "$(cat .buildx_builder)" docker.io/cilium
will build cilium-dev:80e7f0642-dev as it has dev suffix
building cilium-dev:80e7f0642-dev
+ run_buildx
+ build_args=("--platform=${platform}" "--builder=${builder}" "--file=${image_dir}/Dockerfile")
+ '[' true = false ']'
+ build_args+=("${root_dir}")
+ '[' false = true ']'
+ docker buildx build --output=type=image --tag docker.io/cilium/cilium-dev:80e7f0642-dev --platform=linux/amd64,linux/arm64 --builder= --file=images/cilium/Dockerfile /home/tammach/go/src/github.com/cilium/cilium
WARN[0000] invalid non-bool value for BUILDX_NO_DEFAULT_LOAD:  
[+] Building 32.3s (26/26) FINISHED                                                                                                                           
 => [internal] load build definition from Dockerfile                                                                                                     0.0s
 => => transferring dockerfile: 75B                                                                                                                      0.0s
 => [internal] load .dockerignore                                                                                                                        0.0s
 => => transferring context: 35B                                                                                                                         0.0s
 => resolve image config for docker.io/docker/dockerfile:1.1-experimental                                                                                4.0s
 => CACHED docker-image://docker.io/docker/dockerfile:1.1-experimental@sha256:de85b2f3a3e8a2f7fe48e8e84a65f6fdd5cd5183afa6412fff9caa6871649c44           0.0s
 => => resolve docker.io/docker/dockerfile:1.1-experimental@sha256:de85b2f3a3e8a2f7fe48e8e84a65f6fdd5cd5183afa6412fff9caa6871649c44                      0.0s
 => [linux/arm64 internal] load metadata for docker.io/cilium/cilium-runtime-dev:bf6abb13718b26668af89df742b7c91507154a97                                3.8s
 => [linux/arm64 internal] load metadata for docker.io/cilium/cilium-builder-dev:5c69f48a672124827e6513db5f560f60b4a476ba                                3.7s
 => [linux/amd64 internal] load metadata for docker.io/cilium/cilium-runtime-dev:bf6abb13718b26668af89df742b7c91507154a97                                3.8s
 => [linux/amd64 internal] load metadata for docker.io/cilium/cilium-builder-dev:5c69f48a672124827e6513db5f560f60b4a476ba                                3.8s
 => CACHED [linux/amd64 stage-1 1/4] FROM docker.io/cilium/cilium-runtime-dev:bf6abb13718b26668af89df742b7c91507154a97@sha256:4eeb5f3b1327250585b833188  0.0s
 => => resolve docker.io/cilium/cilium-runtime-dev:bf6abb13718b26668af89df742b7c91507154a97@sha256:4eeb5f3b1327250585b8331883823343ce64a4818b8959f25262  0.0s
 => CACHED [linux/amd64 builder 1/4] FROM docker.io/cilium/cilium-builder-dev:5c69f48a672124827e6513db5f560f60b4a476ba@sha256:5e8dc417a3209df3dc9b247b6  0.0s
 => => resolve docker.io/cilium/cilium-builder-dev:5c69f48a672124827e6513db5f560f60b4a476ba@sha256:5e8dc417a3209df3dc9b247b66f891aff61d2978e6550e47a4c7  0.0s
 => [internal] load build context                                                                                                                        3.8s
 => => transferring context: 615.17MB                                                                                                                    3.8s
 => CACHED [linux/arm64 stage-1 1/4] FROM docker.io/cilium/cilium-runtime-dev:bf6abb13718b26668af89df742b7c91507154a97@sha256:4eeb5f3b1327250585b833188  0.0s
 => => resolve docker.io/cilium/cilium-runtime-dev:bf6abb13718b26668af89df742b7c91507154a97@sha256:4eeb5f3b1327250585b8331883823343ce64a4818b8959f25262  0.0s
 => CACHED [linux/arm64 builder 1/4] FROM docker.io/cilium/cilium-builder-dev:5c69f48a672124827e6513db5f560f60b4a476ba@sha256:5e8dc417a3209df3dc9b247b6  0.0s
 => => resolve docker.io/cilium/cilium-builder-dev:5c69f48a672124827e6513db5f560f60b4a476ba@sha256:5e8dc417a3209df3dc9b247b66f891aff61d2978e6550e47a4c7  0.0s
 => [linux/amd64 builder 2/4] RUN --mount=type=bind,readwrite,target=/go/src/github.com/cilium/cilium --mount=target=/root/.cache,type=cache --mount=t  12.3s
 => [linux/arm64 builder 2/4] RUN --mount=type=bind,readwrite,target=/go/src/github.com/cilium/cilium --mount=target=/root/.cache,type=cache --mount=t  12.3s
 => [linux/amd64 builder 3/4] RUN --mount=type=bind,readwrite,target=/go/src/github.com/cilium/cilium   cd /go/src/github.com/cilium/cilium/plugins/cil  0.2s
 => [linux/arm64 builder 3/4] RUN --mount=type=bind,readwrite,target=/go/src/github.com/cilium/cilium   cd /go/src/github.com/cilium/cilium/plugins/cil  0.1s
 => [linux/arm64 builder 4/4] RUN --mount=type=bind,readwrite,target=/go/src/github.com/cilium/cilium   cd /go/src/github.com/cilium/cilium/contrib/pac  0.2s 
 => [linux/amd64 builder 4/4] RUN --mount=type=bind,readwrite,target=/go/src/github.com/cilium/cilium   cd /go/src/github.com/cilium/cilium/contrib/pac  0.1s 
 => [linux/arm64 stage-1 2/4] COPY --from=builder /out/linux/arm64 /                                                                                     0.7s 
 => [linux/amd64 stage-1 2/4] COPY --from=builder /out/linux/amd64 /                                                                                     0.7s 
 => [linux/arm64 stage-1 3/4] WORKDIR /home/cilium                                                                                                       0.0s 
 => [linux/amd64 stage-1 3/4] WORKDIR /home/cilium                                                                                                       0.1s 
 => [linux/arm64 stage-1 4/4] RUN groupadd -f cilium   && echo ". /etc/profile.d/bash_completion.sh" >> /etc/bash.bashrc                                 0.2s 
 => [linux/amd64 stage-1 4/4] RUN groupadd -f cilium   && echo ". /etc/profile.d/bash_completion.sh" >> /etc/bash.bashrc                                 0.2s 
 => exporting to image                                                                                                                                   6.5s 
 => => exporting layers                                                                                                                                  6.4s 
 => => exporting manifest sha256:071eb779e484e4b4370711a91e308a9e408ec869dc1d54bdace698d478d9c0f9                                                        0.0s
 => => exporting config sha256:3ed26b0da3cd719ca5a81fbe2c725aa5c1a0422e9c49897ed4612f5f7f1e77de                                                          0.0s
 => => exporting manifest sha256:b1389e24cba6c03d84e936200d17093439b249b41c85f5abb9f977f5a70e0806                                                        0.0s
 => => exporting config sha256:37a3d2ffcd6656410cc84720e50db2767d3049825aca444833f5c5facb4a0735                                                          0.0s
 => => exporting manifest list sha256:349b9fd3f0c5a8b715bd3a4a822ecb243f3952f5339dcb0e88c75f5b95b1bd17                                                   0.0s
make: Leaving directory '/home/tammach/go/src/github.com/cilium/cilium/images'
ci/docker: Add operator dir into Dockerfile.dockerignore

@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Nov 18, 2020
@sayboras sayboras changed the title ci/docker: Add operator dir into Dockerfile.dockerignore for cilium i… ci/docker: Add operator dir into Dockerfile.dockerignore Nov 18, 2020
@sayboras sayboras changed the title ci/docker: Add operator dir into Dockerfile.dockerignore ci/docker: Add operator into Dockerfile.dockerignore Nov 18, 2020
@sayboras sayboras changed the title ci/docker: Add operator into Dockerfile.dockerignore ci/docker: Add !operator dir into Dockerfile.dockerignore Nov 18, 2020
@sayboras sayboras force-pushed the bugfix/docker-build branch from 00f07d2 to 80e7f06 Compare November 18, 2020 12:14
@@ -28,4 +28,5 @@
!/pkg
!/plugins/cilium-cni
!/proxylib
!/operator
Copy link
Member Author

@sayboras sayboras Nov 18, 2020

Choose a reason for hiding this comment

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

this is not ideal in my opinion, as cilium agent now is having depepency with operator 😓. Maybe it's side effect of having centralized AWS config 1b1134c.

Copy link
Member Author

Choose a reason for hiding this comment

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

another approach is to do a little bit refactor (i.e. move related common code to pkg). Keen to hear your inputs 👍

Copy link
Member

@jibi jibi Nov 19, 2020

Choose a reason for hiding this comment

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

another approach is to do a little bit refactor (i.e. move related common code to pkg)

It looks like the operator/option package in needed in order to access the configuration of the operator:

func Resolver(service, region string) (aws.Endpoint, error) {
if ep := operatorOption.Config.EC2APIEndpoint; len(ep) > 0 && service == "ec2" {
log.Debugf("Using custom API endpoint %s for service %s in region %s", ep, service, region)
// See https://docs.aws.amazon.com/sdk-for-go/v2/api/aws/endpoints/#hdr-Using_Custom_Endpoints
return aws.Endpoint{
URL: "https://" + ep,
}, nil
}
return defaultResolver.ResolveEndpoint(service, region)
}

I don't have much context on this part of the codebase but to me it doesn't look trivial to refactor the code in order to get rid of that import as Resolver is used as a callback in a couple of places:

➜  cilium git:(master) rg endpoints.Resolver pkg/
pkg/aws/ec2/ec2.go
73:	cfg.EndpointResolver = aws.EndpointResolverFunc(endpoints.Resolver)

pkg/policy/groups/aws/aws.go
65:	cfg.EndpointResolver = aws.EndpointResolverFunc(endpoints.Resolver)

/cc @tklauser which may have a bit more context on this

Copy link
Member

Choose a reason for hiding this comment

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

this is not ideal in my opinion, as cilium agent now is having depepency with operator 😓. Maybe it's side effect of having centralized AWS config 1b1134c.

The agent shouldn't have a dependency on the operator (and currently doesn't AFAIK). However, some of the packages which are also consumed by the agent depend on the operator/option package which, is fine as it only contains the operator options. This was the reason in the first place to split out that package.

I think we should be able to solve this issue by changing from !operator to !operator/option in Dockerfile.ignore.

@sayboras sayboras added area/CI Continuous Integration testing issue or flake area/docker Impacts the integration with Docker. release-note/ci This PR makes changes to the CI. labels Nov 18, 2020
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Nov 18, 2020
@sayboras sayboras added release-note/minor This PR changes functionality that users may find relevant to operating Cilium. release-note/misc This PR makes changes that have no direct user impact. and removed release-note/ci This PR makes changes to the CI. release-note/minor This PR changes functionality that users may find relevant to operating Cilium. labels Nov 18, 2020
@sayboras sayboras marked this pull request as ready for review November 18, 2020 12:23
@sayboras sayboras requested a review from a team as a code owner November 18, 2020 12:23
@sayboras sayboras requested a review from twpayne November 18, 2020 12:23
@sayboras
Copy link
Member Author

Full CI is not required in my opinion, otherwise we could have caught this in related PR.

images/cilium/Dockerfile.dockerignore Outdated Show resolved Hide resolved
This commit is to exclude operator/option directory in
Dockerfile.dockerignore file to fix below issue

```
../pkg/aws/endpoints/resolver.go:18:2: cannot find package "." in:
12 9.053       /go/src/github.com/cilium/cilium/operator/option
```

Signed-off-by: Tam Mach <[email protected]>
Copy link
Member

@tklauser tklauser left a comment

Choose a reason for hiding this comment

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

LGTM, thanks 🚀

@tklauser tklauser removed their assignment Nov 19, 2020
@jibi jibi added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Nov 19, 2020
@jibi jibi merged commit d3fbbd9 into cilium:master Nov 19, 2020
@sayboras sayboras deleted the bugfix/docker-build branch November 19, 2020 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/CI Continuous Integration testing issue or flake area/docker Impacts the integration with Docker. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants