Skip to content

Add entrypoint to clear the federation metadata cache on startup#244

Open
phavekes wants to merge 3 commits into
mainfrom
feature/clear_cache_on_startup
Open

Add entrypoint to clear the federation metadata cache on startup#244
phavekes wants to merge 3 commits into
mainfrom
feature/clear_cache_on_startup

Conversation

@phavekes

Copy link
Copy Markdown
Member

This adds an entrypoint to the docker image that will clear the federation metadata cache just before the application in launched.

@phavekes phavekes self-assigned this May 28, 2026
@phavekes phavekes requested review from johanib and pmeulen May 28, 2026 07:16
@johanib

johanib commented May 28, 2026

Copy link
Copy Markdown
Contributor

Discussed: Why not put cache inside container

@phavekes

Copy link
Copy Markdown
Member Author

Or: Should we move the federation-metadata-cache location to /tmp/ in the container? @pmeulen

@johanib johanib 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.

It seems the execute bit is needed, or docker wont run the containers.

Comment thread docker/Dockerfile.test Outdated
Comment thread docker/Dockerfile.prod Outdated
@johanib

johanib commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Investigations have concluded this branch was used to build a beta tag, which was then also given the prod tag. (https://github.com/OpenConext/Stepup-AzureMFA/pkgs/container/stepup-azuremfa%2Fstepup-azuremfa)

What happens, is when I use ./start-dev-env.sh middleware:/home/johan/project/surf/Stepup-Middleware -- --pull always --force-recreate in devconf, I pull in that image.

Which then results in:

middleware-1   | 
middleware-1   |  // Clearing the cache for the dev environment with debug false                 
middleware-1   | 
Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: exec: "/usr/local/bin/entrypoint.sh": permission denied

In devconf, the temporary workaround is.

  azuremfa:
    image: ghcr.io/openconext/stepup-azuremfa/stepup-azuremfa:${STEPUP_VERSION:-prod}
    entrypoint: ["/bin/sh", "-c", "chmod +x /usr/local/bin/entrypoint.sh && exec /usr/local/bin/entrypoint.sh \"$@\"", "--"]

This workaround is no longer needed once a fixed azuremfa image is tagged.

Co-authored-by: Johan Kromhout <60608181+johanib@users.noreply.github.com>
@phavekes phavekes requested a review from johanib June 18, 2026 14:25
Comment thread docker/entrypoint.sh
Comment on lines +4 to +5
CACHE_DIR=$(grep -E '^ *federation_metadata_cache_location:' "$PARAM_FILE" \
| cut -d ':' -f2- | tr -d '[:space:]')

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 dont know bash, but Claude suggested the following, confirmed by GPT5.5:

Suggested change
CACHE_DIR=$(grep -E '^ *federation_metadata_cache_location:' "$PARAM_FILE" \
| cut -d ':' -f2- | tr -d '[:space:]')
CACHE_DIR=$(grep -E '^ *federation_metadata_cache_location:' "$PARAM_FILE" \
| cut -d ':' -f2- | tr -d '[:space:]' | tr -d "'\"")

Finding 1 — docker/entrypoint.sh:4-5:yaml-quote-handling

YAML-quoted values break cache path extraction

parameters.yaml.dist (the file copied as parameters.yaml in both Dockerfiles) stores the value as federation_metadata_cache_location: '/var/www/html/federation-metadata' — with YAML single quotes. The cut | tr pipeline doesn't strip those quotes, so $CACHE_DIR becomes the literal string '/var/www/html/federation-metadata' (with quote characters). The [ -d "$CACHE_DIR" ] test then fails silently because no such directory exists, meaning the cache is never cleared — which is the entire purpose of this PR.

Relevant lines: docker/entrypoint.sh lines 4–5

Suggested approach: Strip YAML quotes after the tr step:

CACHE_DIR=$(grep -E '^ *federation_metadata_cache_location:' "$PARAM_FILE"
| cut -d ':' -f2- | tr -d '[:space:]' | tr -d "'"")

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.

2 participants