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

Make the CMake pipeline work on Kubernetes #553

Open
marcomicera opened this issue Apr 7, 2021 · 1 comment
Open

Make the CMake pipeline work on Kubernetes #553

marcomicera opened this issue Apr 7, 2021 · 1 comment

Comments

@marcomicera
Copy link
Member

marcomicera commented Apr 7, 2021

Prerequisites

Basic understanding of how Quartermaster works (see this presentation).

Problem

The CMake pipeline is supposed to:

  1. git clone and build a CMake repository;
  2. detect its licenses;
  3. report its findings back.

Currently, the pipeline for CMake is broken when being run locally, and it has never worked on Kubernetes.

Goal

Make it work on Kubernetes.
Personally, I wouldn't make the effort to try to make it run locally, but I would concentrate on making it run in Docker containers, as we ultimately want to deploy Quartermaster on Kubernetes.

A possible workflow

See how the pipeline for Maven works on Kubernetes

  1. Start by deploying Quartermaster for Maven on Kubernetes.
    Worth mentioning:
  2. Observe its results by inspecting the DGraph database instance's content.
    • The database schema is defined here as a proto definition file.
      • Might be useful to generate a diagram out of it with protodot.
      • Detected licenses should be contained in DataNodes, having:
        • type = license, and
        • data = the detected license.

Inspect the CMake local demos

The demos submodule contains attempts of license detection of all sorts of projects, including C ones.
This paragraph contains instructions on how to run these demos locally:

Running the demos is Makefile based.
Running just make it will compile all the projects located in the demos/ directory with Quartermaster:

$ make
...

Should you want to compile a specific project run make followed by the name of the project you want to compile e.g.:

$ make curl
...

For more information and updates you can visit the Quartermaster project.

This is a tedious, but maybe necessary step

Several problems arise when trying to run those locally, though: these demos require you to build the qmstr/master (huge and inefficient) image via the Quartermaster's main Makefile (last step):

$ make --dry-run
echo /usr/local/bin/docker
go test ./clients/qmstrctl
go build  -ldflags "-X github.com/QMSTR/qmstr/lib/go-qmstr/cli.QmstrVersion=0.5" -o out/qmstrctl ./clients/qmstrctl
go test ./clients/qmstr
go build -o out/qmstr ./clients/qmstr
go test ./modules/builders/qmstr-wrapper
go build -o out/builders/qmstr-wrapper ./modules/builders/qmstr-wrapper
docker build -f masterserver/Dockerfile -t qmstr/master --target master  --build-arg QMSTR_VERSION=0.5 --build-arg GRPCIO_VERSION=1.20.0 --build-arg DGRAPH_VERSION=1.1.0 --build-arg HUGO_VERSION=0.39 --build-arg SCANCODE_VERSION=3.1.1 --build-arg GO_VERSION=1.12.4 .

Against all good practices, its (huge) Dockerfile masterserver/Dockerfile contains several big components inside, such as the DGraph database itself: this makes the image build take forever to complete.
I'm afraid, though, that this step is necessary to be able to run these demos in a local environment.

That big image is just for demos

Please note that in production, however, a complete different set of images is being used, which reside under the docker folder.

How the Kubernetes version should look like

The qmstr-client is the image that is in charge of building the project (note the mvn package command):

- name: qmstr-client
image: endocodeci/qmstr-client-mvn
command: [ "sh", "-c", "mvn package -Dmaven.test.skip=true && qmstrctl analyze --verbose" ]
env:
- name: QMSTRADDRENV
value: "localhost:50051"
- name: BUILDROOT
value: /var/qmstr/buildroot
- name: QMSTR_MASTER
value: "localhost:50051"
volumeMounts:
- name: buildroot-volume
mountPath: /var/qmstr/buildroot

This means that it is also language-dependent (note its name endocodeci/qmstr-client-mvn, which should really just be a tag in my opinion, i.e., endocodeci/qmstr-client:mvn), as the Maven version should contain the mvn binary, the Cmake version the cmake and make binaries, and so on.
For that matter, the qmstr-client Dockerfile should contain a target specifically for CMake projects (this is the Maven target for reference).

How does the build system interact with Quartermaster

As you can see from this example, cmake and make are wrapped by the qmstr binary, that makes this communication possible (the qmstrctl --verbose spawn qmstr/curldemo part only spawns a container locally and runs all the commands that follow inside it).

Please note that this does not happen with Maven:

command: [ "sh", "-c", "mvn package -Dmaven.test.skip=true && qmstrctl analyze --verbose" ]

qmstr does not wrap the mvn package command, as the pom.xml file is being previously patched by an initContainer in order for Maven to be able to send build information to Quartermaster.

Other useful information

  • Docker images are being built, pushed and deployed through this GitHub Action.
@marcomicera
Copy link
Member Author

Feel free to reach out to me in case you have questions!

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

No branches or pull requests

1 participant