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

PVC name changes if volumes containes .(dot) in it #603

Merged
merged 1 commit into from
Jun 19, 2017

Conversation

procrypt
Copy link
Contributor

@procrypt procrypt commented May 16, 2017

If the docker-compose.yml has volumes defined like this

   volumes:
     - .:/code

Then pvc generated by kompose will be like .-persistentvolumeclaim.yaml. This PR handles the .(dot) in the pvc name.

docker-compose.yml file used

web:
  image: flask_web      
  command: python app.py
  ports:
   - "5000:5000"
  volumes:
   - .:/code
  links:
   - redis
redis:
  image: redis

Master output

$ kompose convert -f volume.yml -o sample/
INFO file "sample/redis-service.yaml" created     
INFO file "sample/web-service.yaml" created       
INFO file "sample/redis-deployment.yaml" created  
INFO file "sample/web-deployment.yaml" created    
INFO file "sample/.-persistentvolumeclaim.yaml" created 

This PR output.

$ kompose convert -f volume.yml -o config/
INFO file "config/redis-service.yaml" created     
INFO file "config/web-service.yaml" created       
INFO file "config/redis-deployment.yaml" created  
INFO file "config/web-deployment.yaml" created    
INFO file "config/web-claim0-persistentvolumeclaim.yaml" created

Fixes: #584

