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

commands: reimplements printing deployment statuses, closes #462 #486

Merged
merged 8 commits into from
Sep 21, 2018

Conversation

ilgooz
Copy link
Contributor

@ilgooz ilgooz commented Sep 20, 2018

  • utils/pretty: add UseSpinner() and DestroySpinner() funcs.

* utils/pretty: add UseSpinner() and DestroySpinner() funcs.
pretty.Progress("Deploying the service...", func() {
id, valid, err = c.e.ServiceDeploy(c.path)
})
statuses := make(chan provider.DeployStatus, 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Small change, but if you're putting 0, just skip it and write make(chan provider.DeplyStatus)

warning: should use make(chan provider.DeployStatus) instead (S1019) (megacheck)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -4,6 +4,9 @@ import (
"errors"
"fmt"

"github.com/mesg-foundation/core/x/xerrors"

Copy link
Contributor

Choose a reason for hiding this comment

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

remove empty line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -23,7 +23,7 @@ type ServiceExecutor interface {
ServiceByID(id string) (*coreapi.Service, error)
ServiceDeleteAll() error
ServiceDelete(ids ...string) error
ServiceDeploy(path string) (id string, valid bool, err error)
ServiceDeploy(path string, statuses chan provider.DeployStatus) (id string, validationError, err error)
Copy link
Contributor

Choose a reason for hiding this comment

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

Update commands_mock_test.go with new api

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

if !valid {
return errors.New("Service is invalid. To get more information, run: mesg-core service validate")
if validationError != nil {
pretty.DestroySpinner()
Copy link
Contributor

Choose a reason for hiding this comment

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

Here just wonder, shouldn't deployer return DONE DeployedStatus on an error, it's kind of done but with error.

Because Here stoping spinner that hasn't been started in the same function looks suspicious.

The same situation is in service_dev.go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i had the similar thing in my mind but i wasn't sure to implement this because this is not an exception to validation error. an error may occour at any time during deployment and because of this we may need to destroy spinner unexpectedly. actually, I should move this line to out of validationError's nil check to make sure we call it all the time, thanks for the heads up.

Copy link
Contributor

Choose a reason for hiding this comment

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

What about sending DONE to deploy statuses?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i think errors should be only returned from funcs otherwise we'll have duplication of errors in the place where they're handled. feel free to open an issue about this so we can discuss there.


const (
// RUNNING indicates that status message belongs to an active state.
RUNNING StatusType = iota + 1
Copy link
Contributor

Choose a reason for hiding this comment

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

One small change - use iota - there is no obvious reason why counting should be started from 1.

Copy link
Contributor Author

@ilgooz ilgooz Sep 20, 2018

Choose a reason for hiding this comment

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

in go, it's a best practice to count constants from 1. i guess this due to 0 is a zero value in go

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you provide some article/best practice about this? I want to read about it.
thanks

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
Member

Choose a reason for hiding this comment

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

We could add a status UNKNOWN and start at iota like that it's ok. I agree that we shouldn't start at 0, we can have some side effects with that.

Like here https://github.com/mesg-foundation/core/blob/a6887f298acf9e1e1d09f6b853d44a660b3b3a46/service/status.go#L11-L17

or here

https://github.com/mesg-foundation/core/blob/a6887f298acf9e1e1d09f6b853d44a660b3b3a46/container/type.go#L7-L12


const (
// RUNNING indicates that status message belongs to an active state.
RUNNING StatusType = iota + 1
Copy link
Member

Choose a reason for hiding this comment

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

We could add a status UNKNOWN and start at iota like that it's ok. I agree that we shouldn't start at 0, we can have some side effects with that.

Like here https://github.com/mesg-foundation/core/blob/a6887f298acf9e1e1d09f6b853d44a660b3b3a46/service/status.go#L11-L17

or here

https://github.com/mesg-foundation/core/blob/a6887f298acf9e1e1d09f6b853d44a660b3b3a46/container/type.go#L7-L12

@antho1404 antho1404 merged commit 15a9a0c into dev Sep 21, 2018
@antho1404 antho1404 deleted the feature/fix-commands-deploy branch September 21, 2018 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants