-
Notifications
You must be signed in to change notification settings - Fork 752
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
added support for restart-policy
keys in v3
#666
Conversation
4b20ac5
to
72a94d8
Compare
@@ -160,7 +160,7 @@ | |||
} | |||
}, | |||
"spec": { | |||
"replicas": 1, | |||
"replicas": 6, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
neither should this..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but there are replicas=6
in docker-compose file, right ?
@@ -56,8 +56,7 @@ | |||
"image": "foo/bar:latest", | |||
"env": [ | |||
{ | |||
"name": "FOO", | |||
"value": "bar" | |||
"name": "FOO" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test should not be changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but results are like this, so I changed
pkg/loader/compose/v3.go
Outdated
// This is a bit messy since we use yaml.MemStringorInt | ||
// TODO: Refactor yaml.MemStringorInt in kobject.go to int64 | ||
// Since Deploy.Resources.Limits does not initialize, we must check type Resources before continuing | ||
if (composeServiceConfig.Deploy.Resources != types.Resources{}) { | ||
serviceConfig.MemLimit = libcomposeyaml.MemStringorInt(composeServiceConfig.Deploy.Resources.Limits.MemoryBytes) | ||
} | ||
//Handling restart-policy | ||
serviceConfig.Restart = composeServiceConfig.Deploy.RestartPolicy.Condition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a small comment here in regards to deploy.
Example:
// Here we handle all Docker Compose Deploy keys
So we can better organize from the rest of all the keys :)
restart-policy
keys in v3restart-policy
keys in v3
72a94d8
to
9b6450b
Compare
@@ -363,13 +358,10 @@ | |||
"stdin": true, | |||
"tty": true | |||
} | |||
], | |||
"restartPolicy": "Always" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
"annotations": { | ||
"com.example.description": "Accounting webapp", | ||
"com.example.empty-label": "", | ||
"com.example.number": "42" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these being deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cdrage, they are not deleted, just order is misplaced
} | ||
}, | ||
"strategy": { | ||
"type": "Recreate" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as here?
"annotations": { | ||
"com.example.description": "Accounting webapp", | ||
"com.example.empty-label": "", | ||
"com.example.number": "42" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annotations should still work ^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
9b6450b
to
992cbff
Compare
@cdrage , there was typo ( |
pkg/loader/compose/v3.go
Outdated
// This is a bit messy since we use yaml.MemStringorInt | ||
// TODO: Refactor yaml.MemStringorInt in kobject.go to int64 | ||
// Since Deploy.Resources.Limits does not initialize, we must check type Resources before continuing | ||
if (composeServiceConfig.Deploy.Resources != types.Resources{}) { | ||
serviceConfig.MemLimit = libcomposeyaml.MemStringorInt(composeServiceConfig.Deploy.Resources.Limits.MemoryBytes) | ||
} | ||
|
||
//Here we handle all Docker Compose Deploy keys | ||
//Handling restart-policy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add spaces after //
pkg/loader/compose/v3.go
Outdated
|
||
//Here we handle all Docker Compose Deploy keys | ||
//Handling restart-policy | ||
if composeServiceConfig.Deploy.RestartPolicy != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for != nil
, just put: if composeServiceConfig.Deploy.RestartPolicy {
@@ -39,7 +39,7 @@ services: | |||
cpus: '0.0001' | |||
memory: 20M | |||
restart_policy: | |||
condition: on_failure | |||
condition: on-failure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunatley, docker says that it works with either _ or -. 👎 but keep this change in!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed: docker/cli#262
template.Spec.RestartPolicy = api.RestartPolicyAlways | ||
case "no": | ||
case "no", "none": | ||
template.Spec.RestartPolicy = api.RestartPolicyNever | ||
case "on-failure": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will actually have to add on_failure
as well to here!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but https://docs.docker.com/compose/compose-file/#restart_policy shows on-failure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on-failure
case is already there ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, but on_failure is still supported. I can't remember where in docker/cli
is it, but it's there. It automatically converts. Unfortunately, some examples use on_failure
.
restart-policy
keys in v3restart-policy
keys in v3
3cfe312
to
5b97b04
Compare
@cdrage , |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after my small comment (remove on_failure
since it was fixed here: docker/cli#262)
Thanks man!!
template.Spec.RestartPolicy = api.RestartPolicyNever | ||
case "on-failure": | ||
case "on-failure", "on_failure": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so found out it was error upstream. it's fixed now :( so we can remove on_failure
. Sorry for confusion!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@surajnarwade gotta remove on_failure and we're good 👍
@@ -39,7 +39,7 @@ services: | |||
cpus: '0.0001' | |||
memory: 20M | |||
restart_policy: | |||
condition: on_failure | |||
condition: on-failure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed: docker/cli#262
5b97b04
to
7d64c92
Compare
@cdrage , removed |
@surajnarwade thanks for helping me in terms of the confusion! this LGTM |
@surajssd , needs +1 to get it merged |
fcda771
to
8cc8473
Compare
Resolves `restart_policy` from issue kubernetes#644
8cc8473
to
9dcb2bf
Compare
Resolves
restart_policy
from issue #644