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

can't connect to HTTP endpoint: invalid payload: json: unknown field "insecure" #310

Closed
chris-aeviator opened this issue Dec 28, 2021 · 9 comments

Comments

@chris-aeviator
Copy link

When trying to connect to a http only registry, according to the readme I'm supposed to add insecure: true to the source configuration.

However, when pushing an image, the build fails with

ERRO[0000] invalid payload: json: unknown field "insecure" 

image

❯ cat build-agent.yml
resources:
- name: prefect-agent
  type: git
  icon: github
  source:

    uri: http://git.sentinel.loc/chris/alpine-ci-dockerbuild-tester
    branch: master
    username: ##############
    password :################
    skip_ssl_verification: true

# Where we will push the image
- name: docker-registry
  type: registry-image
  icon: docker
  source:
    repository: ((image-repo-name))/alpine-ci-test
    tag: latest
    insecure: true

jobs:
- name: build-and-push
  plan:
  - get: prefect-agent
    trigger: true
  - task: build-task-image
    privileged: true
    config:
      platform: linux
      image_resource:
        type: registry-image
        source:
          repository: concourse/oci-build-task
      inputs:
      - name: prefect-agent
      outputs:
      - name: image
      params:
        CONTEXT: prefect-agent/Dockerfiles
      run:
        path: build
  - put: docker-registry
    params:
      image: image/image.tar
fly -t sent-loc set-pipeline -p build-and-push-agent-image \
  -c ./build-agent.yml \
  --var image-repo-name=http://docker.sent.loc

Version 7.6.0

@chris-aeviator chris-aeviator changed the title invalid payload: json: unknown field "insecure" can't connect to HTTP endpoint: invalid payload: json: unknown field "insecure" Dec 28, 2021
@chris-aeviator
Copy link
Author

I think I found the issue to this and possibly any other invalid payload errors like #296 . For me the issue happens with a private registry, and since docker tag works with including the protocol (http/s) I used to include it. The docs also do not highlight anything about it.

Whenever I have https://my-reg.tld I'll get the described error , but when removing https, and setting repository: my-reg.tld/my-image everything works out.

I suggest to check for the protocol being included or any other type of connection check to the actual docker registry

@cherwin
Copy link

cherwin commented Jan 1, 2022

A new release has not been cut yet. I've built an image which includes the fix over here cherwin/registry-image-resource

@chris-aeviator
Copy link
Author

@chervin thanks for clarifying - the param should be removed from the readme IMO to spare others the hrs of unneeded debug time

@jloeser
Copy link

jloeser commented Jan 13, 2022

I run into the same issue with concourse v7.6.0 (registry-image v1.4.1) BUT using repository: http://my-reg.tld:5000 doesn't work either:

$ fly -t devel set-pipeline -p build-and-push-image \                     
    -c ./build-and-push.yml \
   --var repo-server=http://my-reg.tld:5000
...
selected worker: concourse
ERRO[0000] could not resolve repository: repository can only contain the runes `abcdefghijklmnopqrstuvwxyz0123456789_-./`: /my-reg.tld:5000/simple-image 
failed

Using the image (b2e5295880e5) provided by @cherwin results in:

$ fly -t devel trigger-job -j build-and-push-image/build-and-push --watch
started build-and-push-image/build-and-push #21                          

selected worker: concourse
INFO: found existing resource cache

initializing
initializing check: image
selected worker: concourse
run check: find or create container on worker concourse: failed to create volume
run check: find or create container on worker concourse: failed to create volume
errored

(installed by fetch -> run -> export to root.tgz && cp to /usr/local/concourse/resource-types/registry-image/; worker restarted)

Any ideas? Did I oversee something?

@cherwin
Copy link

cherwin commented Jan 13, 2022

@jloeser leave off http:// and see if that works. For future reference, it would be helpful if you post a minimal pipeline to reproduce the issue.

@jloeser
Copy link

jloeser commented Jan 13, 2022

You are right, here we go:

$ cat ./build-and-push.yml
resources:                                                                         
# The repo with our Dockerfile                                                     
- name: concourse-examples                                                         
  type: git                                                                        
  icon: github                                                                     
  source:                                                                          
    uri: https://github.com/concourse/examples.git                                 
    branch: master                                                                 
                                                                                   
## Where we will push the image to                                                 
- name: simple-image                                                               
  type: registry-image                                                             
  icon: docker                                                                     
  source:                                                                          
    repository: my-reg.tld:5000/simple-image                      
    tag: latest                                                                    
                                                                                   
jobs:                                                                              
- name: build-and-push                                                             
  plan:                                                                            
  - get: concourse-examples                                                        
  - task: build-task-image                                                         
    privileged: true                                                               
    config:                                                                        
      platform: linux                                                              
      image_resource:                                                              
        type: registry-image                                                       
        source:                                                                    
          repository: vito/oci-build-task                                          
      inputs:                                                                      
      - name: concourse-examples                                                   
      outputs:                                                                     
      - name: image                                                                
      run:                                                                         
        path: build                                                                
      params:                                                                      
        CONTEXT: concourse-examples/Dockerfiles/simple                             
  - put: simple-image                                                              
    params:                                                                        
      image: image/image.tar

...results in:

$ fly -t devel trigger-job -j build-and-push-image/build-and-push --watch
...
selected worker: concourse
ERRO[0000] pushing image failed: initialize transport: Get "https://my-reg.tld:5000/v2/": http: server gave HTTP response to HTTPS client 
failed

So without protocol prefix it's trying HTTPS.

For now I've set up reverse proxy providing HTTPS connection which works as expected.

@cherwin
Copy link

cherwin commented Jan 13, 2022

@jloeser you are missing insecure: true and you haven't defined the custom resource type. Check out #304 (comment) for example

@jloeser
Copy link

jloeser commented Jan 14, 2022

Let me clarify: according to docs there is an insecure option for registry-image resource type. Like @chris-aeviator and you wrote this is currently not supported by latest v1.4.1 release.

Unfortunately, I interpreted #310 (comment) that it is possible to use HTTP connection at all with latest v1.4.1 (and without insecure option available) - but this guess was wrong.

However, your example in #304 (comment) looks much more handy (and also works) than my amateurish way of replacing actual registry-image resource type directly on the server/worker.

All clear now and looking forward for next release. Thanks for support!

@xtremerui
Copy link
Contributor

This should be fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants