Skip to content

toolbox fails to get updated image if HTTP/HTTPS Proxy is set #83

@kenneth-dsouza

Description

@kenneth-dsouza

Bug

toolbox fails to get updated image if HTTP/HTTPS Proxy is set

Host Operating System Version

[root@worker-0 /]# uname -r
4.18.0-372.39.1.el8_6.x86_64
[root@worker-0 /]# rpm-ostree status
State: idle
Deployments:
* e647edffa40edfe4c3a43f88536cc969ba8810a5e32b498de0739797213da0e4
                  Version: 412.86.202212170457-0 (2022-12-17T05:00:56Z)
                Initramfs: --omit-drivers cdrom 

Environment

What hardware/cloud provider/hypervisor is being used to run toolbox?

Expected Behavior

To pull the new version of image:

There is a newer version of registry.redhat.io/rhel8/support-tools available. Would you like to pull it? [y/N]

Actual Behavior

Fails, Error parsing image name "docker://registry.redhat.io/rhel8/support-tools": pinging container registry registry.redhat.io: Get "https://registry.redhat.io/v2/": dial tcp: lookup registry.redhat.io on x.x.x.x : no such host

Reproduction Steps

Steps to Reproduce:

  1. set HTTP & HTTPS Proxy for an environment, no direct, external access
  2. set HTTP_PROXY and HTTPS_PROXY accordingly
  3. run toolbox ( which would fetch updated image)

Other Information

The issue is due to proxy variables not used for skopeo but the same is used for podman.
Without patch:

# /bin/bash -x /usr/bin/toolbox
+ set -eo pipefail
+ trap cleanup EXIT
+ REGISTRY=registry.redhat.io
+ IMAGE=rhel8/support-tools
+ AUTHFILE=/var/lib/kubelet/config.json
++ whoami
+ TOOLBOX_NAME=toolbox-root
+ TOOLBOXRC=/root/.toolboxrc
+ main
+ setup
+ '[' -f /root/.toolboxrc ']'
+ TOOLBOX_IMAGE=registry.redhat.io/rhel8/support-tools
+ [[ '' =~ ^(--help|-h)$ ]]
+ run
+ image_exists
+ sudo podman image inspect registry.redhat.io/rhel8/support-tools
+ image_fresh
+ errecho 'Checking if there is a newer version of registry.redhat.io/rhel8/support-tools available...'
+ echo 'Checking if there is a newer version of registry.redhat.io/rhel8/support-tools available...'
Checking if there is a newer version of registry.redhat.io/rhel8/support-tools available...
++ sudo podman image inspect registry.redhat.io/rhel8/support-tools --format '{{.Created}}'
+ local_date='2021-03-31 13:45:06.249427 +0000 UTC'
++ sudo skopeo inspect --authfile /var/lib/kubelet/config.json docker://registry.redhat.io/rhel8/support-tools --format '{{.Created}}'
FATA[0000] Error parsing image name "docker://registry.redhat.io/rhel8/support-tools": pinging container registry registry.redhat.io: Get "https://registry.redhat.io/v2/": dial tcp: lookup registry.redhat.io on x.x.x.x:53: no such host
+ remote_date=
+ errecho 'Error inspecting registry.redhat.io/rhel8/support-tools via skopeo'
+ echo 'Error inspecting registry.redhat.io/rhel8/support-tools via skopeo'
Error inspecting registry.redhat.io/rhel8/support-tools via skopeo
+ return
++ image_runlabel
++ sudo podman image inspect registry.redhat.io/rhel8/support-tools --format '{{- if index .Labels "run" -}}{{.Labels.run}}{{- end -}}'
+ local 'runlabel=podman run -it --name NAME --privileged --ipc=host --net=host --pid=host -e HOST=/host -e NAME=NAME -e IMAGE=IMAGE -v /run:/run -v /var/log:/var/log -v /etc/machine-id:/etc/machine-id -v /etc/localtime:/etc/localtime -v /:/host IMAGE'
+ container_exists
+ sudo podman container inspect toolbox-root
+ errecho 'Container '\''toolbox-root'\'' already exists. Trying to start...'
+ echo 'Container '\''toolbox-root'\'' already exists. Trying to start...'
Container 'toolbox-root' already exists. Trying to start...
+ errecho '(To remove the container and start with a fresh toolbox, run: sudo podman rm '\''toolbox-root'\'')'
+ echo '(To remove the container and start with a fresh toolbox, run: sudo podman rm '\''toolbox-root'\'')'
(To remove the container and start with a fresh toolbox, run: sudo podman rm 'toolbox-root')
++ container_state
++ sudo podman container inspect toolbox-root --format '{{.State.Status}}'
+ local state=exited
+ [[ exited == configured ]]
+ [[ exited == created ]]
+ [[ exited == exited ]]
+ container_start
+ sudo podman start toolbox-root
toolbox-root
+ [[ 0 -eq 0 ]]
+ errecho 'Container started successfully. To exit, type '\''exit'\''.'
+ echo 'Container started successfully. To exit, type '\''exit'\''.'
Container started successfully. To exit, type 'exit'.
+ container_exec
+ [[ 0 -eq 0 ]]
+ sudo podman attach toolbox-root

With patch --preserve-env for skopeo:

# /bin/bash -x /tmp/toolbox
+ set -eo pipefail
+ trap cleanup EXIT
+ REGISTRY=registry.redhat.io
+ IMAGE=rhel8/support-tools
+ AUTHFILE=/var/lib/kubelet/config.json
++ whoami
+ TOOLBOX_NAME=toolbox-root
+ TOOLBOXRC=/root/.toolboxrc
+ main
+ setup
+ '[' -f /root/.toolboxrc ']'
+ TOOLBOX_IMAGE=registry.redhat.io/rhel8/support-tools
+ [[ '' =~ ^(--help|-h)$ ]]
+ run
+ image_exists
+ sudo podman image inspect registry.redhat.io/rhel8/support-tools
+ image_fresh
+ errecho 'Checking if there is a newer version of registry.redhat.io/rhel8/support-tools available...'
+ echo 'Checking if there is a newer version of registry.redhat.io/rhel8/support-tools available...'
Checking if there is a newer version of registry.redhat.io/rhel8/support-tools available...
++ sudo podman image inspect registry.redhat.io/rhel8/support-tools --format '{{.Created}}'
+ local_date='2021-03-31 13:45:06.249427 +0000 UTC'
++ sudo --preserve-env skopeo inspect --authfile /var/lib/kubelet/config.json docker://registry.redhat.io/rhel8/support-tools --format '{{.Created}}'
+ remote_date='2023-01-06 17:07:04.286354791 +0000 UTC'
+ [[ 2023-01-06 17:07:04.286354791 +0000 UTC > 2021-03-31 13:45:06.249427 +0000 UTC ]]
+ read -r -p 'There is a newer version of registry.redhat.io/rhel8/support-tools available. Would you like to pull it? [y/N] '
There is a newer version of registry.redhat.io/rhel8/support-tools available. Would you like to pull it? [y/N] y
+ [[ y =~ ^([Yy][Ee][Ss]|[Yy])+$ ]]
+ image_pull
+ sudo --preserve-env podman pull --authfile /var/lib/kubelet/config.json registry.redhat.io/rhel8/support-tools
Trying to pull registry.redhat.io/rhel8/support-tools:latest...
Getting image source signatures
Checking if image destination supports signatures
Copying blob 0161491eccce done
Copying blob 649e5534d134 done
Copying config b2d8baad64 done
Writing manifest to image destination
Storing signatures
b2d8baad64dd2c1ce60642f48ea6812a3b23a30d8c130049dc799c8f1dd81e83
+ container_exists
+ sudo podman container inspect toolbox-root
+ sudo podman rm toolbox-root
1c085c2cb080d646090a5dd61464be92bbd35460546a660018003f8657f1760b
++ image_runlabel
++ sudo podman image inspect registry.redhat.io/rhel8/support-tools --format '{{- if index .Labels "run" -}}{{.Labels.run}}{{- end -}}'
+ local 'runlabel=podman run -it --name NAME --privileged --ipc=host --net=host --pid=host -e HOST=/host -e NAME=NAME -e IMAGE=IMAGE -v /run:/run -v /var/log:/var/log -v /etc/machine-id:/etc/machine-id -v /etc/localtime:/etc/localtime -v /:/host IMAGE'
+ container_exists
+ sudo podman container inspect toolbox-root
+ errecho 'Spawning a container '\''toolbox-root'\'' with image '\''registry.redhat.io/rhel8/support-tools'\'''
+ echo 'Spawning a container '\''toolbox-root'\'' with image '\''registry.redhat.io/rhel8/support-tools'\'''
Spawning a container 'toolbox-root' with image 'registry.redhat.io/rhel8/support-tools'
+ [[ -z podman run -it --name NAME --privileged --ipc=host --net=host --pid=host -e HOST=/host -e NAME=NAME -e IMAGE=IMAGE -v /run:/run -v /var/log:/var/log -v /etc/machine-id:/etc/machine-id -v /etc/localtime:/etc/localtime -v /:/host IMAGE ]]
+ [[ podman run -it --name NAME --privileged --ipc=host --net=host --pid=host -e HOST=/host -e NAME=NAME -e IMAGE=IMAGE -v /run:/run -v /var/log:/var/log -v /etc/machine-id:/etc/machine-id -v /etc/localtime:/etc/localtime -v /:/host IMAGE == \<\n\o\ \v\a\l\u\e\> ]]
+ errecho 'Detected RUN label in the container image. Using that as the default...'
+ echo 'Detected RUN label in the container image. Using that as the default...'
Detected RUN label in the container image. Using that as the default...
+ container_create_runlabel
+ local pod
++ echo 'podman run -it --name NAME --privileged --ipc=host --net=host --pid=host -e HOST=/host -e NAME=NAME -e IMAGE=IMAGE -v /run:/run -v /var/log:/var/log -v /etc/machine-id:/etc/machine-id -v /etc/localtime:/etc/localtime -v /:/host IMAGE'
++ sed 's/--name NAME/--name ${TOOLBOX_NAME}/'
++ sed 's/NAME=NAME/NAME=${TOOLBOX_NAME}/'
++ sed 's/podman run/sudo podman create/'
++ sed 's/host IMAGE/host ${TOOLBOX_IMAGE}/'
++ sed 's/IMAGE=IMAGE/IMAGE=${TOOLBOX_IMAGE}/'
+ pod='sudo podman create -it --name ${TOOLBOX_NAME} --privileged --ipc=host --net=host --pid=host -e HOST=/host -e NAME=${TOOLBOX_NAME} -e IMAGE=${TOOLBOX_IMAGE} -v /run:/run -v /var/log:/var/log -v /etc/machine-id:/etc/machine-id -v /etc/localtime:/etc/localtime -v /:/host ${TOOLBOX_IMAGE}'
+ eval 'sudo podman create -it --name ${TOOLBOX_NAME} --privileged --ipc=host --net=host --pid=host -e HOST=/host -e NAME=${TOOLBOX_NAME} -e IMAGE=${TOOLBOX_IMAGE} -v /run:/run -v /var/log:/var/log -v /etc/machine-id:/etc/machine-id -v /etc/localtime:/etc/localtime -v /:/host ${TOOLBOX_IMAGE}'
++ sudo podman create -it --name toolbox-root --privileged --ipc=host --net=host --pid=host -e HOST=/host -e NAME=toolbox-root -e IMAGE=registry.redhat.io/rhel8/support-tools -v /run:/run -v /var/log:/var/log -v /etc/machine-id:/etc/machine-id -v /etc/localtime:/etc/localtime -v /:/host registry.redhat.io/rhel8/support-tools
27c88f2a6b0c4d6828f0dec7cbcefa3fbc5777e6d02b7f7c40304eb853dd21b9
++ container_state
++ sudo podman container inspect toolbox-root --format '{{.State.Status}}'
+ local state=created
+ [[ created == configured ]]
+ [[ created == created ]]
+ container_start
+ sudo podman start toolbox-root
toolbox-root
+ [[ 0 -eq 0 ]]
+ errecho 'Container started successfully. To exit, type '\''exit'\''.'
+ echo 'Container started successfully. To exit, type '\''exit'\''.'
Container started successfully. To exit, type 'exit'.
+ container_exec
+ [[ 0 -eq 0 ]]
+ sudo podman attach toolbox-root

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions