Skip to content

jenkinsfile: add containerized pipeline - #46071

Closed
epuertat wants to merge 1 commit into
mainfrom
wip-jenkinsfile-master
Closed

epuertat wants to merge 1 commit into
mainfrom
wip-jenkinsfile-master

Conversation

@epuertat

@epuertat epuertat commented Apr 28, 2022 •

Copy link
Copy Markdown
Member

jenkins do not test

There was a first try of this (but without the containerized approach): #37425

New Pipeline View

image

Security

Unlike the non-containerized approach, which required 'sudo' and made changes to the host environment, this version intentionally removes the requirement for sudo.

TODO

  • container build & install-deps (docker build)
    • CentOS Stream 8
    • Ubuntu 20.04
  • configure
  • make
  • unit tests (make check)
    • Failure in librbd /librbd/migration/test_mock_HttpClient.cc: TestMockMigrationHttpClient.OpenConnectFail: expects ECONNREFUSED 111 but gets EADDRNOTAVAIL 99 (when trying to open "http://localhost:2/")
    • Failure run_rbd_unit_tests_*.sh
  • API tests
  • Dashboard tests
  • Options:
    • Timestamps
    • Timeout
    • Abort previous build on new build
    • Trigger phrases
    • Github checks (multiple Github checks for the same Jenkins job: make check, api tests, etc).
    • Junit reporting
  • Optimizations:
    • Parallelize
    • Cache container build (remove --no-cache=true)
    • ccache
    • Cache git
    • Cache packages (/var/cache/dnf)
    • Cache pip
    • Cache npm

Jenkinsfile declarative pipeline syntax reference

Signed-off-by: Ernesto Puerta [email protected]

Contribution Guidelines

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows

@epuertat epuertat changed the title jenkinsfile: add containerized pipeline jenkinsfile: add containerized pipeline Apr 28, 2022
@ceph ceph deleted a comment from ceph-jenkins Apr 28, 2022
@epuertat
epuertat force-pushed the wip-jenkinsfile-master branch 15 times, most recently from 6ea352e to a74052b Compare April 29, 2022 14:55
@epuertat
epuertat force-pushed the wip-jenkinsfile-master branch 4 times, most recently from c5d4708 to 2b57142 Compare April 29, 2022 16:46
@epuertat
epuertat force-pushed the wip-jenkinsfile-master branch 5 times, most recently from 54ceeef to 7748b30 Compare April 29, 2022 17:53
@epuertat
epuertat force-pushed the wip-jenkinsfile-master branch 7 times, most recently from 485d949 to 094034f Compare May 10, 2022 16:03
@djgalloway
djgalloway changed the base branch from master to main May 25, 2022 20:00
@epuertat epuertat mentioned this pull request Aug 11, 2022
4 of 14 tasks
@epuertat
epuertat force-pushed the wip-jenkinsfile-master branch from 094034f to 8417f60 Compare August 18, 2022 16:19
@epuertat
epuertat force-pushed the wip-jenkinsfile-master branch from 8417f60 to d7a5b47 Compare August 29, 2022 17:09
@epuertat
epuertat force-pushed the wip-jenkinsfile-master branch from d7a5b47 to 70f2511 Compare September 8, 2022 12:58
@ceph ceph deleted a comment from github-actions Bot Sep 8, 2022

@phlogistonjohn phlogistonjohn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi,
I finally got to time to mess around with your PR. I think it's a really cool start. Especially reusing the function prepare which I learned about just by reading the source to this dockerfile.

I had to hack up the dockerfile a bit but I did eventually get ceph building using this dockerfile as a base! Unfortunately, certain dependencies didn't seem to get installed by the existing rules. So I ended up with the somewhat messy RUN line:

RUN true \
    && dnf install -y epel-release 'dnf-command(config-manager)'  \
    && dnf config-manager --set-enabled epel \
    && dnf install -y gcc-toolset-11{,-libatomic-devel} \
    && dnf install -y java-1.8.0-openjdk-headless \
    && source ./run-make-check.sh \
    && prepare \
    && ( if [ "${CLEAN_DNF}" != no ]; then dnf clean all && rm -rf /var/cache/dnf/* ; fi ) \
    && true

Obviously, this isn't very nice, but it got me to the point where do_cmake.sh and make/ninja would run.
I've started reading more into the scripts run-make-check.sh and src/script/run-make.sh to see why certain things (installing ccache, installing gcc-toolset, etc) don't work out of the box.

My interest is getting builds going locally, so I don't have a strong opinion on the jenkins part. I wonder if it might make sense to first get the dockerfile/scripts working for local builds of centos8, and ubuntu and then circle back to jenkins? Regardless, this is pretty cool and I want to continue poking at it until I can really use it as a base for my local builds!

Comment thread Dockerfile.build

COPY ./ ./
ARG FOR_MAKE_CHECK=1
RUN source run-make-check.sh && prepare

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I did some digging and found that the pepare function is actually in src/script/run-make.sh. So that script could sourced rather than run-make-check.sh.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch!

Comment thread Dockerfile.build
COPY ./ ./
ARG FOR_MAKE_CHECK=1
RUN source run-make-check.sh && prepare
RUN dnf clean all && rm -rf /var/cache/dnf/*

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We generally want to run cleanup commands in the same RUN statement as the commands that dirty the state, right now the RUN statement above creates a layer with the results of prepare including the dnf cache. This line then creates a new layer that will remove the files... but they'll continue to exist in the parent layer.
It may also be nice to have a ARG to disable this cleanup... I use this myself when I need to iterate on building a container so I bind mount a directory for the dnf cache dirs and then reuse them over multiple runs. It significantly cuts down on the time needed to run the build command, not downloading the dnf metadata and files over and over again.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You're right.

In Docker I think they (recently?) added the --mount=cache option to the RUN command in order to keep an external caching layer for these kind of commands.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Interesting. Thanks for the pointer. I think this will be also in recent podman versions, but I have not tested it. I definitely want the containerfile and supporting bits to also work with podman, even if docker is used on the jenkins builders.

Comment thread Dockerfile.build
ARG JENKINS_USER_GID=100


SHELL ["bash", "-x", "-c"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This line generates warnings for me - using podman.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Can be removed. Just added to dump traces.

Comment thread Dockerfile.build

SHELL ["bash", "-x", "-c"]

COPY ./ ./

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This line is going to stash the entire ceph source tree at the root of the container. It's probably fine to begin with, but it might be nice to put it in a particular dir and maybe only copy only the files necessary to set up the environment?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

With the .dockerignore defined in this PR actually this is just a few files. The repo files are actually mounted in the container run stage.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Gotcha, I missed that, thanks!

@epuertat

Copy link
Copy Markdown
Member Author

@phlogistonjohn would you like to take over here? Honestly I'm not finding time to work on this (and it's high-prio as we discussed in one recent CLT meeting), so if someone else is willing to, I'll be more than happy to hand it over to you and help you as much as I can.

Regarding the Jenkins vs. local, the truth is that we really need this in the CI environment, and the Jenkins pipeline worked good in the past (I broke this when I removed the EPEL install from the Dockerfile, with the goal of having a distro-neutral Dockerfile)...

@phlogistonjohn

Copy link
Copy Markdown
Contributor

@phlogistonjohn would you like to take over here? Honestly I'm not finding time to work on this (and it's high-prio as we discussed in one recent CLT meeting), so if someone else is willing to, I'll be more than happy to hand it over to you and help you as much as I can.

I'd be willing to take the lead on this. If you don't mind I would prefer to create my own branch/pr - in the "compile cephadm" PR I took it over fully intact but it caused some workflow issues for me.

Regarding the Jenkins vs. local, the truth is that we really need this in the CI environment, and the Jenkins pipeline worked good in the past (I broke this when I removed the EPEL install from the Dockerfile, with the goal of having a distro-neutral Dockerfile)...

I'm 100% behind getting it integrated with jenkins. I personally think getting it working locally first is faster and simpler and works as a glide path to also getting it working in jenkins too. I'd also need to rely more on your help and others when it comes to jenkins integration.

@phlogistonjohn

Copy link
Copy Markdown
Contributor

Replying to myself, I want to create a branch under my own fork based on this branch, not just starting from scratch.

@epuertat

epuertat commented Oct 4, 2022

Copy link
Copy Markdown
Member Author

I'd be willing to take the lead on this. If you don't mind I would prefer to create my own branch/pr - in the "compile cephadm" PR I took it over fully intact but it caused some workflow issues for me.

@phlogistonjohn great, all yours then! I'll close this PR.

I'm 100% behind getting it integrated with jenkins. I personally think getting it working locally first is faster and simpler and works as a glide path to also getting it working in jenkins too. I'd also need to rely more on your help and others when it comes to jenkins integration.

Regarding the Jenkins thing: the Jenkinsfile is already complete there (only a few things are left to achieve feature parity with the current Jenkins job: a) trigger phrases support, like the jenkins make check stuff, b) caching for git/pip/npm/dnf, etc.).

Good thing of conveying the Jenkins support is that it automatically becomes the validation step for this change (no need to add any further testing)... And I also found that Jenkins nodes built Ceph faster than my laptop ;-)

Besides, if you need to keep any artifacts of the build for local testing, Jenkins also allows you to do that.

@epuertat epuertat closed this Oct 4, 2022
@phlogistonjohn

Copy link
Copy Markdown
Contributor

Cool, thanks. I will probably have additional jenkins specific questions I'll need to ask you in the future. For those, I'll use chat/email from this point on. :-)

phlogistonjohn added a commit to phlogistonjohn/ceph that referenced this pull request Nov 2, 2022
In preparation for running builds and tests in containers, make some
organizational changes to the run-make-*.sh scripts.

Original version of the patch can be found at ceph#46071

Original-version-by: Ernesto Puerta <[email protected]>
Co-authored-by: Ernesto Puerta <[email protected]>
Co-authored-by: John Mulligan <[email protected]>
Signed-off-by: Ernesto Puerta <[email protected]>
Signed-off-by: John Mulligan <[email protected]>
phlogistonjohn added a commit to phlogistonjohn/ceph that referenced this pull request Nov 8, 2022
In preparation for running builds and tests in containers, make some
organizational changes to the run-make-*.sh scripts.

Original version of the patch can be found at ceph#46071

Original-version-by: Ernesto Puerta <[email protected]>
Co-authored-by: Ernesto Puerta <[email protected]>
Co-authored-by: John Mulligan <[email protected]>
Signed-off-by: Ernesto Puerta <[email protected]>
Signed-off-by: John Mulligan <[email protected]>
phlogistonjohn added a commit to phlogistonjohn/ceph that referenced this pull request Nov 8, 2022
In preparation for running builds and tests in containers, make some
organizational changes to the run-make-*.sh scripts.

Original version of the patch can be found at ceph#46071

Original-version-by: Ernesto Puerta <[email protected]>
Co-authored-by: Ernesto Puerta <[email protected]>
Co-authored-by: John Mulligan <[email protected]>
Signed-off-by: Ernesto Puerta <[email protected]>
Signed-off-by: John Mulligan <[email protected]>
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.

2 participants