Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s2i does not update Cmd after assemble with podman service #1082

Open
lunicon opened this issue Dec 20, 2021 · 6 comments
Open

s2i does not update Cmd after assemble with podman service #1082

lunicon opened this issue Dec 20, 2021 · 6 comments
Labels
lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.

Comments

@lunicon
Copy link

lunicon commented Dec 20, 2021

Run podman image created with s2i fail with error

podman run --rm -it b2bpartners

tar: Refusing to read archive contents from terminal (missing -f option?)
tar: Error is not recoverable: exiting now

podman inspect --format='{{ json .Config.Cmd }}' b2bpartners

["/bin/sh","-c","tar -C /app/builder -xf - && /app/s2i/assemble"]

Looks like s2i doesnt commit Cmd:[/app/s2i/run] as it show in build log

s2i --loglevel=5 --url=unix:///run/podman/podman.sock build ./build/libs s2i-payara:5.2021.8_J8 localhost/b2bpartners

I1220 10:37:46.066228 120 build.go:51] Running S2I version "v1.3.1"
I1220 10:37:46.422745 120 docker.go:490] Using locally available image "s2i-payara:5.2021.8_J8"
I1220 10:37:46.435409 120 build.go:164]
Builder Name: Payara Micro 5.2021.8 S2I Builder
Builder Image: s2i-payara:5.2021.8_J8
Source: ./build/libs
Output Image Tag: localhost/b2bpartners
Environment:
Labels:
Incremental Build: disabled
Remove Old Build: disabled
Builder Pull Policy: if-not-present
Previous Image Pull Policy: if-not-present
Quiet: disabled
Layered Build: disabled
Docker Endpoint: unix:///run/podman/podman.sock

