Skip to content

Conversation

@lhotari
Copy link
Member

@lhotari lhotari commented Feb 19, 2021

Motivation

Smaller pulsar-test-latest-version docker image size makes it feasible to build the image once and share it between the different parallel integration test build jobs. This will help improve the Pulsar CI in the future since it opens up new possibilities to save build system resources (GitHub Actions Runner VM time).

Modifications

  • Build go-lang examples in a separate temporary layer. This reduces the final size of the image by at least 600MB.

  • Cleanup files as last steps

    • Cleaning up files doesn't reduce the size of the image yet since it requires docker build squashing. The cleanup step is preparation for future changes.
    • To actually reduce the final image size, it would require -Ddockerfile.build.squash=true (uses docker build --squash). This is not part of this change since the image size isn't important until images are transferred over the network. Squashing the image would just add overhead to the current build.
    • Remove Pulsar CPP library's static libraries /usr/lib/libpulsar*.a (since no tests use it)
    • Remove gcc compiler (since no tests use it)

- smaller image size makes it feasible to build the image once and share
  it between the different parallel integration test jobs. This will
  help improve the Pulsar CI in the future.

Solution:
- build go-lang examples in a separate temporary layer
- cleanup files as last steps
  - requires "-Ddockerfile.build.squash=true" (uses "docker build --squash")
    to reduce the final image size. This is not part of this change
    since the image size isn't important until images are transferred over
    the network. Squashing the image would just add overhead to the current build.
Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

+1

Copy link
Member

@zymap zymap left a comment

Choose a reason for hiding this comment

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

I wonder how to share the docker image between different jobs?

@zymap zymap added this to the 2.8.0 milestone Feb 19, 2021
@lhotari
Copy link
Member Author

lhotari commented Feb 19, 2021

I wonder how to share the docker image between different jobs?

@zymap The high level idea is described in the draft PIP Changes to GitHub Actions based Pulsar CI. It's possible by using the GitHub Actions Cache. There's an action that adds a local HTTP proxy to the cache where you can POST and GET any key from the cache. I've been experimenting with it and it's really great and efficient. I'll share the results on the mailing list asap (next week).

docker comes with docker save and docker load commands which allow to export an image to a stream of bytes. I've been experimenting with a solution where I pipe this to zstd compressor and with curl over http-cache-proxy to GitHub Actions Cache. It's pretty stable, however sometimes the upload or download fails. I'll add retries to address that issue.

btw. The challenge with docker save is that it saves all layers. It also saves the openjdk:8-jdk-slim layers which could be pulled directly, however that's not a big concern since the size of openjdk:8-jdk-slim is 288MB uncompressed. This is a small portion of the total image size of pulsar-test-latest-version image. There are solutions to hack around the limitation, but they are fairly complex.

@lhotari
Copy link
Member Author

lhotari commented Feb 19, 2021

/pulsarbot run-failure-checks

1 similar comment
@lhotari
Copy link
Member Author

lhotari commented Feb 19, 2021

/pulsarbot run-failure-checks

@merlimat merlimat merged commit 3ad9d32 into apache:master Feb 19, 2021
@michaeljmarshall
Copy link
Member

@lhotari - great change, and I'm looking forward to seeing the GitHub Actions Cache in practice. That should really speed up the builds.

sijie pushed a commit that referenced this pull request Mar 8, 2021
### Motivation

The chown & chmod operations added in #9627 are causing docker to actually duplicate all the files in the overlay filesystem, increasing the image size by ~2GB. 

After this change the test image size is ~2.5 GB.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants