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

added support for restart-policy keys in v3 #666

Merged
merged 1 commit into from
Jul 6, 2017

Conversation

surajnarwade
Copy link
Contributor

Resolves restart_policy from issue #644

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 22, 2017
@surajnarwade surajnarwade force-pushed the add-restart-policy-v3 branch 6 times, most recently from 4b20ac5 to 72a94d8 Compare June 22, 2017 13:44
@@ -160,7 +160,7 @@
}
},
"spec": {
"replicas": 1,
"replicas": 6,
Copy link
Member

Choose a reason for hiding this comment

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

neither should this..

Copy link
Contributor Author

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"
Copy link
Member

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

Copy link
Contributor Author

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

// 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
Copy link
Member

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 :)

@surajnarwade surajnarwade changed the title added support for restart-policy keys in v3 [WIP]added support for restart-policy keys in v3 Jun 23, 2017
@@ -363,13 +358,10 @@
"stdin": true,
"tty": true
}
],
"restartPolicy": "Always"
Copy link
Member

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"
Copy link
Member

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?

Copy link
Contributor Author

@surajnarwade surajnarwade Jun 27, 2017

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"
}
Copy link
Member

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"
Copy link
Member

Choose a reason for hiding this comment

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

Annotations should still work ^^

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same here

@surajnarwade
Copy link
Contributor Author

@cdrage , there was typo ( on_failure >> on-failure) in example due to which output was varying, can you please review now.

// 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
Copy link
Member

Choose a reason for hiding this comment

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

please add spaces after //


//Here we handle all Docker Compose Deploy keys
//Handling restart-policy
if composeServiceConfig.Deploy.RestartPolicy != nil {
Copy link
Member

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
Copy link
Member

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!

Copy link
Member

Choose a reason for hiding this comment

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

template.Spec.RestartPolicy = api.RestartPolicyAlways
case "no":
case "no", "none":
template.Spec.RestartPolicy = api.RestartPolicyNever
case "on-failure":
Copy link
Member

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!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

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 ?

Copy link
Member

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.

@surajnarwade surajnarwade changed the title [WIP]added support for restart-policy keys in v3 added support for restart-policy keys in v3 Jun 27, 2017
@surajnarwade surajnarwade force-pushed the add-restart-policy-v3 branch 3 times, most recently from 3cfe312 to 5b97b04 Compare June 29, 2017 06:07
@surajnarwade
Copy link
Contributor Author

@cdrage , on_failure case added, final review please and ready for merge :)

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.

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":
Copy link
Member

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!

docker/cli#262

Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

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

@surajnarwade
Copy link
Contributor Author

@kadel @surajssd needed one more +1 here :)

@surajnarwade
Copy link
Contributor Author

@cdrage , removed on_failure, we are good to go

@cdrage
Copy link
Member

cdrage commented Jul 4, 2017

@surajnarwade thanks for helping me in terms of the confusion! this LGTM

@surajnarwade
Copy link
Contributor Author

@surajssd , needs +1 to get it merged

@surajnarwade surajnarwade force-pushed the add-restart-policy-v3 branch 3 times, most recently from fcda771 to 8cc8473 Compare July 6, 2017 11:56
Resolves `restart_policy` from issue kubernetes#644
@surajssd surajssd merged commit 14dbb30 into kubernetes:master Jul 6, 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. rebase needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants