sealos icon indicating copy to clipboard operation
sealos copied to clipboard

BUG: sealos build with parse image name error

Open weironz opened this issue 3 years ago • 3 comments

Which command or component

sealos build

The Description of the bug

root@ubuntu:/data/git/cluster-image/applications/istio/v1.14.2# sealos build -f Kubefile -t registry.cn-shenzhen.aliyuncs.com/cnmirror/istio:v1.14.2 .
2022-08-06 12:47:25 [INFO] srcPath: charts
2022-08-06 12:47:25 [INFO] subChartPath is: base
2022-08-06 12:47:25 [INFO] subChartPath is: gateway
2022-08-06 12:47:25 [INFO] subChartPath is: istiod
2022-08-06 12:47:25 [INFO] fetch chart images: [auto docker.io/istio/pilot:1.14.2 {{annotation.ObjectMeta`sidecar.istio.io/proxyImage`.Values.global.proxy_init.image}} {{.ProxyImage}} {{annotation.ObjectMeta`sidecar.istio.io/proxyImage`.Values.global.proxy_init.image}} {{.ProxyImage}} {{annotation.ObjectMeta`sidecar.istio.io/proxyImage`.Values.global.proxy.image}} {{.ProxyImage}} {{annotation.ObjectMeta`sidecar.istio.io/proxyImage`.Values.global.proxy.image}} {{.ProxyImage}} busybox:1.28 {{annotation.ObjectMeta`sidecar.istio.io/proxyImage`.Values.global.proxy.image}} {{.ProxyImage}}]
2022-08-06 12:47:25 [INFO] srcPath is empty manifests
2022-08-06 12:47:25 [INFO] fetch manifests images: []
2022-08-06 12:47:25 [WARN] if you access private registry,you must be 'sealos login' or 'buildah login'
2022-08-06 12:47:25 [INFO] pull images [docker.io/istio/install-cni:1.14.2 docker.io/istio/proxyv2:1.14.2 docker.io/istio/pilot:1.14.2 auto docker.io/istio/pilot:1.14.2 {{annotation.ObjectMeta`sidecar.istio.io/proxyImage`.Values.global.proxy_init.image}} {{.ProxyImage}} {{annotation.ObjectMeta`sidecar.istio.io/proxyImage`.Values.global.proxy_init.image}} {{.ProxyImage}} {{annotation.ObjectMeta`sidecar.istio.io/proxyImage`.Values.global.proxy.image}} {{.ProxyImage}} {{annotation.ObjectMeta`sidecar.istio.io/proxyImage`.Values.global.proxy.image}} {{.ProxyImage}} busybox:1.28 {{annotation.ObjectMeta`sidecar.istio.io/proxyImage`.Values.global.proxy.image}} {{.ProxyImage}}] for platform is linux/amd64
Pulling image: docker.io/istio/install-cni:1.14.2
Pulling image: docker.io/istio/proxyv2:1.14.2
Pulling image: docker.io/istio/pilot:1.14.2
Pulling image: docker.io/library/auto:latest
Error: save images failed in this context: parse image name error: invalid reference format: repository name (proxyImage`.Values.global.proxy_init.image}}) must be lowercase
Pulling image: docker.io/istio/pilot:1.14.2
Usage:
  sealos build [flags] PATH

Examples:
sealos build -t labring/kubernetes:v1.24.0 .

Flags:
      --basic-auth           pull image auth policy,default is token auth
  -h, --help                 help for build
  -f, --kubefile string      kubefile filepath (default "Kubefile")
  -m, --max-pull-procs int   maximum number of goroutines for pulling (default 5)
      --platform string      set the OS/ARCH/VARIANT of the image to the provided value instead of the current operating system and architecture of the host (for example linux/arm) (default "linux/amd64")
  -t, --tag string           tagged name to apply to the built image

Global Flags:
      --cluster-root string   cluster root directory (default "/var/lib/sealos")
      --debug                 enable debug logger

save images failed in this context: parse image name error: invalid reference format: repository name (proxyImage`.Values.global.proxy_init.image}}) must be lowercase
root@ubuntu:/data/git/cluster-image/applications/istio/v1.14.2# 

How to reproduce(pictures can be attached if necessary)

helm repo add istio https://istio-release.storage.googleapis.com/charts
helm pull istio/base --untar -d charts/
helm pull istio/istiod --untar -d charts/
sealos build -f Kubefile -t registry.cn-shenzhen.aliyuncs.com/cnmirror/istio:v1.14.2 .

Test Result 1. 2. 3.

What you expected to happen

Expected build success

