"Interrupted system call" on sync
This is probably distinct enough that it warrants its own issue - I'm having trouble syncing a Gitlab repository. Fails with v3.2.2 and v3.3.0, same error log:
I0524 14:20:42.972102 11 main.go:430] "level"=0 "msg"="starting up" "args"=["/git-sync"] "pid"=11
I0524 14:20:42.975376 11 main.go:694] "level"=0 "msg"="cloning repo" "origin"="https://git.biome.io/seth/airflow-combined.git" "path"="/git"
I0524 14:21:00.351196 11 main.go:586] "level"=0 "msg"="syncing git" "hash"="fb971d07a0e5b25580cd934f2aa8991da248c8ba" "rev"="HEAD"
I0524 14:21:49.643403 11 main.go:607] "level"=0 "msg"="adding worktree" "branch"="origin/master" "path"="/git/rev-fb971d07a0e5b25580cd934f2aa8991da248c8ba"
E0524 14:21:49.643540 11 main.go:455] "msg"="too many failures, aborting" "error"="Run(git worktree add /git/rev-fb971d07a0e5b25580cd934f2aa8991da248c8ba origin/master): exit status 128: { stdout: \"Preparing worktree (detached HEAD fb971d0)\\n\", stderr: \"Checking out files: 1% (16/819) \\rChecking out files: 2% (17/819) \\rChecking out files: 3% (25/819) \\rChecking out files: 4% (33/819) \\rChecking out files: 4% (35/819) \\rChecking out files: 5% (41/819) \\rChecking out files: 6% (50/819) \\rChecking out files: 7% (58/819) \\rChecking out files: 7% (59/819) \\rChecking out files: 8% (66/819) \\rChecking out files: 9% (74/819) \\rChecking out files: 9% (77/819) \\rChecking out files: 10% (82/819) \\rChecking out files: 11% (91/819) \\rChecking out files: 12% (99/819) \\rChecking out files: 13% (107/819) \\rChecking out files: 14% (115/819) \\rChecking out files: 15% (123/819) \\rChecking out files: 15% (124/819) \\rChecking out files: 16% (132/819) \\rChecking out files: 17% (140/819) \\rChecking out files: 18% (148/819) \\rChecking out files: 18% (149/819) \\rChecking out files: 19% (156/819) \\rChecking out files: 20% (164/819) \\rChecking out files: 20% (166/819) \\rChecking out files: 21% (172/819) \\rChecking out files: 22% (181/819) \\rChecking out files: 23% (189/819) \\rChecking out files: 23% (190/819) \\rChecking out files: 24% (197/819) \\rChecking out files: 25% (205/819) \\rChecking out files: 26% (213/819) \\rfatal: cannot create directory at 'cea/cea': Interrupted system call\\n\" }" "failCount"=0
Here is my k8s config:
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: symlink-azurefile-2
provisioner: kubernetes.io/azure-file
mountOptions:
- mfsymlinks
---
apiVersion: v1
kind: ConfigMap
metadata:
name: airflow-gitsync
data:
GIT_SYNC_REPO: [gitlab path].git
GIT_SYNC_BRANCH: master
GIT_SYNC_ROOT: '/git'
GIT_SYNC_DEST: sync
GIT_SYNC_WAIT: '300'
GIT_SYNC_DEPTH: '1'
GIT_SYNC_USERNAME: gitsync
GIT_SYNC_PASSWORD: [pwd]
GIT_PASSWORD: [pwd]
GIT_SYNC_SUBMODULES: recursive
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: airflow-combined-repo-volume-claim
spec:
resources:
requests:
storage: 2Gi
storageClassName: symlink-azurefile-2
accessModes:
- ReadWriteMany
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "airflow.fullname" . }}-gitsync
labels:
app: gitsync
{{ include "airflow.labels" . | indent 4 }}
spec:
replicas: {{ .Values.airflow.web.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "airflow.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app: gitsync
template:
metadata:
labels:
app: gitsync
app.kubernetes.io/name: {{ include "airflow.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
serviceAccountName: {{ include "airflow.serviceAccountName" . }}
containers:
- name: git-sync-clone
image: k8s.gcr.io/git-sync/git-sync:v3.3.0
imagePullPolicy: IfNotPresent
envFrom:
- configMapRef:
name: airflow-gitsync
volumeMounts:
- mountPath: /git
name: airflow-combined-repo-volume
securityContext:
runAsUser: 0
volumes:
- name: airflow-combined-repo-volume
persistentVolumeClaim:
claimName: airflow-combined-repo-volume-claim
imagePullSecrets:
- name: regcred
Any ideas?
Originally posted by @sglickman in https://github.com/kubernetes/git-sync/issues/384#issuecomment-846463992
There are no submodules in this repository, and the repository is 30.3MB in size.
edit: gitlab claims this is 30.3MB in size but when I download it, it's closer to 100MB.
I wonder if this has to do with Azure specifically. I don't really know what I'm talking about, but:
- azurefile seemingly requires the
securityContext: runAsUser: 0config in the git-sync container (https://github.com/Azure/AKS/issues/97) - i wonder if running
kubectl logs $CONTAINER_IDor some other kubernetes internal process interrupts the initial git sync if they're both the same user?
no clue what else to go on
am now wondering if this is related to this issue
Thought that Go 1.16 would fix it so I built a local git-sync image with that version but it still fails with the same issue. I now think it's an Azure/SMB related thing, there are a lot of reports of CIFS "interrupted system call" errors and seemingly the only way to solve it is by using an nfs volume instead, which has preview support, it seems.
I'm currently attempting to solve this with an extremely janky DIY git-sync, which pulls down the repository to a folder which isn't the PVC mount and then copies it over to the mounted volume share in the hopes that this will be a faster operation than git clone directly onto the volume, and thus run into the error less frequently.
For anyone else in the same boat thanks to Azure, here's the DIY git-pull I put together which seems to be working.
entrypoint.sh:
#!/bin/sh
export RED='\033[0;31m'
export NC='\033[0m' # No Color
# Apparently there are massive issues with mounting SMB
# volumes using CIFS, which is what Azure uses. The
# solution here is to use NFS but as of this writing
# it (a) was only in preview, (b) needed a specific premium
# registration which I'm not sure we have, and (c) could
# only register 100G at a time.
# See https://docs.microsoft.com/en-us/azure/aks/azure-files-csi#nfs-file-shares
# for more information.
#
# As a consequence, the standard git-sync container fails
# for large-ish repositories with "Interrupted system call"
# errors, and so git-pull is our workaround.
#
# Our PVC is mounted to /git over CIFS, and the basic theory is
# by using a staging area to do the "heavy lifting" of cloning
# and pulling changes in, we won't run into the Interrupted system call
# errors. Once we've retrieved the repository on a local folder,
# it should be a relatively quick operation to copy it over to our
# shared mounted folder (to be picked up by Airflow webserver and scheduler)
# and since it should be fast we will hopefully avoid the CIFS errors.
#
# The /staging folder is our staging area, and we perform
# the initial clone into this local folder.
# We have two folders on the shared mounted drive:
# - /git/git_clone
# - /git/git_clone_2
# We use a symlink (/git/repo) to toggle between the two once
# a pull-copy cycle has completed, so Airflow never sees an incomplete
# set of files.
# prints messages with date/time and in red.
ColorLog () {
echo -e "${RED}$(date): $1${NC}"
}
rm -rf /staging
mkdir /staging
chmod -R 777 /staging
cd /staging
# Initial clone operation.
ColorLog "Starting initial clone."
git clone https://[username]:[pwd]@[repo-url] .
ColorLog "Done with initial clone."
cp --verbose -R /staging /git/git_clone
ColorLog "Done with initial SMB copy into git_clone."
# change directory to the shared drive, since it's important to use relative paths
# for the symlink.
cd /git
ln -sf git_clone repo
ColorLog "Created initial symlink to git_clone"
# change back to our staging directory for the next pull, in 180 seconds.
cd /staging
sleep 180
WORKING_DIR=git_clone
# Loop forever so the container remains alive.
while true
do
git fetch origin
reslog=$(git log HEAD..origin/master --oneline)
if [[ "${reslog}" != "" ]] ; then
git pull
ColorLog "Git Pulled."
ColorLog "Changing working directory from ${WORKING_DIR}."
# /git/repo points to WORKING_DIR, so flip.
if [[ "${WORKING_DIR}" == "git_clone_2" ]] ; then
WORKING_DIR=git_clone
else
WORKING_DIR=git_clone_2
fi
ColorLog "Working directory changed to ${WORKING_DIR}."
rm -rf /git/$WORKING_DIR
ColorLog "Cleared ${WORKING_DIR}"
cp --verbose -R /staging /git/$WORKING_DIR
ColorLog "Copied into ${WORKING_DIR}"
cd /git
# For some reason we can't overwrite the symlink so
# we need to remove it and then re-create it.
rm repo
ln -sf $WORKING_DIR repo
ColorLog "Created symlink to ${WORKING_DIR}"
cd /staging
else
ColorLog "No updates found, sleeping until next check."
fi
sleep 180
done
Dockerfile:
FROM alpine/git:v2.30.2
ADD . /usr/local/git
WORKDIR "/usr/local/git"
RUN chmod -R 777 /git
RUN chmod u+x entrypoint.sh
ENTRYPOINT ["/usr/local/git/entrypoint.sh"]
Wow. I am not sure what to say on this one. Setting runAsUser: 0 is (IMO) a horrible answer. There's no reason for git-sync to run as root. does setting fsGroup help?
I saw this: https://codeyarns.com/tech/2020-08-26-git-interrupted-system-call-error.html which seems plausible
Now the fun part - this does not seem like a git-sync bug, so I think we should close this issue. :(