Skip to content
This repository has been archived by the owner on Jun 1, 2021. It is now read-only.

ImagePush function | capture name of the built image name, tag and push the resultant image according #70

Open
AniketKul opened this issue Nov 8, 2019 · 8 comments
Assignees
Labels
bug Something isn't working PRIORITY: 1 Picked up and resolved in the current sprint
Projects
Milestone

Comments

@AniketKul
Copy link
Member

AniketKul commented Nov 8, 2019

Describe the bug

At present, users need to provide the image name as a combination of registry, user and image-name in ocibuilder.yaml. Ideally users should provide just the image-name and ImagePush() function from pkg/docker.go should take care of tagging the image appropriately and pushing it to the registry/registries mentioned in push specs of ocibuilder.yaml file

Current Spec

build:
  templates:
    - name: template-1
      cmd:
        - docker:
            inline:
              - RUN mkdir /dirname
              - WORKDIR /dirname
              - COPY * /dirname/
              - EXPOSE 8888
  steps:
    - metadata:
        name: <registry>/<namespace>/<image-name>
        labels:
          type: build-1
          overlay: overlay-1
      stages:
        - metadata:
            name: build-env
            labels:
              stage: stage-1
              type: build-from-base
          base:
            image: python
            platform: alpine
          template: template-1
      tag: v0.0.1
      distroless: false
      cache: false
      purge: false

Expected Spec

build:
  templates:
    - name: template-1
      cmd:
        - docker:
            inline:
              - RUN mkdir /dirname
              - WORKDIR /dirname
              - COPY * /dirname/
              - EXPOSE 8888
  steps:
    - metadata:
        name: <image-name>
        labels:
          type: build-1
          overlay: overlay-1
      stages:
        - metadata:
            name: build-env
            labels:
              stage: stage-1
              type: build-from-base
          base:
            image: python
            platform: alpine
          template: template-1
      tag: v0.0.1
      distroless: false
      cache: false
      purge: false
@AniketKul
Copy link
Member Author

Getting following error with all the commands apart from ImagePull and ImagePush at present. investigating it further

go test -v ./pkg/docker/ -run TestDocker_Push
=== RUN   TestDocker_Push
--- FAIL: TestDocker_Push (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xe0 pc=0x1a2c6e9]

goroutine 20 [running]:
testing.tRunner.func1(0xc00011e100)
	/usr/local/Cellar/go/1.13.1/libexec/src/testing/testing.go:874 +0x3a3
panic(0x1b39780, 0x2636b00)
	/usr/local/Cellar/go/1.13.1/libexec/src/runtime/panic.go:679 +0x1b2
github.com/ocibuilder/ocibuilder/pkg/docker.(*testClient).ContainerList(0x26465f0, 0x1e0b0e0, 0xc00003a0a8, 0x10100, 0x1c6d4a8, 0x9, 0x0, 0x0, 0x0, 0x0, ...)
	<autogenerated>:1 +0x39
github.com/ocibuilder/ocibuilder/pkg/docker.Docker.Push(0xc00014f0a0, 0x1e2f460, 0x26465f0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x263e420, ...)
	/Users/<username>/go_installation/src/github.com/ocibuilder/ocibuilder/pkg/docker/docker.go:202 +0x35f
github.com/ocibuilder/ocibuilder/pkg/docker.TestDocker_Push(0xc00011e100)
	/Users/<username>/go_installation/src/github.com/ocibuilder/ocibuilder/pkg/docker/docker_test.go:52 +0x76
testing.tRunner(0xc00011e100, 0x1cd3380)
	/usr/local/Cellar/go/1.13.1/libexec/src/testing/testing.go:909 +0xc9
created by testing.(*T).Run
	/usr/local/Cellar/go/1.13.1/libexec/src/testing/testing.go:960 +0x350
FAIL	github.com/ocibuilder/ocibuilder/pkg/docker	0.191s
FAIL

@AniketKul
Copy link
Member Author

AniketKul commented Nov 11, 2019

Steps to fix this:

1] use cli.ImageTag in ImagePush function first and then
2] use cli.ImagePush

but the issue is I am getting above error with a simple cli.ImageTag call in ocibuilder repo. It works fine on my machine in another sample repository

@artbegolli
Copy link
Collaborator

What error is being thrown with ImageTag?

@AniketKul
Copy link
Member Author

AniketKul commented Nov 11, 2019

@artbegolli - similar to what I had posted earlier. ImageRemove that we have in our code also throws similar error.

=== RUN   TestDocker_Push
--- FAIL: TestDocker_Push (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x208 pc=0x1a4dee6]

goroutine 20 [running]:
testing.tRunner.func1(0xc00013e100)
	/usr/local/go/src/testing/testing.go:830 +0x392
panic(0x1b57940, 0x274c640)
	/usr/local/go/src/runtime/panic.go:522 +0x1b5
github.com/ocibuilder/ocibuilder/pkg/docker.(*testClient).ImageTag(0x275bb60, 0x1e2cc80, 0xc00003a090, 0x1c7d983, 0xa, 0xc00038e000, 0x2e, 0x0, 0x1c7a359)
	<autogenerated>:1 +0x36
github.com/ocibuilder/ocibuilder/pkg/docker.Docker.Push(0xc0000d15c0, 0x1e56640, 0x275bb60, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2753ba0, ...)
	/Users/<username>/go_installation/src/github.com/ocibuilder/ocibuilder/pkg/docker/docker.go:196 +0x3b4
github.com/ocibuilder/ocibuilder/pkg/docker.TestDocker_Push(0xc00013e100)
	/Users/<username>/go_installation/src/github.com/ocibuilder/ocibuilder/pkg/docker/docker_test.go:52 +0x76
testing.tRunner(0xc00013e100, 0x1cdfc68)
	/usr/local/go/src/testing/testing.go:865 +0xc0
created by testing.(*T).Run
	/usr/local/go/src/testing/testing.go:916 +0x35a
FAIL	github.com/ocibuilder/ocibuilder/pkg/docker	0.239s

@artbegolli
Copy link
Collaborator

Add ImageTag to the mock test function in docker_test.go

@AniketKul
Copy link
Member Author

cool

@VaibhavPage VaibhavPage modified the milestones: release v0.1.0, v0.1.1 Nov 14, 2019
@AniketKul
Copy link
Member Author

AniketKul commented Nov 18, 2019

this is almost done. just need to regenerate clientset to fix some unwanted code in clientset. working on it

@artbegolli artbegolli changed the title bugfix(): ImagePush function | capture name of the built image name, tag and push the resultant image according ImagePush function | capture name of the built image name, tag and push the resultant image according Nov 18, 2019
@artbegolli artbegolli added this to To do in ocibuilder via automation Nov 18, 2019
@artbegolli artbegolli added the PRIORITY: 1 Picked up and resolved in the current sprint label Nov 18, 2019
@AniketKul
Copy link
Member Author

PR #71 fixes this issue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working PRIORITY: 1 Picked up and resolved in the current sprint
Projects
ocibuilder
  
To do
3 participants