-
Notifications
You must be signed in to change notification settings - Fork 770
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
Kompose will keep trying its job #477
Conversation
@@ -640,9 +640,10 @@ func (k *Kubernetes) Undeploy(komposeObject kobject.KomposeObject, opt kobject.C | |||
//FIXME: gracePeriod is nil | |||
err = rpDeployment.Stop(namespace, t.Name, TIMEOUT*time.Second, nil) | |||
if err != nil { | |||
return err |
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.
These REALLY shouldn't be removed... If it errors out during deployment Kompose should return an err. It's not good Go practice to simply log.Error(err)
.
If we're retrying for a job.... this should be more complicated and use a Go channel (maybe) + retry maybe 3 times + timeout then return err.
Thoughts @kadel ?
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 we returned the error, kompose will not be able to keep doing its job (as discussed in issue, its there only in the case of kompose down)
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.
Whole point of the issue is that we error out (return error) and that is not good. We need at least try delete the rest of the objects. Error in deleting one of the objects shouldn't be show stopper for deleting the rest.
On the other hand, Undeploy
function should probably return error if we can't be sure that all the objects were deleted. Maybe those error should be aggregated so it can be returned at the end.
@containscafeine was looking into error handling lately. He might know what would be best 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.
How about we defer
the return err
statements? This way, the errors will get returned at the end of Undeploy()
and by that time the other resources would also have been 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.
I don't know if defer is going to help here.
Maybe just collecting all the errors to array and then returning it should be enough.
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.
Just create a list of errors and then return that maybe and the caller of undeploy should print it in right way or whatever!
Please use |
It is not going to go away. This logic will be still needed, #483 is not solving this problem. |
c03dadf
to
27b37ca
Compare
} | ||
} | ||
} | ||
} | ||
return nil | ||
return ErrorList |
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 seems a bit unconventional for Go, why an ErrorList? We should be returning an error when it actually happens and not continue throughout the code, should this be nil? @kadel
Honestly, it seems awkward that in order to "keep trying" for Kompose, it means going against Go conventions and continuing through the code brute-force. Having logic throughout the code would be more viable instead.
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.
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.
Okay, shouldn't we use https://golang.org/pkg/go/scanner/#ErrorList instead? @kadel
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 seems a bit unconventional for Go, why an ErrorList? We should be returning an error when it actually happens and not continue throughout the code, should this be nil? @kadel
I don't think that this is against Go conventions. It quite common to aggregate errors into slice. If you look at Kubernetes code base you can see it there. Only difference is that they are doing it little bit smarter. They don't return slice of errors, but Aggregate
. Aggregate is special type that implements error interface and can contain multiple errors. (see https://github.com/kubernetes/kubernetes/blob/55bee3ad21f025b1416a4e1f10de753f484b66d3/staging/src/k8s.io/apimachinery/pkg/util/errors/errors.go#L36).
I don't think we need to do that like that right now, just returning []error
should be enough.
Something went wrong, even if we tried to continue but we need to inform user that something wasn't deleted.
This is simplification, because ideally deletion should happen in parallel. Every delete should have run its own goroutine. But I don't think we should worry about that right now. Doing it serially on-by-one is ok for now.
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 makes sense. Instead of Go routines (maybe implement them later if API calls start becoming lengthy), just iterating through each-step would be the best-case-scenario. I totally agree!
It looks like that |
@@ -691,17 +691,19 @@ func (k *Kubernetes) Deploy(komposeObject kobject.KomposeObject, opt kobject.Con | |||
} | |||
|
|||
// Undeploy deletes deployed objects from Kubernetes cluster | |||
func (k *Kubernetes) Undeploy(komposeObject kobject.KomposeObject, opt kobject.ConvertOptions) error { | |||
func (k *Kubernetes) Undeploy(komposeObject kobject.KomposeObject, opt kobject.ConvertOptions) []error { | |||
var ErrorList []error |
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.
There shouldn't be capital 'E'. it should be lower-case.
Uppercase in go means public variable, we don't want that here.
@@ -495,20 +495,22 @@ func (o *OpenShift) Deploy(komposeObject kobject.KomposeObject, opt kobject.Conv | |||
} | |||
|
|||
//Undeploy removes deployed artifacts from OpenShift cluster | |||
func (o *OpenShift) Undeploy(komposeObject kobject.KomposeObject, opt kobject.ConvertOptions) error { | |||
func (o *OpenShift) Undeploy(komposeObject kobject.KomposeObject, opt kobject.ConvertOptions) []error { | |||
var ErrorList []error |
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. this should be errorList
27b37ca
to
ccad3d4
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.
Other than the changes requests (removing comments), LGTM.
//Convert komposeObject | ||
objects, err := k.Transform(komposeObject, opt) | ||
|
||
if err != nil { | ||
return errors.Wrap(err, "k.Transform failed") | ||
errorList = append(errorList, err) | ||
//return errors.Wrap(err, "k.Transform failed") |
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.
need to remove this comment
//Convert komposeObject | ||
objects, err := o.Transform(komposeObject, opt) | ||
|
||
if err != nil { | ||
return errors.Wrap(err, "o.Transform failed") | ||
errorList = append(errorList, err) | ||
//return errors.Wrap(err, "o.Transform failed") |
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 needs to be removed
fixes kubernetes#270 all errors in undeploy method(both kubernetes and openshift) are appended in a slice of errors, and then it will be returned after successful deletion of all components.
ccad3d4
to
80b15c1
Compare
@cdrage done with changes |
LGTM |
I just found that there is a BIG mistake in there. If it can't connect to cluster it panics. Problem is that we continue after every error. |
@kadel Yeah. I thought we were brute-forcing the force down since we're iterating right through each-one of them. I've opened up a PR to revert this so we can at least push a release today. |
yeh, that was a bit too much brute-forcing :-) |
new take on "Kompose will keep trying its job #477"
fixes #270