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

Mrc 5146 container gh actions #7

Merged
merged 27 commits into from
Aug 16, 2024
Merged

Conversation

M-Kusumgar
Copy link
Contributor

@M-Kusumgar M-Kusumgar commented Aug 7, 2024

This turned into a longer PR than I had initially hoped for. This PR builds docker and pushes it dockerhub and github container registry. Main changes include:

  • workflow for pushing
  • upgrading R version in the package because R versions less than 4.1.0 have problems with decoding url params
  • added host option in server main entrypoint
  • added worker main entrypoint that also creates their worker directory in .packit
  • REDIS_CONTAINER_NAME env var so that we can connect to redis running in another container
  • various scripts for testing this out fully in a docker setup, these are outlined in the README

@M-Kusumgar M-Kusumgar marked this pull request as draft August 7, 2024 14:55
@M-Kusumgar M-Kusumgar marked this pull request as ready for review August 7, 2024 15:00
@M-Kusumgar M-Kusumgar changed the base branch from main to mrc-5585-submit-endpoint August 7, 2024 15:01
@M-Kusumgar M-Kusumgar changed the base branch from mrc-5585-submit-endpoint to main August 8, 2024 18:44
@M-Kusumgar M-Kusumgar changed the base branch from main to mrc-5585-submit-endpoint August 8, 2024 18:49
Comment on lines 28 to 30
RUN git config --global --add safe.directory /orderly-root
RUN echo ".packit" > /.gitignore
RUN git config --global core.excludesFile "/.gitignore"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

same issue as in outpack_server PR, gotta add this as a safe directory as it is not owned by us in the container, also the global gitignore means that the .packit where the workers are isnt tracked by git

@M-Kusumgar M-Kusumgar requested a review from richfitz August 8, 2024 18:58
@M-Kusumgar M-Kusumgar requested a review from absternator August 8, 2024 18:58
Copy link
Contributor

@absternator absternator left a comment

Choose a reason for hiding this comment

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

LGTM!!!! just some minor commnets..

  • Maybe the scripts can be one level higher above test? in a scripts folder for consitency

Also just a question... im gussiing in packet we just spin up the runner and worker right?


docker volume create orderly-root-volume

docker run --rm -d --pull=missing \
Copy link
Contributor

Choose a reason for hiding this comment

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

Q: whats this one for?

Copy link
Contributor Author

@M-Kusumgar M-Kusumgar Aug 12, 2024

Choose a reason for hiding this comment

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

that one is for a couple things:

  1. you need a volume attached to a container to do anything with it so for us modifying the orderly repo, we could use this as the place to change things in the volume for testing
  2. to view how things change in the working directory (since workers will be running things and producing result files and metadata of the run) theres a helper script docker/test/copy-orderly-root that will copy the folder so we can see it easily - that script uses this container too


docker network create orderly.runner_network

docker run --rm -d \
Copy link
Contributor

Choose a reason for hiding this comment

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

also wondering if redis is needed here? or maybe another script that dosent... as this will all be brought up with packet (which already brings up redis), thus will get conflict

Copy link
Member

Choose a reason for hiding this comment

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

we do need redis here, but that's fine for testing this stuff. You will get a conflict if two containers bring up redis on the same port, but in practice it's not hard to deal with

@@ -17,3 +19,15 @@ RUN install2.r --error remotes && \

COPY . /src
RUN R CMD INSTALL --install-tests /src && rm -rf /src

ENV ORDERLY_RUNNER_QUEUE_ID=orderly.runner
ENV REDIS_CONTAINER_NAME=orderly.runner_redis
Copy link
Contributor

Choose a reason for hiding this comment

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

will this come from packet? or will this have another redis container?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

packit does not need a redis container, after addressing rich's comments, this will come from env args in docker run and so these variables will come from the packit deploy tool which makes sense

@@ -17,3 +19,15 @@ RUN install2.r --error remotes && \

COPY . /src
RUN R CMD INSTALL --install-tests /src && rm -rf /src

ENV ORDERLY_RUNNER_QUEUE_ID=orderly.runner
Copy link
Contributor

Choose a reason for hiding this comment

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

a more informative name just to be safe ahha eg. orderly.runner.queueId

Copy link
Contributor Author

Choose a reason for hiding this comment

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

gone with orderly.runner.queue for casing consistency

Copy link
Contributor

@absternator absternator left a comment

Choose a reason for hiding this comment

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

LGTM!!!! just some minor commnets..

  • Maybe the scripts can be one level higher above test? in a scripts folder for consitency

Also just a question... im gussiing in packet we just spin up the runner and worker right?


RUN apt-get update && apt-get install -y --no-install-recommends \
libcurl4-openssl-dev \
libssl-dev \
zlib1g-dev \
libhiredis-dev \
git \
Copy link
Member

Choose a reason for hiding this comment

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

can yo sort these alphabetically please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -17,3 +19,15 @@ RUN install2.r --error remotes && \

COPY . /src
RUN R CMD INSTALL --install-tests /src && rm -rf /src

ENV ORDERLY_RUNNER_QUEUE_ID=orderly.runner
ENV REDIS_CONTAINER_NAME=orderly.runner_redis
Copy link
Member

Choose a reason for hiding this comment

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

I don't think that this should be a default envvar in the image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

set -x
HERE=$(dirname $0)

docker kill \
Copy link
Member

Choose a reason for hiding this comment

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

Use docker rm -f and you can avoid the repetition here


docker network create orderly.runner_network

docker run --rm -d \
Copy link
Member

Choose a reason for hiding this comment

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

we do need redis here, but that's fine for testing this stuff. You will get a conflict if two containers bring up redis on the same port, but in practice it's not hard to deal with

docker run --rm -d --pull=always \
--net=orderly.runner_network \
--name=orderly.runner_server \
--entrypoint="/usr/local/bin/orderly.runner.server" \
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
--entrypoint="/usr/local/bin/orderly.runner.server" \
--entrypoint="/usr/local/bin/orderly.runner.server" \
--env=REDIS_CONTAINER_NAME=orderly.runner_redis \

etc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -0,0 +1,41 @@
#!/usr/bin/env bash
set -ex
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
set -ex
set -exu

Everywhere you want -e you usually want -u

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@M-Kusumgar M-Kusumgar requested a review from richfitz August 12, 2024 13:35
@M-Kusumgar
Copy link
Contributor Author

M-Kusumgar commented Aug 12, 2024

I have addressed the comments but also done a bit of cleanup, all ive done that is extra is extract out certain variables you may want to change like container names, after approval I will also change it to pull image from main and merge it in so that we arent always pulling from this random branch. I will also remove triggers to the build and push workflow from this branch.

Also I remember this ticket that I had to do involving replacing _ with - in docker container names, ive forgotten why I had to do it but to be on the safe side, the naming convention is now orderly.runner-[container] instead of orderly.runner_[container]

main_worker <- function(args = commandArgs(TRUE)) {
dat <- parse_main_worker(args)

# assumes ORDERLY_RUNNER_QUEUE_ID is set
Copy link
Member

Choose a reason for hiding this comment

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

Does this error informatively if not set?

# Create queue
self$controller <- rrq::rrq_controller(
queue_id %||% orderly_queue_id()
queue_id %||% orderly_queue_id(),
Copy link
Member

Choose a reason for hiding this comment

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

Suggest erroring here or orderly_queue_id() here if not set? but we could explore that in another PR if you prefer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i think we should error in the main_worker function because this is okay if we havent set the queue id, in fact we use that behaviour a lot in the tests, have made a ticket: https://mrc-ide.myjetbrains.com/youtrack/issue/mrc-5663/orderly.runner-worker-error-if-ORDERLYRUNNERQUEUEID-not-set

@M-Kusumgar M-Kusumgar changed the base branch from mrc-5585-submit-endpoint to main August 16, 2024 12:17
@M-Kusumgar M-Kusumgar merged commit 9985f51 into main Aug 16, 2024
8 checks passed
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

Successfully merging this pull request may close these issues.

3 participants