I1220 10:37:46.448490 120 docker.go:490] Using locally available image "s2i-payara:5.2021.8_J8"
I1220 10:37:46.483483 120 docker.go:490] Using locally available image "s2i-payara:5.2021.8_J8"
I1220 10:37:46.483591 120 docker.go:730] Image sha256:e04d8305f9d0595efb33d01ae9523d25de43ba4c54f2ac33ae10be12a415eb38 contains io.openshift.s2i.scripts-url set to "image:///app/s2i"
I1220 10:37:46.483611 120 scm.go:20] DownloadForSource ./build/libs
I1220 10:37:46.487818 120 sti.go:204] Preparing to build localhost/b2bpartners
I1220 10:37:46.488501 120 download.go:38] Copying sources from "./build/libs" to "/tmp/s2i175934027/upload/src"
I1220 10:37:46.493236 120 ignore.go:66] .s2iignore file does not exist
I1220 10:37:46.513723 120 fs.go:269] F "build/libs/b2bpartners.ear" -> "/tmp/s2i175934027/upload/src/b2bpartners.ear"
I1220 10:37:49.577072 120 install.go:261] Using "assemble" installed from "image:///app/s2i/assemble"
I1220 10:37:49.577188 120 install.go:261] Using "run" installed from "image:///app/s2i/run"
I1220 10:37:49.577212 120 install.go:261] Using "save-artifacts" installed from "image:///app/s2i/save-artifacts"
I1220 10:37:49.577339 120 ignore.go:66] .s2iignore file does not exist
I1220 10:37:49.577420 120 sti.go:213] Clean build will be performed
I1220 10:37:49.577503 120 sti.go:216] Performing source build from ./build/libs
I1220 10:37:49.577518 120 sti.go:227] Running "assemble" in "localhost/b2bpartners"
I1220 10:37:49.577531 120 sti.go:585] Using image name s2i-payara:5.2021.8_J8
I1220 10:37:49.588720 120 docker.go:490] Using locally available image "s2i-payara:5.2021.8_J8"
I1220 10:37:49.588835 120 sti.go:465] No user environment provided (no environment file found in application sources)
I1220 10:37:49.589397 120 sti.go:703] starting the source uploading ...
I1220 10:37:49.589428 120 tar.go:238] Adding "/tmp/s2i175934027/upload" to tar ...
I1220 10:37:49.613801 120 docker.go:730] Image sha256:e04d8305f9d0595efb33d01ae9523d25de43ba4c54f2ac33ae10be12a415eb38 contains io.openshift.s2i.scripts-url set to "image:///app/s2i"
I1220 10:37:49.613907 120 docker.go:804] Base directory for S2I scripts is '/app/s2i'. Untarring destination is '/app/builder'.
I1220 10:37:49.613924 120 docker.go:961] Setting "/bin/sh -c tar -C /app/builder -xf - && /app/s2i/assemble" command for container ...
I1220 10:37:49.614033 120 docker.go:970] Creating container with options {Name:"s2i_payara_5_2021_8_J8_57c58a03" Config:{Hostname: Domainname: User: AttachStdin:false AttachStdout:true AttachStderr:false ExposedPorts:map[] Tty:false OpenStdin:true StdinOnce:true Env:[] Cmd:[/bin/sh -c tar -C /app/builder -xf - && /app/s2i/assemble] Healthcheck: ArgsEscaped:false Image:s2i-payara:5.2021.8_J8 Volumes:map[] WorkingDir: Entrypoint:[] NetworkDisabled:false MacAddress: OnBuild:[] Labels:map[] StopSignal: StopTimeout: Shell:[]} HostConfig:&{Binds:[] ContainerIDFile: LogConfig:{Type: Config:map[]} NetworkMode: PortBindings:map[] RestartPolicy:{Name: MaximumRetryCount:0} AutoRemove:false VolumeDriver: VolumesFrom:[] CapAdd:[] CapDrop:[] Capabilities:[] DNS:[] DNSOptions:[] DNSSearch:[] ExtraHosts:[] GroupAdd:[] IpcMode: Cgroup: Links:[] OomScoreAdj:0 PidMode: Privileged:false PublishAllPorts:false ReadonlyRootfs:false SecurityOpt:[] StorageOpt:map[] Tmpfs:map[] UTSMode: UsernsMode: ShmSize:67108864 Sysctls:map[] Runtime: ConsoleSize:[0 0] Isolation: Resources:{CPUShares:0 Memory:0 NanoCPUs:0 CgroupParent: BlkioWeight:0 BlkioWeightDevice:[] BlkioDeviceReadBps:[] BlkioDeviceWriteBps:[] BlkioDeviceReadIOps:[] BlkioDeviceWriteIOps:[] CPUPeriod:0 CPUQuota:0 CPURealtimePeriod:0 CPURealtimeRuntime:0 CpusetCpus: CpusetMems: Devices:[] DeviceCgroupRules:[] DeviceRequests:[] DiskQuota:0 KernelMemory:0 KernelMemoryTCP:0 MemoryReservation:0 MemorySwap:0 MemorySwappiness: OomKillDisable: PidsLimit: Ulimits:[] CPUCount:0 CPUPercent:0 IOMaximumIOps:0 IOMaximumBandwidth:0} Mounts:[] MaskedPaths:[] ReadonlyPaths:[] Init:}} ...
I1220 10:37:49.621379 120 tar.go:336] Adding to tar: /tmp/s2i175934027/upload/scripts as scripts
I1220 10:37:49.714654 120 docker.go:1002] Attaching to container "c05679c19f8c0b8fa119c1a28122dc7524cdfe37671a2983e94e691576ddccae" ...
I1220 10:37:50.128002 120 docker.go:1013] Starting container "c05679c19f8c0b8fa119c1a28122dc7524cdfe37671a2983e94e691576ddccae" ...
I1220 10:37:50.142695 120 tar.go:336] Adding to tar: /tmp/s2i175934027/upload/src as src
....
I1220 10:38:39.713353 120 sti.go:711] ---> Assembled in 48 seconds
I1220 10:38:39.724063 120 docker.go:1044] Waiting for container "c05679c19f8c0b8fa119c1a28122dc7524cdfe37671a2983e94e691576ddccae" to stop ...
I1220 10:38:39.754414 120 docker.go:1069] Invoking PostExecute function
I1220 10:38:39.754451 120 postexecutorstep.go:68] Skipping step: store previous image
I1220 10:38:39.754461 120 postexecutorstep.go:117] Executing step: commit image
I1220 10:38:39.760785 120 postexecutorstep.go:523] Checking for new Labels to apply...
I1220 10:38:39.760889 120 postexecutorstep.go:531] Creating the download path '/tmp/s2i175934027/metadata'
I1220 10:38:39.761048 120 postexecutorstep.go:465] Downloading file "/tmp/.s2i/image_metadata.json"
I1220 10:38:39.809026 120 postexecutorstep.go:539] unable to download and extract 'image_metadata.json' ... continuing
I1220 10:38:39.833631 120 docker.go:1103] Committing container with dockerOpts: {Reference:localhost/b2bpartners Comment: Author: Changes:[] Pause:false Config:0xc000536280}, config: {Hostname: Domainname: User:1000 AttachStdin:false AttachStdout:false AttachStderr:false ExposedPorts:map[] Tty:false OpenStdin:false StdinOnce:false Env:[] Cmd:[/app/s2i/run] Healthcheck: ArgsEscaped:false Image: Volumes:map[] WorkingDir: Entrypoint:[] NetworkDisabled:false MacAddress: OnBuild:[] Labels:map[description:Payara Micro 5.2021.8 S2I for OpenShift io.k8s.description:Payara Micro 5.2021.8 S2I Image io.k8s.display-name:localhost/b2bpartners io.openshift.expose-services:8080:http,8443:https io.openshift.s2i.build.image:s2i-payara:5.2021.8_J8 io.openshift.s2i.build.source-location:./build/libs io.openshift.s2i.destination:/app/builder io.openshift.s2i.scripts-url:image:///app/s2i io.openshift.tags:builder,payara micro 5.2021.8,javaee,microprofile] StopSignal: StopTimeout: Shell:[]}
Getting image source signatures
Copying blob 9f54eef41275 skipped: already exists
Copying blob 785785172586 skipped: already exists
Copying blob bd818254e98f skipped: already exists
Copying blob 7dc3e0f19365 skipped: already exists
Copying blob b18b4f4aba0c skipped: already exists
Copying blob 0b6f3d5842bd skipped: already exists
Copying blob ae10706ab17e skipped: already exists
Copying blob 5f70bf18a086 skipped: already exists
Copying blob 6798887ff012 skipped: already exists
Copying blob 54db80b377f0 done
Copying config bb3a404ee7 done
Writing manifest to image destination
Storing signatures
I1220 10:38:47.541353 120 postexecutorstep.go:393] Executing step: report success
I1220 10:38:47.541394 120 postexecutorstep.go:398] Successfully built localhost/b2bpartners
I1220 10:38:47.541404 120 postexecutorstep.go:93] Skipping step: remove previous image
I1220 10:38:47.541436 120 docker.go:980] Removing container "c05679c19f8c0b8fa119c1a28122dc7524cdfe37671a2983e94e691576ddccae" ...
I1220 10:38:47.623668 120 docker.go:990] Removed container "c05679c19f8c0b8fa119c1a28122dc7524cdfe37671a2983e94e691576ddccae"
I1220 10:38:47.624402 120 cleanup.go:33] Removing temporary directory /tmp/s2i175934027
I1220 10:38:47.624533 120 fs.go:313] Removing directory '/tmp/s2i175934027'
I1220 10:38:47.640109 120 build.go:176] Build completed successfully

podman version

Version: 3.4.4
API Version: 3.4.4
Go Version: go1.17.4
Git Commit: 6145bb5d5696db0144ea529004b7fcdc928c23d3
Built: Sun Dec 19 23:40:38 2021
OS/Arch: linux/amd64

Install s2i v1.3.1 command

wget -qO- https://github.com/openshift/source-to-image/releases/download/v1.3.1/source-to-image-v1.3.1-a5a77147-linux-amd64.tar.gz | tar xvz -C /usr/local/bin

podman run --rm -it b2bpartners /app/s2i/run
work as expected.

service runned by root
podman system service -t=0 &

I can try any different s2i image

@openshift-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 20, 2022
@lunicon
Copy link
Author

lunicon commented Mar 21, 2022

/lifecycle frozen

@openshift-ci openshift-ci bot added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Mar 21, 2022
@matejvasek
Copy link
Contributor

I tend to believe this is rather podman's bug.

@matejvasek
Copy link
Contributor

This podman's bug could be workaround by changes to pkg/docker/docker.go such that the ENTRYPOINT CMD and maybe some other settings are propagated via Changes options.

Example:

diff --git a/vendor/github.com/openshift/source-to-image/pkg/docker/docker.go b/vendor/github.com/openshift/source-to-image/pkg/docker/docker.go
index 48fcbbef..a4284fab 100644
--- a/vendor/github.com/openshift/source-to-image/pkg/docker/docker.go
+++ b/vendor/github.com/openshift/source-to-image/pkg/docker/docker.go
@@ -1104,6 +1104,13 @@ func (d *stiDocker) CommitContainer(opts CommitContainerOptions) (string, error)
                log.V(2).Infof("Committing container with dockerOpts: %+v, config: %+v", dockerOpts, *util.SafeForLoggingContainerConfig(&config))
        }
 
+       if s, err := stringArray2JSONString(opts.Command); err == nil {
+               dockerOpts.Changes = append(dockerOpts.Changes, "CMD " + s)
+       }
+       if s, err := stringArray2JSONString(opts.Entrypoint); err == nil {
+               dockerOpts.Changes = append(dockerOpts.Changes, "ENTRYPOINT " + s)
+       }
+
        resp, err := d.client.ContainerCommit(context.Background(), opts.ContainerID, dockerOpts)
        if err == nil {
                return resp.ID, nil
@@ -1111,6 +1118,14 @@ func (d *stiDocker) CommitContainer(opts CommitContainerOptions) (string, error)
        return "", err
 }
 
+func stringArray2JSONString(A []string) (string, error) {
+       bs, err := json.Marshal(A)
+       if err != nil {
+               return "", err
+       }
+       return string(bs), nil
+}
+
 // RemoveImage removes the image with specified ID
 func (d *stiDocker) RemoveImage(imageID string) error {
        ctx, cancel := getDefaultContext()

@matejvasek
Copy link
Contributor

This might be fixed by containers/podman#20657

@nalind
Copy link
Member

nalind commented Dec 4, 2023

That is the intent, yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.
Projects
None yet
Development

No branches or pull requests

4 participants