cc: @surajssd @cdrage @surajnarwade

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 16, 2017
@procrypt procrypt changed the title PVC name changes if volumes container .(dot) in it. PVC name changes if volumes containes .(dot) in it. May 16, 2017
@procrypt procrypt changed the title PVC name changes if volumes containes .(dot) in it. PVC name changes if volumes containes .(dot) in it May 16, 2017
@@ -337,7 +337,12 @@ func (c *Compose) LoadFile(files []string) (kobject.KomposeObject, error) {
if composeServiceConfig.Volumes != nil {
for _, volume := range composeServiceConfig.Volumes.Volumes {
v := normalizeServiceNames(volume.String())
serviceConfig.Volumes = append(serviceConfig.Volumes, v)
if strings.Contains(v, ".") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of putting this if statement here (making compose.go even larger). Why not put the if / else statement inside of func normalizeVolumeNames ?

Copy link
Member

@surajssd surajssd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to do all of these things, check my comment at:
#584 (comment)

@@ -0,0 +1,11 @@
web:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's do version 2 please?

@@ -218,6 +218,13 @@ cd "$KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/node"
convert::expect_success_and_warning "kompose convert --provider openshift --stdout -j -f ../docker-compose.yml" "/tmp/output-os.json" "$warning"
cd $CURRENT_DIR

####
# Test related to change in volume-name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a better line which mentions what this test is about?

@procrypt
Copy link
Contributor Author

All tests are passing locally.

@cdrage
Copy link
Member

cdrage commented May 24, 2017

@procrypt Nope, they're not. Travis still says failing.

@surajssd
Copy link
Member

@procrypt update the fixtures with the latest code changes, I mean regenerate them again, it seems that it is taking name of fixture as ''.".

@procrypt procrypt force-pushed the error_with_volume_name branch 2 times, most recently from a7e18e4 to 6f0da4d Compare May 29, 2017 09:11
@surajssd
Copy link
Member

@procrypt openshift output matches but k8s does not?

@procrypt
Copy link
Contributor Author

@surajssd Test are passing locally.

@procrypt procrypt force-pushed the error_with_volume_name branch 2 times, most recently from c39b1b2 to bbf901d Compare May 29, 2017 10:33
@cdrage
Copy link
Member

cdrage commented May 29, 2017

@procrypt Doesn't matter if tests are passing locally or not, it has to pass on Travis in order to get approval. You may have to run these tests manually and troubleshoot to figure out what may be the issue.

@procrypt
Copy link
Contributor Author

procrypt commented May 30, 2017

@cdrage I have no idea why kubernetes test is failing on travis :(
@kadel can you please take a look at it.

@kadel
Copy link
Member

kadel commented Jun 7, 2017

Yeh, this will be quite hard to debug.
It might be time look at #604 it will make it easier to debug issues like this

@ashetty1
Copy link
Contributor

ashetty1 commented Jun 8, 2017

@procrypt tests are failing locally for me with kubernetes. I see that the patch fixes the bug; so it could be a case where the output file you are comparing against is incorrect?

@procrypt procrypt force-pushed the error_with_volume_name branch 2 times, most recently from 054271f to 39a0ca4 Compare June 12, 2017 18:59
@procrypt
Copy link
Contributor Author

@surajssd @cdrage @kadel @ashetty1 Ping all tests are passing now.

@ashetty1
Copy link
Contributor

LGTM

Copy link
Member

@cdrage cdrage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other than small change for port, this code LGTM.

@@ -16,7 +16,7 @@ services:
etherpad:
image: centos/etherpad
ports:
- "80:9001"
- "81:9001"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 81? please change back to 80 :(

@surajssd
Copy link
Member

The commit message needs to framed better also the extra tab space makes it look more weird

@surajssd
Copy link
Member

tried running this locally, it fails for some reason:

The test fails:

$ kompose version
0.6.0 (6faa732)

$ make test-cmd 
./script/test/cmd/tests.sh
...
===> Starting test <===
convert::expect_success_and_warning: Running: 'kompose convert -f
/home/hummer/go/src/github.com/kubernetes-incubator/kompose/script/test/fixtures/change-in-volume/docker-compose.yml
--stdout -j' expected_output:
'/home/hummer/go/src/github.com/kubernetes-incubator/kompose/script/test/fixtures/change-in-volume/output-k8s.json'
expected_warning: 'Volume mount on the host "." isn't supported - ignoring path on the host'
FAIL: converted output does not match
...

So when I tried re-generating the output-k8s.json it is not generating labels.

regenerate:

~/go/src/github.com/kubernetes-incubator/kompose/script/test/fixtures/change-in-volume [pr_603 L|✔] 
12:02 $ kompose convert --stdout -j > ./output-k8s.json 
WARN Volume mount on the host "." isn't supported - ignoring path on the host 
✔ ~/go/src/github.com/kubernetes-incubator/kompose/script/test/fixtures/change-in-volume [pr_603 L|✚ 1] 

diff:

$ git diff
diff --git a/script/test/fixtures/change-in-volume/output-k8s.json b/script/test/fixtures/change-in-volume/output-k8s.json
index ea27825..6ee4489 100644
--- a/script/test/fixtures/change-in-volume/output-k8s.json
+++ b/script/test/fixtures/change-in-volume/output-k8s.json
@@ -61,10 +61,7 @@
       "apiVersion": "extensions/v1beta1",
       "metadata": {
         "name": "redis",
-        "creationTimestamp": null,
-        "labels": {
-          "io.kompose.service": "redis"
-        }
+        "creationTimestamp": null
       },
       "spec": {
         "replicas": 1,
@@ -95,10 +92,7 @@
       "apiVersion": "extensions/v1beta1",
       "metadata": {
         "name": "web",
-        "creationTimestamp": null,
-        "labels": {
-          "io.kompose.service": "web"
-        }
+        "creationTimestamp": null
       },
       "spec": {
         "replicas": 1,

    if volumes in docker file is defined as
      volumes:
        - .:/code
    Then the PVC created by kompose will containes .(dot) in it.
       .-persistentvolumeclaim.yaml
@procrypt
Copy link
Contributor Author

@surajssd can you review it again when you get some time, I have updated the PR.

Copy link
Member

@surajssd surajssd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@surajssd
Copy link
Member

waiting on @cdrage to approve and merge!

@procrypt
Copy link
Contributor Author

Awesome :)

@procrypt procrypt closed this Jun 16, 2017
@procrypt procrypt reopened this Jun 16, 2017
@surajnarwade
Copy link
Contributor

LGTM 👍

@surajssd
Copy link
Member

@cdrage you need to approve to merge this!

@cdrage cdrage merged commit ee79612 into kubernetes:master Jun 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants