Matt
08/17/2023, 8:26 PMMarvin
08/17/2023, 8:27 PMNate
08/17/2023, 8:28 PMMatt
08/17/2023, 8:29 PMNate
08/17/2023, 8:37 PMdocker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', ConnectionRefusedError(61, 'Connection refused'))
seems like the problem line - i think thats one of the ones you get if the client cant find an engine to talk toMatt
08/18/2023, 6:08 PMMarvin
08/18/2023, 6:09 PMprefect.yaml
file. It's like the blueprint for your Prefect deployment. It contains deployment configuration for deployments created from this file, default instructions for how to build and push any necessary code artifacts (such as Docker images), and default instructions for pulling a deployment in remote execution environments (like cloning a GitHub repository).
You can manage your deployments with a prefect.yaml
file that describes how to prepare one or more flow deployments. You can initialize your deployment configuration, which creates the prefect.yaml
file, by running the command prefect init
.
Here's a basic structure of a prefect.yaml
file:
yaml
# generic metadata
prefect-version: null
name: null
# preparation steps
build: null
push: null
# runtime steps
pull: null
# deployment configurations
deployments:
- # base metadata
name: null
version: null
tags: []
description: null
schedule: null
# flow-specific fields
flow_name: null
entrypoint: null
parameters: {}
As for creating a template for a prefect.yaml
file that pulls code from a GitLab repository and runs a Docker image in a Kubernetes cluster that is managed by a GitLab-CI pipeline, well, that's a bit more involved. I'm afraid I can't provide a full template as it would depend on the specifics of your setup. However, you would want to specify the GitLab repository in the pull
section and the Docker image in the build
and push
sections. The Kubernetes and GitLab-CI configuration would likely be external to the prefect.yaml
file, but could be triggered as part of the deployment process.Nate
08/18/2023, 6:10 PMMarvin
08/18/2023, 6:11 PMNate
08/18/2023, 6:12 PMprefect init
and choose docker-git
, you'll be off to a good startMatt
08/18/2023, 6:13 PMNate
08/18/2023, 6:14 PMMatt
08/18/2023, 6:17 PMMarvin
08/18/2023, 6:21 PMdocker info
in your terminal.
2. Docker login: You might not be logged in to Docker. You can log in by running docker login
in your terminal and entering your Docker credentials.
3. Docker permissions: Docker might not have the necessary permissions to access the Dockerfile or the context directory. Make sure the user running the Prefect command has read and write access to these resources.
4. Dockerfile location: The Dockerfile might not be in the expected location. Make sure the Dockerfile is in the same directory as your prefect.yaml
file or provide the correct path to the Dockerfile in your prefect.yaml
file.
If none of these solutions work, you might want to consider reaching out to the Prefect community or Docker support. They're humans, after all, and might be able to help you better.Matt
08/21/2023, 7:06 PMNate
08/21/2023, 7:12 PMCOPY
instead of ADD
, ADD
comes with some other quirks that can cause confusion unless you have a specific reason to use it (beyond just copying stuff from the builder machine to the eventual image)
if I'm correct to assume that what you're trying to do is copy a bunch of flows from a local directory flows
into some analogous location on the image, I'd be curious why you wouldn't just have a pull
step that retrieves the code at runtime? that way you don't have to rebuild your image each time any of the flow implementations in flows/
changesMatt
08/21/2023, 7:14 PMprefect init
command and followed the docker-git
file. What that spat out was this file:
FROM prefecthq/prefect:2.10.17-python3.11
COPY requirements.txt .
RUN pip install -r requirements.txt --trusted-host <http://pypi.python.org|pypi.python.org> --no-cache-dir
ADD flows /opt/prefect/flows
Nate
08/21/2023, 7:15 PMMatt
08/21/2023, 7:15 PMprefect deploy
but it failed to build the imageNate
08/21/2023, 7:16 PMMatt
08/21/2023, 7:16 PMmatts_image
and that’s now referenced in the prefect.yaml
file. But, when I run prefect deploy
in the repository on my specific flow, the build fails, so I was wondering if the ADD
specification was causing the issueNate
08/21/2023, 7:17 PMMatt
08/21/2023, 7:17 PMNate
08/21/2023, 7:18 PMMatt
08/21/2023, 7:18 PMRunning deployment build steps...
> Running build_docker_image step...
Step 1/5 : FROM prefecthq/prefect:2.10.17-python3.11
---> 2d96a38329f0
Step 2/5 : COPY requirements.txt .
---> Using cache
---> 419adc86766c
Step 3/5 : RUN pip install -r requirements.txt --trusted-host <http://pypi.python.org|pypi.python.org> --no-cache-dir
---> Using cache
---> 951415cef7a3
Step 4/5 : ADD Pipeline /Pipeline
---> Using cache
---> b0c79eeed8d0
Step 5/5 : LABEL io.prefect.version=2.10.17
---> Running in e9bfe3396f9e
---> 35b47a4209bb
Successfully built 35b47a4209bb
The push refers to repository [<http://docker.io/library/safety_hazard_database|docker.io/library/safety_hazard_database>]
Preparing
Preparing
Preparing
Preparing
Preparing
Preparing
Preparing
Preparing
Preparing
Preparing
Preparing
Preparing
Preparing
Preparing
Preparing
Preparing
Preparing
Preparing
Waiting
Waiting
Waiting
Waiting
Waiting
Waiting
Waiting
Waiting
Waiting
Waiting
Waiting
Waiting
Waiting
Traceback (most recent call last):
File "/Users/matthew.rand/Git/hazard-database-pipeline/.venv/lib/python3.11/site-packages/prefect/deployments/steps/core.py", line 122, in run_steps
step_output = await run_step(step, upstream_outputs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/matthew.rand/Git/hazard-database-pipeline/.venv/lib/python3.11/site-packages/prefect/deployments/steps/core.py", line 93, in run_step
result = await from_async.call_soon_in_new_thread(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/matthew.rand/Git/hazard-database-pipeline/.venv/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 292, in aresult
return await asyncio.wrap_future(self.future)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/matthew.rand/Git/hazard-database-pipeline/.venv/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 316, in _run_sync
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/matthew.rand/Git/hazard-database-pipeline/.venv/lib/python3.11/site-packages/prefect/_internal/compatibility/deprecated.py", line 149, in wrapper
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/Users/matthew.rand/Git/hazard-database-pipeline/.venv/lib/python3.11/site-packages/prefect_docker/deployments/steps.py", line 233, in build_docker_image
raise OSError(event["error"])
OSError: denied: requested access to the resource is denied
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/matthew.rand/Git/hazard-database-pipeline/.venv/lib/python3.11/site-packages/prefect/cli/_utilities.py", line 41, in wrapper
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/Users/matthew.rand/Git/hazard-database-pipeline/.venv/lib/python3.11/site-packages/prefect/utilities/asyncutils.py", line 255, in coroutine_wrapper
return call()
^^^^^^
File "/Users/matthew.rand/Git/hazard-database-pipeline/.venv/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 383, in __call__
return self.result()
^^^^^^^^^^^^^
File "/Users/matthew.rand/Git/hazard-database-pipeline/.venv/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 283, in result
return self.future.result(timeout=timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/matthew.rand/Git/hazard-database-pipeline/.venv/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 169, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/Users/matthew.rand/Git/hazard-database-pipeline/.venv/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 346, in _run_async
result = await coro
^^^^^^^^^^
File "/Users/matthew.rand/Git/hazard-database-pipeline/.venv/lib/python3.11/site-packages/prefect/cli/deploy.py", line 244, in deploy
await _run_single_deploy(
File "/Users/matthew.rand/Git/hazard-database-pipeline/.venv/lib/python3.11/site-packages/prefect/client/utilities.py", line 51, in with_injected_client
return await fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/matthew.rand/Git/hazard-database-pipeline/.venv/lib/python3.11/site-packages/prefect/cli/deploy.py", line 436, in _run_single_deploy
await run_steps(build_steps, step_outputs, print_function=app.console.print)
File "/Users/matthew.rand/Git/hazard-database-pipeline/.venv/lib/python3.11/site-packages/prefect/deployments/steps/core.py", line 150, in run_steps
raise StepExecutionError(f"Encountered error while running {fqn}") from exc
prefect.deployments.steps.core.StepExecutionError: Encountered error while running prefect_docker.deployments.steps.build_docker_image
An exception occurred.
Nate
08/21/2023, 7:21 PMimage_name
OSError: denied: requested access to the resource is denied
the build is fine, the push is referring to a restricted/non-existent repo
The push refers to repository [<http://docker.io/library/safety_hazard_database|docker.io/library/safety_hazard_database>]
you'll need to have your repo name prefixing the actual image name like
my_dockerhub_user/my_image_name
Matt
08/21/2023, 7:26 PMpush
step in the prefect.yaml
file is listed as null
. So does the push
step in my yaml file need to specify the name? Or, I guess I’m asking what needs to change in my process to correct the issue? Are you saying that in my .yaml
, i should specify image_name: some_repo/safety_hazard_database
instead of just image_name: safety_hazard_database
Nate
08/21/2023, 7:37 PMbuild
and push
step (analogous to docker's very own commands) which could look like
definitions:
work_pools:
k8s_work_pool: &k8s_work_pool
name: k8s
work_queue_name: default
job_variables:
image: "{{ build_image.image }}"
schedules:
every_ten_minutes: &every_10_minutes
interval: 600
actions:
docker_build: &docker_build
- prefect_docker.deployments.steps.build_docker_image:
id: build-image
requires: prefect-docker>=0.3.11
image_name: zzstoatzz/prefect-monorepo
tag: latest
dockerfile: Dockerfile.demo
docker_push: &docker_push
- prefect_docker.deployments.steps.push_docker_image:
id: push-image
requires: prefect-docker>=0.3.11
image_name: zzstoatzz/prefect-monorepo
tag: latest
deployments:
- name: healthcheck-docker-test
entrypoint: src/demo_project/healthcheck.py:healthcheck
schedule: *every_10_minutes
work_pool: *k8s_work_pool
build: *docker_build
push: *docker_push
note that I made some defintions
like some work_pools
, schedules
and actions
so that I could reuse these things later on other deployments
most relevant though are the docker_build
and docker_push
steps. I'm saying, for this specific deployment I want to use the build and push steps I defined abovezzstoatzz
and my image name is prefect-monorepo
so image_name: zzstoatzz/prefect-monorepo
pull
step at the top of my prefect.yaml
that automatically applies to all deployments defined here like
pull:
- prefect.deployments.steps.git_clone: &clone_repo
repository: <https://github.com/zzstoatzz/prefect-monorepo>
branch: main
access_token: null
...
rest of file
Matt
08/21/2023, 7:47 PMNate
08/21/2023, 7:53 PMpush
to your image repo (whether by providing the credentials
to the push
step, or letting docker discover your creds on your machine)
and just before runtime, your worker will need to be able to pull down your image from that repo in order to submit the flow run to your containerized execution envMatt
08/21/2023, 8:08 PMNate
08/21/2023, 8:10 PM