Skip to content

Conversation

@kmala
Copy link
Contributor

@kmala kmala commented Jun 30, 2016

Output before:

keerthanmala$ deis scale web=-1
'web=-1' does not match the pattern 'type=num', ex: web=2
Scaling processes... but first, coffee!
done in 0s
=== woodsy-jokester Processes
--- cmd:
woodsy-jokester-v2-cmd-zbonf up (v2)

after:

deis scale web=-1 -a=woodsy-jokester
'web=-1' does not match the pattern 'type=num', ex: web=2

@deis-bot
Copy link

@Joshua-Anderson and @helgi are potential reviewers of this pull request based on my analysis of git blame information. Thanks @kmala!

@kmala kmala self-assigned this Jun 30, 2016
@kmala kmala added this to the v2.2 milestone Jun 30, 2016
cmd/ps.go Outdated
return err
}
} else {
fmt.Printf("'%s' does not match the pattern 'type=num', ex: web=2\n", target)
Copy link
Member

@bacongobbler bacongobbler Jun 30, 2016

Choose a reason for hiding this comment

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

I think we should just make this return an error if there's a bad seed in the scale list. That would solve this problem quickly, cause ps:scale to return non-zero and we can test for it.

e.g.

return fmt.Errorf("'%s' does not match the pattern 'type=num', ex: web=2\n", target)

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 am ok with returning and error but i think we are not returning an error because user can try to scale multiple proc types at a time and only few can be bad.

Copy link
Member

@bacongobbler bacongobbler Jun 30, 2016

Choose a reason for hiding this comment

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

yeah but what I mean is that if there is a single bad scale type we should error and say "hey, this process type is poorly formed, so we're not going to accept this request. Please try again."

Same thing applies for config:set as well. For example there were issues like #61 that was unintended, so there is precedence.

Copy link
Member

Choose a reason for hiding this comment

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

also the current implementation will cause ps:scale to return 0 (meaning success) when they call deis ps:scale web=-1. That's not really what we would want to do in this scenario

@bacongobbler
Copy link
Member

In the future we should probably clean this out so we don't have to have this ugly testing code to mock out the client settings, but this works for now. Thanks!

cmd/ps_test.go Outdated
t.Fatalf("error creating temp directory (%s)", err)
}
os.Setenv("DEIS_PROFILE", "testing")
os.Setenv("HOME", tmpDir)
Copy link
Contributor

@Joshua-Anderson Joshua-Anderson Jul 6, 2016

Choose a reason for hiding this comment

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

This will break on windows, cause $HOME is different. I wrote settings.SetHome to handle the cross platform differences transparently.

@Joshua-Anderson
Copy link
Contributor

Joshua-Anderson commented Jul 6, 2016

The way I've normally tested the stuff is by extracting the logic I want to test into its own function and then test that, which IMO is a bit cleaner. cmd.chooseKey is an example of this.

I also have some mock session code in settings_tests.go that could probably be made public and does all this work for you, if you want to use a session.

@bacongobbler
Copy link
Member

bacongobbler commented Jul 6, 2016

that is indeed the better approach, but I am happy to merge this as-is and we can clean this up later.

}
} else {
fmt.Printf("'%s' does not match the pattern 'type=num', ex: web=2\n", target)
return fmt.Errorf("'%s' does not match the pattern 'type=num', ex: web=2\n", target)
Copy link
Member

Choose a reason for hiding this comment

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

can this become a struct that implements error?

Copy link
Member

Choose a reason for hiding this comment

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

you mean like https://github.com/deis/controller-sdk-go/blob/master/errors.go? Those errors are for server-side, but that is a good suggestion.

Copy link
Member

@arschles arschles Jul 7, 2016

Choose a reason for hiding this comment

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

not a global var, a global type since this has variable data in it:

type errInvalidScalePattern struct {
  target string
}

// Error implements the error interface
func (e errInvalidScalePattern) Error() string {
  return fmt.Sprintf("'%s' does not match the pattern 'type=num', ex: web=2\n", e.target)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is something which needs to be done on the whole repo....may be i can create an issue and do it later?

Copy link
Member

Choose a reason for hiding this comment

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

@kmala an issue to do it later is fine, but why not start with this one now?

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 created an issue #129

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants