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

Kaniko extraFlags don't seem to work for --cache-repo #5689

Closed
alexkuretz opened this issue Jan 31, 2024 · 2 comments · Fixed by #6149
Closed

Kaniko extraFlags don't seem to work for --cache-repo #5689

alexkuretz opened this issue Jan 31, 2024 · 2 comments · Fixed by #6149
Assignees

Comments

@alexkuretz
Copy link

alexkuretz commented Jan 31, 2024

Bug

Current Behavior

Trying to test various Kaniko configurations with AWS ECR so setting the --cache-repo parameter in extraArgs in project.garden.yml.

    buildMode: kaniko
    kaniko:
      extraFlags: ["--cache-repo", "${var.aws-account}.dkr.ecr.us-west-2.amazonaws.com/${var.service}"]

This fails due to a regex rejecting the second parameter.

Invalid format for a kaniko flag. Expected it to match /--([a-zA-Z]*)/, actually got: accountnumber.dkr.ecr.us-west-2.amazonaws.com/myproject

So I tried setting it as a single string to bypass the regex:

    buildMode: kaniko
    kaniko:
      extraFlags: ["--cache-repo ${var.aws-account}.dkr.ecr.us-west-2.amazonaws.com/${var.service}"]

And get this:

build.task-py → [verbose] Starting Pod kaniko-myservice-0f8ae4 with command 'sh -c /kaniko/executor "--context" "dir:///.garden/context" "--dockerfile" "Dockerfile" "--destination" "accountnumber.dkr.ecr.us-west-2.amazonaws.com/myproject/myservice:v-4e23f7add0" "--cache-repo accountnumber.dkr.ecr.us-west-2.amazonaws.com/myproject" "--build-arg" "GARDEN_MODULE_VERSION=v-4e23f7add0" "--build-arg" "GARDEN_ACTION_VERSION=v-4e23f7add0" "--build-arg" "RUN_ENV=dev" "--target" "prod";
Error: unknown command "GARDEN_MODULE_VERSION=v-4e23f7add0" for "executor"
Run 'executor --help' for usage.

It appears the --cache-repo parameter needs to be a separate string but the garden regex won't allow it.

Expected behavior

To be able to supply a cache-repo to kaniko per garden documentation.

Reproducible example

Info above.

Workaround

Don't know of any workaround, the same regex is run if I try to put the extraFlags in the container spec.

Suggested solution(s)

Improve or remove regex.

Additional context

cluster-buildkit doesn't check formatting of extraFlags from the spec, not sure why kaniko does? I tested both 0.13 and 0.12 versions, wondering if this ever worked, doesn't look like that code has changed in over 3 years.

Your environment

Ubuntu Linux 22.04
EKS
garden 0.12.67 and 0.13.24

@alexkuretz alexkuretz added the bug label Jan 31, 2024
@mattpolzin
Copy link
Contributor

I am hitting this bug when trying to set build-args as well. It seems that if you set the config up to pass a build arg the same way Garden does under the hood with its own build args, Garden will complain about the value being an invalid format (same reason as reported above).

@10ko 10ko assigned 10ko and stefreak and unassigned 10ko Jun 6, 2024
stefreak added a commit that referenced this issue Jun 6, 2024
@stefreak
Copy link
Member

stefreak commented Jun 6, 2024

@alexkuretz @mattpolzin thanks for the reports, this was actually an easy fix, I changed the regex to allow dashes. PR at #6149 and will hopefully make it into the next release 👍

Once the PR is merged, you can try it out using garden self-update bonsai-edge.

github-merge-queue bot pushed a commit that referenced this issue Jun 6, 2024
* fix: allow dashes in kaniko options

Fixes #5689

* test: fix test assertion

* chore: satisfy prettier

* chore: satisfy linter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants