Tom
08/05/2025, 10:03 AMMarvin
08/05/2025, 10:03 AMMarvin
08/05/2025, 10:04 AMyaml
initContainers:
- name: init-permissions
image: busybox
command: ['sh', '-c', 'chown -R 1000:1000 /opt/prefect']
volumeMounts:
- name: prefect-data
mountPath: /opt/prefect
b. Modify SecurityContext Safely:
If you need to use a custom securityContext, ensure it includes the minimum required permissions:
yaml
securityContext:
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
allowPrivilegeEscalation: false
3. Best Practices:
- Keep the Git clone directory writable by the worker process
- Ensure the worker has read access to the necessary SSH keys or credentials
- Consider using HTTPS instead of SSH for Git operations if possible
4. Debugging Steps:
1. Check the full pod logs for more detailed error messages
2. Verify the permissions on the mounted volumes
3. Confirm that your Git credentials are properly configured and accessible
Could you share:
1. The specific securityContext configuration you're trying to use?
2. Are you using SSH or HTTPS for your Git repository access?
3. Are you using any custom volume mounts in your work pool configuration?
This information would help me provide more targeted assistance for your specific setup.
Also, while the default user works, it's understandable that you might need to run with custom security contexts for compliance or security reasons. We can work on finding a solution that maintains security while allowing the Git clone operation to succeed.Tom
08/05/2025, 10:06 AMTom
08/05/2025, 10:07 AMMarvin
08/05/2025, 10:07 AMMarvin
08/05/2025, 10:08 AMupdated-job-template.json
) and update your work pool:
bash
prefect work-pool update your-pool-name --base-job-template updated-job-template.json
To help debug if you're still having issues:
1. Can you check the full pod logs and see if there are any permission-related messages before the Git clone error?
2. Are there any specific error messages in the logs about file access or directory permissions?
3. Could you confirm if the Git clone operation is trying to clone into the volume you've mounted, and if that volume has the correct permissions?
Also, as a temporary test, you could try setting the securityContext with slightly more permissive settings to isolate whether it's purely a permissions issue:
yaml
securityContext:
runAsUser: 66537
runAsGroup: 66537
fsGroup: 66537
allowPrivilegeEscalation: false
runAsNonRoot: true
Let me know if you need any clarification on these steps or if you'd like me to explain any part in more detail.Marvin
08/05/2025, 10:14 AMMarvin
08/05/2025, 10:14 AMTom
08/05/2025, 10:15 AMWorker 'KubernetesWorker 41f07e47-3ad1-4e1c-8545-9f40d0120d59' submitting flow run '2e1a803c-5d11-4bdb-99b9-0adb70fe456b'
11:12:13 AM
prefect.flow_runs.worker
Creating Kubernetes job...
11:12:13 AM
prefect.flow_runs.worker
Completed submission of flow run '2e1a803c-5d11-4bdb-99b9-0adb70fe456b'
11:12:13 AM
prefect.flow_runs.worker
Opening process...
11:12:22 AM
prefect.flow_runs.runner
> Running git_clone step...
11:12:23 AM
prefect.flow_runs
Failed to clone repository '<https://git.drwholdings.com/ChipQA/Clue-Prefect.git>' with exit code 128.
11:12:26 AM
prefect.flow_runs
Unexpected exception encountered when trying to load flow
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/prefect/deployments/steps/core.py", line 163, in run_steps
step_output = await run_step(step, upstream_outputs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/prefect/deployments/steps/core.py", line 134, in run_step
result = await from_async.call_soon_in_new_thread(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 374, in aresult
return await asyncio.wrap_future(self.future)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 399, in _run_sync
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/prefect/_internal/compatibility/async_dispatch.py", line 94, in wrapper
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/prefect/deployments/steps/pull.py", line 204, in git_clone
run_coro_as_sync(_pull_git_repository_with_retries(storage))
File "/usr/local/lib/python3.11/site-packages/prefect/utilities/asyncutils.py", line 197, in run_coro_as_sync
result = from_sync.call_in_new_thread(coroutine_wrapper)
....
Marvin
08/05/2025, 10:15 AMMarvin
08/05/2025, 10:15 AM<http://git.drwholdings.com|git.drwholdings.com>
). The error code 128 from Git typically indicates permission or authentication issues. Let me help you troubleshoot this more specifically.
Given that you're using HTTPS and an internal Git repository, here are the most likely issues and their solutions:
1. Git Credentials Access
First, let's ensure your Git credentials are properly configured. You'll need to modify your work pool job template to include Git credentials:
yaml
kubernetes:
# Existing security context
securityContext:
runAsUser: 66537
runAsGroup: 66537
fsGroup: 66537
# Add environment variables for Git
env:
- name: GIT_CONFIG_GLOBAL
value: /opt/prefect/git/.gitconfig
- name: GIT_CREDENTIALS
valueFrom:
secretKeyRef:
name: git-credentials
key: credentials
# Mount points for Git configuration
volumeMounts:
- name: git-config
mountPath: /opt/prefect/git
# Your existing volume mounts...
volumes:
- name: git-config
emptyDir: {}
# Your existing volumes...
# Add an init container to set up Git configuration
initContainers:
- name: git-init
image: alpine/git
command:
- sh
- -c
- |
mkdir -p /opt/prefect/git
git config --global --add safe.directory '*'
git config --global http.sslVerify false # Only if needed for internal certificates
echo "https://\${GIT_USERNAME}:\${GIT_PASSWORD}@git.drwholdings.com" > /opt/prefect/git/.git-credentials
chmod 600 /opt/prefect/git/.git-credentials
chown -R 66537:66537 /opt/prefect/git
env:
- name: GIT_USERNAME
valueFrom:
secretKeyRef:
name: git-credentials
key: username
- name: GIT_PASSWORD
valueFrom:
secretKeyRef:
name: git-credentials
key: password
volumeMounts:
- name: git-config
mountPath: /opt/prefect/git
2. Create the Kubernetes Secret
Before applying the above configuration, create a Kubernetes secret with your Git credentials:
bash
kubectl create secret generic git-credentials \
--from-literal=username=your-username \
--from-literal=password=your-password \
--from-literal=credentials="<https://your-username:your-password@git.drwholdings.com>"
3. SSL Certificate Handling
If your internal Git server uses custom certificates, you might need to add them:
yaml
kubernetes:
volumes:
- name: ca-certificates
configMap:
name: custom-ca-certificates
volumeMounts:
- name: ca-certificates
mountPath: /etc/ssl/certs/custom-ca.crt
subPath: ca.crt
env:
- name: GIT_SSL_CAINFO
value: /etc/ssl/certs/custom-ca.crt
4. Debugging Steps
To help diagnose issues, add these environment variables to your job template:
yaml
env:
- name: GIT_TRACE: "1"
- name: GIT_CURL_VERBOSE: "1"
5. Alternative Approach Using Git Config
If the above doesn't work, try this alternative approach:
yaml
initContainers:
- name: git-setup
image: alpine/git
command:
- sh
- -c
- |
mkdir -p /opt/prefect/git
git config --global --add safe.directory '*'
git config --global credential.helper 'store --file=/opt/prefect/git/.git-credentials'
git config --global http.sslVerify false # Only if needed
chown -R 66537:66537 /opt/prefect/git
volumeMounts:
- name: git-config
mountPath: /opt/prefect/git
To implement these changes:
1. Save the modified configuration as a JSON file (e.g., updated-job-template.json
)
2. Update your work pool:
bash
prefect work-pool update your-pool-name --base-job-template updated-job-template.json
Questions to help further diagnose:Marvin
08/05/2025, 10:15 AM