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

restart: no gets interpreted as restart: false #67

Merged
merged 1 commit into from
Oct 8, 2015

Conversation

ibuildthecloud
Copy link
Contributor

The yaml parser seems to turn restart: no into restart: false and
false is not a valid restart policy. This patch manually fixes up the
value to be no if it is read as false.

This is based off of #66 because in that PR I added merge_test.go and didn't want to duplicate it and then have to deal with merge conflicts/rebasing.

@ibuildthecloud
Copy link
Contributor Author

@dnephin @vdemeester

if v.Restart == "false" {
v.Restart = "no"
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is the direction we want to go. We've decided against it in docker-compose (at least for now).

Re-writing boolean values to string values is not really intuitive. Could we instead warn the user that they have the wrong type?

I think this will just fix itself when #34 is completed. The jsonschema will raise a validation error if this field is a boolean

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dnephin I don't totally follow. The issue is this... If the user does the below

image:
  restart: no

The yaml parser turns restart: no into restart: false. We need to then manually change restart: false back to restart: no.

Copy link
Contributor

Choose a reason for hiding this comment

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

No, the yaml parser isn't wrong, the user is wrong.

If you go that route, you end up translating a bunch of things that aren't no into "no".

Using a boolean in a string field should result in an error. The user should write restart: 'no'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The user is always right 😄 So seriously you don't want this? This matches the behaviour of docker-compose today. restart: no works in docker-compose without restart: 'no'

Copy link
Contributor

Choose a reason for hiding this comment

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

We're changing it to a warning in the next release (1.5.0) now that we're properly validating the config. It'll become an error in the release after that.

I'm not sure how it works, since we shouldn't be doing any conversion of bool to string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dnephin I don't know how to proceed because a docker-compose.yml from docker compose will work in 1.5 and blow up in libcompose-cli. It sounds to me like we need this change to stay compatible. @joshwget is working on schema validation. Maybe when that PR is done we can revisit this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure how it works, but I agree we should revisit after validation is in

@ibuildthecloud ibuildthecloud force-pushed the restart-no branch 2 times, most recently from a207409 to c041413 Compare October 7, 2015 15:55
ConfigLookup: &NullLookup{},
})

config, err := Merge(p, []byte(`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah you need to update that I think, to mergeProject.

The yaml parser seems to turn `restart: no` into `restart: false` and
false is not a valid restart policy.  This patch manually fixes up the
value to be `no` if it is read as `false`.

Signed-off-by: Darren Shepherd <darren@rancher.com>
@ibuildthecloud
Copy link
Contributor Author

@vdemeester Fix compilation errors with Merge/mergeProject

@vdemeester
Copy link
Collaborator

So, we are ok to merge this as is and we'll get back on it when validation hits, right ? (thus we follow docker-compose < 1.5 behavior)

@ibuildthecloud
Copy link
Contributor Author

@vdemeester I believe that is the agreement. I've created an issue to track this: #72

@dnephin
Copy link
Contributor

dnephin commented Oct 7, 2015

I think the reason this doesn't fail validation in compose 1.4.2 is because the check if not restart_config:, so compose actually things there is no config instead of translating it.

I'm not against merging this, but it will become dead code as soon as #34 is implemented

@vdemeester
Copy link
Collaborator

Not against either 😉
LGTM 🐸

ibuildthecloud added a commit that referenced this pull request Oct 8, 2015
restart: no gets interpreted as restart: false
@ibuildthecloud ibuildthecloud merged commit e5e0e8e into docker:master Oct 8, 2015
@glensc
Copy link

glensc commented Apr 21, 2017

documentation still suggest unquoted version:

https://docs.docker.com/compose/compose-file/compose-file-v2/#restart

image

and that results failure on 1.9.0:

# grep restart docker-compose.override.yml
    restart: no

# docker-compose ps
ERROR: The Compose file './docker-compose.override.yml' is invalid because:
services.weblate.restart contains an invalid type, it should be a string

@vdemeester
Copy link
Collaborator

@glensc hum this PR is quite old though, we have schema validation now, that should be the same as docker-compose, I would guess it's doing the same with libcompose 👼

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

Successfully merging this pull request may close these issues.

5 participants