-
Notifications
You must be signed in to change notification settings - Fork 79
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
App Deploy (gRPC series) #211
Conversation
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.
Most comments are suggestions, the point of attention is keeping the deploy files in memory. Great job.
cmd/client/cmd/deploy.go
Outdated
|
||
currentClusterName, err := getCurrentClusterName() | ||
if err != nil { | ||
fmt.Fprintln(os.Stderr, "error on read config file:", 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.
I guess "error reading config file is better"
cmd/client/cmd/deploy.go
Outdated
} | ||
if n == 0 { | ||
break | ||
} |
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.
Maybe check for io.EOF
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.
Yeah, much better.
pkg/server/app/app.go
Outdated
@@ -19,6 +19,9 @@ type Operations interface { | |||
Create(user *storage.User, app *App) error | |||
Logs(user *storage.User, appName string, lines int64, follow bool) (io.ReadCloser, error) | |||
Info(user *storage.User, appName string) (*Info, error) | |||
TeamName(appName string) (string, error) | |||
Meta(appName string) (*App, error) | |||
HasPermission(user *storage.User, appName string) bool |
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 guess the name Meta
is a little bit misleading as it returns an app instance but I can't think of something better 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.
Me too.
I'll think again about this name, but for now, I don't have any idea.
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.
Let me know if you find a better name.
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.
What do you think about Get
?
I'm not sure because that method returns only information about the app, not a powerful struct with useful methods. BUT, is better than Meta? (or not? 🤔 )
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.
It' better, perhaps Instance
.
|
||
func TestNewBuildSpec(t *testing.T) { | ||
expectedDeployId := "123" | ||
expectedTarBallLocation := "narnia" |
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.
Maybe mordor
pkg/server/deploy/deploy.go
Outdated
go func() { | ||
defer w.Close() | ||
if err = ops.buildApp(tarBall, a, deployId, buildDest, w); err != nil { | ||
return |
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.
Maybe we should log the buildApp
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.
Oh, I forgot :/
scanner := bufio.NewScanner(r) | ||
for scanner.Scan() { | ||
c <- fmt.Sprintln(scanner.Text()) | ||
} |
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 guess we should check scanner.Err() at the end of the loop, not sure though.
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.
If raised an error we can't do much more than log the 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.
fair enough
pkg/server/deploy/handlers.go
Outdated
} | ||
defer rc.Close() | ||
|
||
deployMsgs := sendMsgsToAChannel(rc) |
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.
Maybe rename sendMsgsToAChannel -> channelFromReader
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 name is much better on a monumental scale.
pkg/server/k8s/client.go
Outdated
} | ||
io.Copy(w, stream) | ||
|
||
if err = k.waitPodEnd(pod, 1*time.Second, 5*time.Minute); err != nil { |
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.
For deploy safety we need more than 5 minutes of finish timeout, maybe more args. Also we may increase the poll interval (less cpu intensive)
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.
Hm, What do you think about 30 minutes for finish timeout and 3 seconds for check interval?
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.
That's ok.
pkg/server/k8s/client.go
Outdated
return int(state.ExitCode) | ||
} | ||
} | ||
return 0 |
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.
Maybe return error if the pod is running
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.
Do you say that because Terminated
is a pointer and it can be nil?
I'll prevent this.
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.
If I call this function on a running pod I would expect an error: pod is still running, no exit code yet. But this is 💅
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.
Gotcha!!! I'll change
pkg/server/k8s/client.go
Outdated
func newInClusterK8sClient() (Client, error) { | ||
conf, err := restclient.InClusterConfig() | ||
func (k *k8sClient) CreateDeploy(deploySpec *deploy.DeploySpec) error { | ||
replicas := k.currentPodReplicasFromDeploy(deploySpec.Namespace, deploySpec.Name) |
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.
Maybe a django style name CreateOrUpdateDeploy
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 like functions with more than one proposal but you're right, the current name does not reflect the reality.
…ement K8S methods to deal with deploy
… limit per deploy
80a36b5
to
07c25f8
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.
🔁
related #203
It's a big pull request with tons of code change on sensible features, please, pay attention and don't hesitate to point errors or even improvements.
BTW, now Teresa will delete "build pods" after they finish their job.
Good Luck 🇯🇲
This change is![Reviewable](https://camo.githubusercontent.com/23b05f5fb48215c989e92cc44cf6512512d083132bd3daf689867c8d9d386888/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)