kaniko icon indicating copy to clipboard operation
kaniko copied to clipboard

corruptedEnvironmentError showing up when updating conda requirements

Open VasLem opened this issue 1 year ago • 0 comments

Let's say I have this example Dockerfile:

FROM ubuntu:22.04
ENV R_VERSION=4.3.2
ENV PYTHON_VERSION=3.10

ARG DEBIAN_FRONTEND=noninteractive

SHELL ["/bin/bash", "-c"]
USER root
ENV HOME=/home/root
WORKDIR $HOME
ENV PATH="$PATH:$HOME/miniforge3/bin"
RUN conda config --add channels bioconda && \
    conda config --add channels conda-forge && \
    conda config --set channel_priority flexible
RUN conda update -y -n base -c conda-forge conda 
RUN conda install -y conda-libmamba-solver python=$PYTHON_VERSION r-base=$R_VERSION 
RUN conda install -y bedops r-r.utils 

and this cloudbuild.yaml :

steps:
- name: 'gcr.io/kaniko-project/executor:latest'
  args:
  - --destination=europe-west1-docker.pkg.dev/MY_REPO/MY_IMAGE:latest
  - --cache=true
  - --compressed-caching=false
  - --cache-copy-layers=true

which needs all of those flags for a variety of stupid reasons (see this).

Then, I use this command

gcloud builds submit --async --region=europe-west1 --project=MY_PROJECT --default-buckets-behavior REGIONAL_USER_OWNED_BUCKET --machine-type=e2-highcpu-8

to make a build, successfully. If afterwards, I add/modify any line that has to do with conda, for example by appending this line:

RUN conda install samtools -y

and retry to build, I am always getting something like this error:

CorruptedEnvironmentError: The target environment has been corrupted. Corrupted environments most commonly
occur when the conda process is force-terminated while in an unlink-link
transaction.
  environment location: /home/root/miniforge3
  corrupted file: /home/root/miniforge3/conda-meta/.wh.ruamel.yaml-0.18.6-py312h98912ed_0.json

error building image: error building stage: failed to execute command: waiting for process to exit: exit status 1

(The corrupted package could be any package installed in the previous build.)

which forces me to delete the cache and retry installation. Of course this runs alright, however kaniko completely loses its purpose, and is only meaningful when I change other things in the Dockerfile. Of course, changing miniconda requirements is the most frequent operation I do, as I am using Python and R, and any new dependency coming up needs to have the image updated.

Description Yes/No
Please check if this a new feature you are proposing
  • - [ ]
Please check if the build works in docker but not in kaniko
  • - [X]
Please check if this error is seen when you use --cache flag
  • - [X]
Please check if your dockerfile is a multistage dockerfile
  • - [ ]

VasLem avatar Oct 09 '24 14:10 VasLem