-
Notifications
You must be signed in to change notification settings - Fork 772
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
error out if controller object is specified with "restart: on-failure" #373
Conversation
0dee862
to
83723f8
Compare
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 is not working.
with docker-compose file from #354
▶ ./kompose convert
FATA[0000] Controller object cannot be specified with restart: 'on-failure'
this should be valid
@@ -463,6 +463,10 @@ func (k *Kubernetes) Transform(komposeObject kobject.KomposeObject, opt kobject. | |||
service := komposeObject.ServiceConfigs[name] | |||
var objects []runtime.Object | |||
|
|||
// Show error if no controller object is specified and restart: "on-failure" | |||
if opt.CreateD && service.Restart == "on-failure" || opt.CreateDS && service.Restart == "on-failure" || opt.CreateDeploymentConfig && service.Restart == "on-failure" || opt.CreateRC && service.Restart == "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.
this doesn't look right :-(
It should be also handled somewhere else. Don't forget about OpenShift transformer ;-)
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.
k8sutils.go would be a better area. similar to your work on cpu_shares https://github.com/kubernetes-incubator/kompose/pull/294/files
@@ -111,7 +111,7 @@ convert::expect_success_and_warning "kompose --bundle $KOMPOSE_ROOT/script/test/ | |||
# Test related to restart options in docker-compose | |||
# kubernetes test | |||
convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/restart-options/docker-compose-restart-no.yml convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/restart-options/output-k8s-restart-no.json" | |||
convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/restart-options/docker-compose-restart-onfail.yml convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/restart-options/output-k8s-restart-onfail.json" |
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 remove this test? It is valid
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.
new failing tests should be added, which will check if it fails on adding more objects on convert.
@@ -463,6 +463,10 @@ func (k *Kubernetes) Transform(komposeObject kobject.KomposeObject, opt kobject. | |||
service := komposeObject.ServiceConfigs[name] | |||
var objects []runtime.Object | |||
|
|||
// Show error if no controller object is specified and restart: "on-failure" | |||
if opt.CreateD && service.Restart == "on-failure" || opt.CreateDS && service.Restart == "on-failure" || opt.CreateDeploymentConfig && service.Restart == "on-failure" || opt.CreateRC && service.Restart == "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.
k8sutils.go would be a better area. similar to your work on cpu_shares https://github.com/kubernetes-incubator/kompose/pull/294/files
30355e5
to
39e2898
Compare
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.
Thank for refactoring your original code! This looks a lot cleaner :)
IsDeploymentFlag: cmd.Flags().Lookup("deployment").Changed, | ||
IsDaemonSetFlag: cmd.Flags().Lookup("daemon-set").Changed, | ||
IsReplicationControllerFlag: cmd.Flags().Lookup("replication-controller").Changed, | ||
IsDeploymentConfigFlag: cmd.Flags().Lookup("deployment-config").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.
👍 on all above :)
// Error out if Controller Object is specified with restart: 'on-failure' | ||
if opt.IsDeploymentFlag || opt.IsDaemonSetFlag || opt.IsReplicationControllerFlag { | ||
logrus.Fatalf("Controller object cannot be specified with restart: '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.
Don't really understand this part. If a user doesn't pass in these flags, it won't error out?
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.
// Error out if Controller Object is specified with restart: 'on-failure' | ||
if opt.IsDeploymentConfigFlag { | ||
logrus.Fatalf("Controller object cannot be specified with restart: '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.
same here.. What happens if the user doesnt pass in the flag but still supplies an "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.
@cdrage If the user don't pass the flag and still supplies on-failure
, then kompose convert
will create the config files for it.
Thanks for the comments. This LGTM :) All green from me. |
39e2898
to
1ecd32a
Compare
@procrypt Thanks for the awesome work! Merging away :) |
Fixes #354
CC: @kadel @surajssd