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

Image name not given still kompose does not errors out #92

Closed
surajssd opened this issue Aug 8, 2016 · 18 comments
Closed

Image name not given still kompose does not errors out #92

surajssd opened this issue Aug 8, 2016 · 18 comments
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.
Milestone

Comments

@surajssd
Copy link
Member

surajssd commented Aug 8, 2016

Using docker-compose file that has no field for image, so this should error out, but this still works.

$ cat /tmp/docker-compose-no-image.yml 
version: "2"

services:
  mariadb:
    ports:
      - 3306

output

$ kompose convert --stdout -y -f /tmp/docker-compose-no-image.yml                                                                                                                       
apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  labels:
    service: mariadb
  name: mariadb
spec:
  ports:
  - name: "3306"
    port: 3306
    protocol: TCP
    targetPort: 3306
  selector:
    service: mariadb
status:
  loadBalancer: {}

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    service: mariadb
  name: mariadb
spec:
  replicas: 1
  selector:
    matchLabels:
      service: mariadb
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        service: mariadb
    spec:
      containers:
      - name: mariadb
        ports:
        - containerPort: 3306
          protocol: TCP
        resources: {}
      restartPolicy: Always
status: {}

---
@surajssd surajssd self-assigned this Aug 8, 2016
@sebgoa
Copy link
Contributor

sebgoa commented Aug 8, 2016

is there a way to validate the docker-compose file with lib compose ?

@ngtuna
Copy link
Contributor

ngtuna commented Aug 8, 2016

@Runseb : docker-compose has this validation. libcompose should have.

$ cat docker-compose.yml
web:
  links:
   - redis
redis:

$ docker-compose up
ERROR: The Compose file is invalid because:
Service web has neither an image nor a build context specified. At least one must be provided.

@ngtuna
Copy link
Contributor

ngtuna commented Aug 8, 2016

Found it.
https://github.com/docker/libcompose/blob/master/config/validation.go#L263

@surajssd you will see kompose currently use function Parse() of libcompose in order to read compose file. It should then call to validateServiceConstraints() above.

@surajssd
Copy link
Member Author

surajssd commented Aug 8, 2016

@ngtuna thanks for that pointer :-)

@ngtuna ngtuna added the kind/bug Categorizes issue or PR as related to a bug. label Aug 8, 2016
@surajssd
Copy link
Member Author

@ngtuna now when I started working on this, looks like function validateServiceConstraints is not exported so, we might need different way to validate the values.

@surajssd
Copy link
Member Author

surajssd commented Aug 11, 2016

Also with libcompose I found this thing:

[vagrant@fedora tmp]$ cat docker-compose.yml 
version: "2"

services:
  mariadb:
    ports:
      - 3306

somehow the docker-compose warning is not what I get

[vagrant@fedora tmp]$ libcompose up
WARN[0000] Note: This is an experimental alternate implementation of the Compose CLI (https://github.com/docker/compose) 
INFO[0000] [0/1] [mariadb]: Starting                    
ERRO[0000] Failed Starting mariadb : Error: No such image: tmp_mariadb 
ERRO[0000] Failed to start: mariadb : Error: No such image: tmp_mariadb 
Error: No such image: tmp_mariadb

Using following libcompose version

$ libcompose version
WARN[0000] Note: This is an experimental alternate implementation of the Compose CLI (https://github.com/docker/compose) 
Version:      0.3.0-dev (HEAD)
Go version:   go1.6.3

It didn't tell me that I have not put image name!

@surajssd
Copy link
Member Author

But for a docker-compose file of v1 like this

[vagrant@fedora tmp]$ cat docker-compose.yml
mariadb:
  ports:
    - 3306

I get errors similar to docker-compose

[vagrant@fedora tmp]$ libcompose up
WARN[0000] Note: This is an experimental alternate implementation of the Compose CLI (https://github.com/docker/compose) 
ERRO[0000] Could not parse config for project tmp : Service 'mariadb' has neither an image nor a build path specified. Exactly one must be provided. 
FATA[0000] Failed to read project: Service 'mariadb' has neither an image nor a build path specified. Exactly one must be provided.

@surajssd
Copy link
Member Author

Filed issue in libcompose docker/libcompose#357

@sebgoa
Copy link
Contributor

sebgoa commented Oct 5, 2016

@surajssd @ngtuna looks like lib compose now got validation for v2 docker/libcompose#371

We should try to close this.

@ngtuna
Copy link
Contributor

ngtuna commented Oct 5, 2016

Well yeah, upgrade libcompose will help solving couple of problems.
Hey @kadel , I could help to do that while you are taking care of k8s go client.

@kadel
Copy link
Member

kadel commented Oct 6, 2016

@ngtuna sure, go ahead

@ngtuna
Copy link
Contributor

ngtuna commented Oct 10, 2016

closed via #195

@ngtuna ngtuna closed this as completed Oct 10, 2016
@surajssd
Copy link
Member Author

@ngtuna this is issue is not fixed yet!

@surajssd
Copy link
Member Author

docker-compose file

$ cat docker-compose-no-image.yml 
version: "2"

services:
  mariadb:
    ports:
      - 3306

  etherpad:
    ports:
      - "80:9001"

output

$ kompose -f docker-compose-no-image.yml convert --stdout -y
apiVersion: v1
items:
- apiVersion: v1
  kind: Service
[SNIP]
    loadBalancer: {}
- apiVersion: extensions/v1beta1
  kind: Deployment
  metadata:
    creationTimestamp: null
    name: mariadb
  spec:
    replicas: 1
    strategy: {}
    template:
      metadata:
        creationTimestamp: null
        labels:
          service: mariadb
      spec:
        containers:
        - name: mariadb
          ports:
          - containerPort: 3306
            protocol: TCP
          resources: {}
        restartPolicy: Always
  status: {}
- apiVersion: extensions/v1beta1
  kind: Deployment
  metadata:
    creationTimestamp: null
    name: etherpad
  spec:
    replicas: 1
    strategy: {}
    template:
      metadata:
        creationTimestamp: null
        labels:
          service: etherpad
      spec:
        containers:
        - name: etherpad
          ports:
          - containerPort: 9001
            protocol: TCP
          resources: {}
        restartPolicy: Always
  status: {}
kind: List
metadata: {}

@surajssd surajssd reopened this Oct 12, 2016
@ngtuna
Copy link
Contributor

ngtuna commented Oct 12, 2016

Oh you're right. Thanks @surajssd good catch. If that's compose version 1, kompose worked. But it seems does not work on version 2. Let me check.

@ngtuna ngtuna assigned ngtuna and unassigned surajssd Oct 22, 2016
@sebgoa
Copy link
Contributor

sebgoa commented Nov 29, 2016

@ngtuna any news on this.

@sebgoa sebgoa added this to the v0.2.1 release milestone Nov 29, 2016
@ngtuna
Copy link
Contributor

ngtuna commented Nov 29, 2016

@sebgoa it's still there. Just tested with libcompose HEAD. Let me just tackling it directly without libcompose.

@ngtuna
Copy link
Contributor

ngtuna commented Dec 31, 2016

This issue just be solved in libcompose docker/libcompose#415. Will check that piece of code shortly.

cdrage added a commit to cdrage/kompose that referenced this issue Jan 3, 2017
This commit updates libcompose in order to merge in
docker/libcompose#423 which affected
kubernetes#92 by not
erroring out when an image name wasn't provided.

Closes kubernetes#92

As well as knocks out the last required milestone for a 0.2.1 release
https://github.com/kubernetes-incubator/kompose/milestone/2
cdrage added a commit to cdrage/kompose that referenced this issue Jan 4, 2017
This commit updates libcompose in order to merge in
docker/libcompose#423 which affected
kubernetes#92 by not
erroring out when an image name wasn't provided.

Closes kubernetes#92

As well as knocks out the last required milestone for a 0.2.1 release
https://github.com/kubernetes-incubator/kompose/milestone/2
kadel pushed a commit to kadel/kompose that referenced this issue Jan 20, 2017
This commit updates libcompose in order to merge in
docker/libcompose#423 which affected
kubernetes#92 by not
erroring out when an image name wasn't provided.

Closes kubernetes#92

As well as knocks out the last required milestone for a 0.2.1 release
https://github.com/kubernetes-incubator/kompose/milestone/2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

4 participants