GoogleContainerTools / skaffold

Easy and Repeatable Kubernetes Development
https://skaffold.dev/
Apache License 2.0
15.03k stars 1.62k forks source link

Skaffold tried to pull image for wrong plaform #9161

Open matanw opened 1 year ago

matanw commented 1 year ago

Expected behavior

"skaffold build" should work on my skaffold yaml

Actual behavior

Skaffold failed to pull remote image:

Generating tags...

When I execute "docker pull mcr.microsoft.com/dotnet/framework/wcf:latest" it worked

Information

apiVersion: skaffold/v4beta4
kind: Config
build:
    artifacts:
        - image: my-image
          context: .
          docker:
            dockerfile: ./Dockerfile
          platforms:
            - windows

Dockerfile: FROM mcr.microsoft.com/dotnet/framework/wcf:latest

Steps to reproduce the behavior

run "skaffold build"

Root cause: When code retrive image from remote - https://github.com/GoogleContainerTools/skaffold/blob/85de8d7a9b394ec8b3f3a4a4fef1463fb628dfb6/pkg/skaffold/docker/image.go#L299 It doesn't use any platform that it get from caller, but v1.Platform{}, so client try to pull images for default plafrom, mean linux

renzodavid9 commented 11 months ago

Hey @matanw, thanks for opening this issue. It looks like is failing while checking the cache, could you please try skaffold build --cache-artifacts=false and let us know how it goes? From the info you shared, I understand you are running the command from a Windows OS; we'll need some time to figure out a way to setup an environment with a Windows machine. Thanks!

matanw commented 11 months ago

Yes indeed it solves it. By the way, the preblem, and the wordaround, can be repuduced on Linux (even on linux with "--cache-artifacts=false" I get another error)

renzodavid9 commented 11 months ago

Hey @matanw, cool! Good to know that it works with the flag, however it would be better if we can make it work without it (--cache-artifacts is true by default). And yes, I was able to get some behaviour on mac, but as you mentioned, it throws another error, guessing is because we're trying to build a windows container on mac(?).

We'll take a look to how to solve this, as you pointed, is related with the piece of code from your first comment. Thanks!

matanw commented 3 months ago

When I try to build windows artifacts that is cloud code based from my linux machine, even workaround of " --cache-artifacts=false " do not work

my skaffold.yaml:

apiVersion: skaffold/v4beta4
kind: Config
build:
    artifacts:
        - image: my-image
          context: .
          docker:
            dockerfile: ./Dockerfile
          platforms:
            - windows
    googleCloudBuild: {}

My Dockerfile

FROM mcr.microsoft.com/dotnet/framework/wcf:latest

My commands

> skaffold build --cache-artifacts=false -d europe-docker.pkg.dev/my-repo/matan 
Generating tags...
 - my-image -> [europe-docker.pkg.dev/modernize-dev/matan/my-image:latest](http://europe-docker.pkg.dev/modernize-dev/matan/my-image:latest)
Some taggers failed. Rerun with -vdebug for errors.
Starting build...
Building [my-image]...
Target platforms: [windows/amd64]
getting dependencies for "my-image": parsing ONBUILD instructions: retrieving image "mcr.microsoft.com/dotnet/framework/wcf:latest": no child with platform linux/amd64 in index mcr.microsoft.com/dotnet/framework/wcf:latest