PrefectHQ / prefect

Prefect is a workflow orchestration framework for building resilient data pipelines in Python.
https://prefect.io
Apache License 2.0
15.92k stars 1.56k forks source link

Docker image used with Docker-git recipe doesn't get cleaned up after deployment run #12932

Open discdiver opened 1 year ago

discdiver commented 1 year ago

First check

Bug summary

Docker image used with docker-git recipe remains in-use and dangling after deployment run.

I guess this could go under the prefect-docker library, also. This error might also be a bug with Docker.

Reproduction

`docker init` -> choose docker git

Create a deployment that uses a docker work pool and run it.

The flow runs okay in the container. 

Look in Docker Desktop -> Images

Error

See screenshot below. Image is in use and dangling. 

Clicking on the image results in the following error.

We've reported this to our error tracker.

TypeError: Cannot read properties of undefined (reading 'scanningType')

### Versions

```Text
Version:             2.10.17
API version:         0.8.4
Python version:      3.10.8
Git commit:          6d53d9b4
Built:               Thu, Jun 22, 2023 5:28 PM
OS/Arch:             darwin/arm64
Profile:             prod
Server type:         cloud

Docker Desktop 4.20.1 (110738) is currently the newest version available.

Macbook M1

prefect.yaml contents:

# Welcome to your prefect.yaml file! You can you this file for storing and managing
# configuration for deploying your flows. We recommend committing this file to source
# control along with your flow code.

# Generic metadata about this project
name: docker-git
prefect-version: 2.10.17

# build section allows you to manage and build docker images
build:
- prefect_docker.deployments.steps.build_docker_image:
    id: build_image
    requires: prefect-docker>=0.3.0
    image_name: discdiver/dg
    tag: 0.0.1
    dockerfile: auto
    push: true

# push section allows you to manage if and how this project is uploaded to remote locations
push:

# pull section allows you to provide instructions for cloning this project in remote locations
pull:
- prefect.deployments.steps.git_clone:
    repository: https://github.com/discdiver/docker-git.git
    branch: main
    access_token:

# the deployments section allows you to provide configuration for deploying flows
deployments:
- name:
  version:
  tags: []
  description:
  schedule: {}
  flow_name:
  entrypoint:
  parameters: {}
  work_pool:
    name:
    work_queue_name:
    job_variables:
      image: '{{ build_image.image }}'
- name: dg
  version:
  tags: []
  description:
  entrypoint: flows.py:hi
  parameters: {}
  work_pool:
    name: docker-work2
    work_queue_name:
    job_variables: {}
  schedule:

Additional context

Screenshot 2023-06-28 at 5 32 45 PM
desertaxle commented 1 year ago

I think this issue is caused by some unexpected behavior in DockerWorker. @discdiver do you have any logs from your Docker worker for a run that caused a dangling image?