Skip to content

[WIP] Update to Gitbase v0.20.0 - #439

Open
se7entyse7en wants to merge 21 commits into
src-d:masterfrom
se7entyse7en:gitbase-v0.20.0
Open

[WIP] Update to Gitbase v0.20.0#439
se7entyse7en wants to merge 21 commits into
src-d:masterfrom
se7entyse7en:gitbase-v0.20.0

Conversation

@se7entyse7en

@se7entyse7en se7entyse7en commented Apr 12, 2019

Copy link
Copy Markdown
Contributor

Closes #424.

Marked as WIP as waiting for final Gitbase v0.20.0 release.

This PR removes the MysqlCli component and uses the MySql client provided by Gitbase itself.

@se7entyse7en

Copy link
Copy Markdown
Contributor Author

The tests are failing due to a bug that will be fixed by #432.

@carlosms

Copy link
Copy Markdown
Contributor

Looks good so far.
But it looks like there are more test that are failing, not only because of #432.

@se7entyse7en

Copy link
Copy Markdown
Contributor Author

@carlosms thanks I didn't notice. To simplify review I've just rebased to master to solve conflicts, gonna address the tests now and also update to beta3.

Comment thread cmd/srcd/cmd/sql.go
return humanizef(err, "could not start gitbase")
}

if err := docker.EnsureInstalled(components.MysqlCli.Image, components.MysqlCli.Version); err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this function has name startGitbaseWithClient but it doesn't start client anymore. Just gitbase.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done here and here.

Comment thread docker/docker_exec.go Outdated
}

defer func() {
err = term.RestoreTerminal(fd, prevState)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this error is never returned from the function

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

refactored this part here. It should be clearer now and the code is more decoupled.

Comment thread docker/docker_exec.go Outdated
return &insResp, nil
}

func withRawTerminal(in io.ReadCloser, fn func() error) func() error {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the name of this function and arguments below are a little confusing. withRawTerminal and rawTerminal. But actually you pass true and call this function even for non-terminal.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

answered here.

Comment thread cmd/srcd/cmd/sql.go
err := docker.RemoveContainer(components.MysqlCli.Name)
if err != nil {
log.Warningf("could not stop mysql client: %v", err)
if insResp.ExitCode != 0 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not sure if we have tests for it. What happens when you exit with ctrl-c or ctrl-d? Does it exit correctly with exit code 0?

@se7entyse7en se7entyse7en Apr 23, 2019

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nice catch! Now it exits with 0 on ctrl-d but not on ctrl-c. Gonna try adding a test for these.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

maybe it's okay to exit with error on ctrl-c in this case

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added a test for Ctrl-D here.

Comment thread docker/docker_exec.go Outdated

return fn()
}
type stdioAttaccher struct {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

attach -> attacher

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤦‍♂️

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed here.

Comment thread docker/docker_exec.go Outdated
// characters
prevState, err = term.SetRawTerminal(fd)
if err != nil {
done <- err

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you have deadlock here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

😮 eagle's eye! thanks for noticing

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed here

Comment thread docker/docker_exec.go
prevState, err = term.SetRawTerminal(fd)
if err != nil {
done <- err
go func() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

maybe it's better to make the channel buffered?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Even if in this case would slightly increase readability, I think that using an unbuffered channel keeps the code simpler compared to the readability gain of using a buffered channel.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what exactly do you see as a downside of a buffered channel?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it's just an easier model to think 😄

Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
… containers

Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
…cess

Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
I've separatead the starting of a component into a different function
so that it can be used by other commands as well.

Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
@se7entyse7en

Copy link
Copy Markdown
Contributor Author

Rebased on master and updated to use gitbase-v0.20.0-beta4.

Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
Signed-off-by: Lou Marvin Caraig <loumarvincaraig@gmail.com>
@se7entyse7en

se7entyse7en commented May 1, 2019

Copy link
Copy Markdown
Contributor Author

Updated to gitbase-v0.20.0-rc1.

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.

Update to gitbase 0.20 beta

3 participants