acoustic-carpenter-78188
11/12/2023, 6:34 AMimage_spec_1 = ImageSpec(
name="image-1",
packages=["numpy"],
registry="localhost:30000",
)
image_spec_2 = ImageSpec(
name="image-2",
packages=["pandas"],
registry="localhost:30000",
)
ps = V1PodSpec(
containers=[
V1Container(
name="primary",
image=image_spec_1,
),
V1Container(
name="secondary",
image=image_spec_2,
# use 1 cpu and 1Gi mem
resources=V1ResourceRequirements(
requests={"cpu": "1", "memory": "100Mi"},
limits={"cpu": "1", "memory": "100Mi"},
)
)
]
)
pt = PodTemplate(pod_spec=ps, primary_container_name="primary")
@task(
pod_template=pt,
)
def t1():
...
pyflyte run --remote test_workflow.py wf
Running Execution on Remote.
Image localhost:30000/image-1:gDSPZbJbEJZi4aE3JU5KsQ.. found. Skip building.
Image localhost:30000/image-2:_m2eLIYc7WSm8vWd9yzNNA.. found. Skip building.
[✔] Go to http://localhost:30080/console/projects/flytesnacks/domains/development/executions/f12b519658cb1441ab0f to see execution in the console.
FIx the issue where the primary container image in pod template can never be picked up
The original behavior is: the image of primary container is overridden with primaryContainer's image during serialization. (code)
ps = V1PodSpec(
containers=[
V1Container(
name="primary",
image="primary-image",
),
]
)
pt = PodTemplate(pod_spec=ps, primary_container_name="primary")
@task(
pod_template=pt,
)
def t():
...
In the above case, the task will use default image instead of primary-image at the end because
Note:1. We constructhere means the one get fromprimaryContainer, andget_containermeans the one in pod templateprimary container
primaryContainer in get_container, and because container_image arg in @task is empty, it will be filled with the default image.
2. We assign `primaryContaine`r's image (default image) to the primary container in the pod template (code), so the actual image (primary-image) is overridden.
The fixed behavior is that PrimaryContainer only overrides when the image in pod_template's primary container is empty. With the same example above, it now uses primary-image.
Tracking Issue
flyteorg/flyte#4070
flyteorg/flytekit
Codecov: 62.47% (-0.22%) compared to 28adeee
Codecov: 25.00% of diff hit (target 62.69%)
✅ 28 other checks have passed
28/30 successful checksacoustic-carpenter-78188
11/15/2023, 9:56 PM