Operating environment

  • Docker version:
  • Kubernetes version:
  • Sealos version: v4.0.0
  • Operating system: ubuntu 22.04
  • Runtime environment: eg. physical machine (100G memory, 10 core cpu, 10T storage), virtual machine (virbox, 10G memory, 2 core cpu, 100G storage), cloud(aws, 10G memory, 2 core cpu, 100G storage)
  • Cluster size: eg 3 master, 3 node
  • Additional information: istio, dashboard ...

weironz avatar Aug 06 '22 04:08 weironz

can you use helm template command to render istio helm chart?

fanux avatar Aug 06 '22 14:08 fanux

too many content, it's here

helm template charts/istiod > istiod-template.yaml

https://gist.githubusercontent.com/willzhang/432eab4aec857756ad8e8ff695c045ba/raw/2880d97e0eb0b0a12ad727da4c121c841bb9526d/istiod-template.yaml

weironz avatar Aug 06 '22 14:08 weironz

(proxyImage`.Values.global.proxy_init.image}}) Seems render this values failed.

fanux avatar Aug 10 '22 02:08 fanux

This bug already fixed?

fanux avatar Feb 12 '23 13:02 fanux

GOOD FIRST ISSUE:

https://github.com/labring/sealos/blob/a02ebcafefbeb31b284ee8786987d7f7c6455721/pkg/buildimage/manifests/utils.go#L30-L75 Fix the parimages method to return the correct image name: something like image in the content of the chart template file. ignoring wrong images, and add test case for it. Wrong image like:

image: "{{ annotation .ObjectMeta `sidecar.istio.io/proxyImage` .Values.global.proxy_init.image }}"

bxy4543 avatar Mar 23 '23 08:03 bxy4543

@bxy4543 I reproduce this issue , and the current version results are as follows:

2023-03-29T18:48:51 info lookup in path /home/ricky/yaml/charts
2023-03-29T18:48:51 info sub chart is base
2023-03-29T18:48:51 info sub chart is istiod
2023-03-29T18:48:51 error failed to parse image name image: "{{ annotation .ObjectMeta `sidecar.istio.io/proxyImage` .Values.global.proxy_init.image }}": invalid reference format: repository name must be lowercase
2023-03-29T18:48:51 error failed to parse image name image: "{{ .ProxyImage }}": invalid reference format: repository name must be lowercase
2023-03-29T18:48:51 error failed to parse image name image: "{{ annotation .ObjectMeta `sidecar.istio.io/proxyImage` .Values.global.proxy_init.image }}": invalid reference format: repository name must be lowercase
2023-03-29T18:48:51 error failed to parse image name image: "{{ .ProxyImage }}": invalid reference format: repository name must be lowercase
2023-03-29T18:48:51 error failed to parse image name image: "{{ annotation .ObjectMeta `sidecar.istio.io/proxyImage` .Values.global.proxy.image }}": invalid reference format: repository name must be lowercase
2023-03-29T18:48:51 error failed to parse image name image: "{{ .ProxyImage }}": invalid reference format: repository name must be lowercase
2023-03-29T18:48:51 error failed to parse image name image: "{{ annotation .ObjectMeta `sidecar.istio.io/proxyImage` .Values.global.proxy.image }}": invalid reference format: repository name must be lowercase
2023-03-29T18:48:51 error failed to parse image name image: "{{ .ProxyImage }}": invalid reference format: repository name must be lowercase
2023-03-29T18:48:51 error failed to parse image name image: "{{ annotation .ObjectMeta `sidecar.istio.io/proxyImage` .Values.global.proxy.image }}": invalid reference format: repository name must be lowercase
2023-03-29T18:48:51 error failed to parse image name image: "{{ .ProxyImage }}": invalid reference format: repository name must be lowercase
Pulling image: index.docker.io/istio/pilot:1.17.1
Pulling image: index.docker.io/library/busybox:1.28
699d9171558c: already exists 
753cd998611f: already exists 
69b62d9454ad: already exists 
ce135d1b1aa5: already exists 
f5cc8452ea58: Download complete 
ea38cc39ffb7: Download complete 
cd2dd85d9fe3: Download complete 
07a152489297: Download complete 
8c811b4aec35: Download complete 
Status: images save success
2023-03-29T18:49:05 info saving images index.docker.io/istio/pilot:1.17.1, index.docker.io/library/busybox:1.28
STEP 1/3: FROM scratch
STEP 2/3: COPY . .
STEP 3/3: CMD ["helm install istio ."]
COMMIT registry.cn-shenzhen.aliyuncs.com/cnmirror/istio:v1.14.2
Getting image source signatures
Copying blob a332e134a895 done  
Copying config 886e2bf4d7 done  
Writing manifest to image destination
Storing signatures
--> 886e2bf4d7a
Successfully tagged registry.cn-shenzhen.aliyuncs.com/cnmirror/istio:v1.14.2
886e2bf4d7a4aa289304994f12ad9207a887b77b940c36153db1e096f40af651

Perhaps this issue has been fixed?

y-ykcir avatar Mar 30 '23 12:03 y-ykcir

helm engine.Render() doesn't seem to render all. https://github.com/labring/sealos/blob/a929e01b639a409d03c9db06694f9a01e0fcb936/pkg/buildimage/chart.go#L94-L105

bxy4543 avatar Apr 03 '23 07:04 bxy4543

1

mixinkexue avatar Apr 03 '23 10:04 mixinkexue

(proxyImage`.Values.global.proxy_init.image}}) Seems render this values failed.

i think this template was rendered successfully the template: before The file /injection-template.ymal being loaded: mid end: image

Like we can see, the contents of the file are loaded Simply put, '{{' is the content in the file, not the template

mixinkexue avatar Apr 04 '23 05:04 mixinkexue

@bxy4543 I reproduce this issue , and the current version results are as follows:

2023-03-29T18:48:51 info lookup in path /home/ricky/yaml/charts
2023-03-29T18:48:51 info sub chart is base
2023-03-29T18:48:51 info sub chart is istiod
2023-03-29T18:48:51 error failed to parse image name image: "{{ annotation .ObjectMeta `sidecar.istio.io/proxyImage` .Values.global.proxy_init.image }}": invalid reference format: repository name must be lowercase
2023-03-29T18:48:51 error failed to parse image name image: "{{ .ProxyImage }}": invalid reference format: repository name must be lowercase
2023-03-29T18:48:51 error failed to parse image name image: "{{ annotation .ObjectMeta `sidecar.istio.io/proxyImage` .Values.global.proxy_init.image }}": invalid reference format: repository name must be lowercase
2023-03-29T18:48:51 error failed to parse image name image: "{{ .ProxyImage }}": invalid reference format: repository name must be lowercase
2023-03-29T18:48:51 error failed to parse image name image: "{{ annotation .ObjectMeta `sidecar.istio.io/proxyImage` .Values.global.proxy.image }}": invalid reference format: repository name must be lowercase
2023-03-29T18:48:51 error failed to parse image name image: "{{ .ProxyImage }}": invalid reference format: repository name must be lowercase
2023-03-29T18:48:51 error failed to parse image name image: "{{ annotation .ObjectMeta `sidecar.istio.io/proxyImage` .Values.global.proxy.image }}": invalid reference format: repository name must be lowercase
2023-03-29T18:48:51 error failed to parse image name image: "{{ .ProxyImage }}": invalid reference format: repository name must be lowercase
2023-03-29T18:48:51 error failed to parse image name image: "{{ annotation .ObjectMeta `sidecar.istio.io/proxyImage` .Values.global.proxy.image }}": invalid reference format: repository name must be lowercase
2023-03-29T18:48:51 error failed to parse image name image: "{{ .ProxyImage }}": invalid reference format: repository name must be lowercase
Pulling image: index.docker.io/istio/pilot:1.17.1
Pulling image: index.docker.io/library/busybox:1.28
699d9171558c: already exists 
753cd998611f: already exists 
69b62d9454ad: already exists 
ce135d1b1aa5: already exists 
f5cc8452ea58: Download complete 
ea38cc39ffb7: Download complete 
cd2dd85d9fe3: Download complete 
07a152489297: Download complete 
8c811b4aec35: Download complete 
Status: images save success
2023-03-29T18:49:05 info saving images index.docker.io/istio/pilot:1.17.1, index.docker.io/library/busybox:1.28
STEP 1/3: FROM scratch
STEP 2/3: COPY . .
STEP 3/3: CMD ["helm install istio ."]
COMMIT registry.cn-shenzhen.aliyuncs.com/cnmirror/istio:v1.14.2
Getting image source signatures
Copying blob a332e134a895 done  
Copying config 886e2bf4d7 done  
Writing manifest to image destination
Storing signatures
--> 886e2bf4d7a
Successfully tagged registry.cn-shenzhen.aliyuncs.com/cnmirror/istio:v1.14.2
886e2bf4d7a4aa289304994f12ad9207a887b77b940c36153db1e096f40af651

Perhaps this issue has been fixed?

There is a slight issue with the logic , which caused some incorrect logs to be printed, but it won't affect the execution of the functions.

mixinkexue avatar Apr 04 '23 05:04 mixinkexue

After execing helm template , there are still {{ meaning that the code about rendering is fine

mixinkexue avatar Apr 04 '23 05:04 mixinkexue