Hi Prefect Experts, am getting *`InterruptedError:...
# prefect-community
a
Hi Prefect Experts, am getting
InterruptedError: denied: access forbidden
error when trying prefect.Docker | Pushing image to the registry..., Can anyone help me - how to /where to specify the registry username passwords in the code ? or anywhere it matters
Copy code
import prefect
from prefect import task, Flow
from prefect.environments.storage import Docker
from prefect.run_configs import KubernetesRun

@task(log_stdout=True)
def log_my_stdout(print_message):
    print("I will log this ",print_message)


with Flow("KubeTestFlow") as f:
    log_my_stdout("Example!")

f.storage = Docker( registry_url="hakko.sekai.dev:5050/sekai-backend/", image_name="k8s-job-flow", image_tag="0.1.0" )

f.run_config = KubernetesRun(labels=["DEV"],job_template_path="/home/ajith/prefect/job_spec.yaml")
out = f.register(project_name="kubeTest")
this is my code
Complete Stacktrace
Copy code
Successfully tagged hakko.sekai.dev:5050/sekai-backend/k8s-job-flow:0.1.0
[2021-02-23 06:35:32+0530] INFO - prefect.Docker | Pushing image to the registry...
Traceback (most recent call last):
  File "kubeTutorial.py", line 20, in <module>
    out = f.register(project_name="kubeTest")
  File "/usr/local/lib/python3.8/dist-packages/prefect/core/flow.py", line 1668, in register
    registered_flow = client.register(
  File "/usr/local/lib/python3.8/dist-packages/prefect/client/client.py", line 783, in register
    serialized_flow = flow.serialize(build=build)  # type: Any
  File "/usr/local/lib/python3.8/dist-packages/prefect/core/flow.py", line 1450, in serialize
    storage = self.storage.build()  # type: Optional[Storage]
  File "/usr/local/lib/python3.8/dist-packages/prefect/storage/docker.py", line 303, in build
    self._build_image(push=push)
  File "/usr/local/lib/python3.8/dist-packages/prefect/storage/docker.py", line 378, in _build_image
    self.push_image(full_name, self.image_tag)
  File "/usr/local/lib/python3.8/dist-packages/prefect/storage/docker.py", line 586, in push_image
    raise InterruptedError(line.get("error"))
InterruptedError: denied: access forbidden
f
If you’re using an ECS registry you need to specify your AWS credentials. You can do that in a few different places, e.g. in the Run config or as arguments when you start the prefect agent. I hope this helps!
a
Thank you @Fina Silva-Santisteban, our k8s cluster in on DigitalOcean , Docker registry is on GitLabs , i'll try that out , Any prefect document related to this ? Thank you!
f
@Ajith Kumara Beragala Acharige Lal ah sorry, now I see your code snippets! Im using the ECS run config and that one has a param
run_task_kwargs
which I use for setting things like cluster name and launchtype, but for that to work I must have set the permissions correctly on aws. I save env variables in my Docker storage using the
env_vars
param and then use prefect secrets to make them available. Even though it’s not Kubernetes or gitlab registry setup, I hope this helps!
a
Thank you @Fina Silva-Santisteban, this helps lot !
c
Since this happens on push it sounds like a potential issue with your local setup — prefect directly uses your local docker daemon, so ensuring that you can run
docker push
commands from the command line might help you identify where the issue is