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

Track container events, reworked Deployment management #334

Merged
merged 28 commits into from
Jul 29, 2018

Conversation

bobheadxi
Copy link
Member

@bobheadxi bobheadxi commented Jul 28, 2018

🎟️ Ticket(s): Closes #161, improves #237, closes #323


👷 Changes

  • Moved and refactored some build tests
  • Deployment is now a persistent class created upon daemon startup
  • A new goroutine to watch event channels for container stoppages - based on if a project is active or not, certain container stoppages should be reported as an error and stop the project entirely. Not the cleanest, but a stopgap solution for now as some other tickets get resolved (I'm thinking deploy: quick rollback #293, Reverse proxy in front of project #311, daemon: event database #297... dunno)

🔦 Testing Instructions

inertia local up
inertia local ssh
# docker ps
# docker kill $SOME_CONTAINER

You should get:

W2018-07-29T00:38:12.382370676Z container inertia-deploy-test_webdev_1 (76f8a) has stopped
T2018-07-29T00:38:12.382427581Z container stoppage was unexpected, project is active
B2018-07-29T00:38:12.382403754Z Shutting down active containers...
I2018-07-29T00:38:12.385818586Z Stopping /inertia-deploy-test_webdev_1...
;2018-07-29T00:38:12.732767097Z Stopping /docker-compose...
I2018-07-29T00:38:13.316878318Z container docker-compose (e7c85) has stopped

@bobheadxi bobheadxi added the pr: wip in progress but seeking feedback label Jul 28, 2018
@bobheadxi bobheadxi force-pushed the daemon/#161-container-failures branch from 0e112c4 to cb721ff Compare July 28, 2018 21:43
@codecov
Copy link

codecov bot commented Jul 28, 2018

Codecov Report

Merging #334 into master will increase coverage by 3.63%.
The diff coverage is 20.91%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #334      +/-   ##
==========================================
+ Coverage   40.16%   43.78%   +3.63%     
==========================================
  Files          57       58       +1     
  Lines        3230     3287      +57     
==========================================
+ Hits         1297     1439     +142     
+ Misses       1779     1663     -116     
- Partials      154      185      +31
Impacted Files Coverage Δ
daemon/inertiad/env.go 0% <ø> (ø) ⬆️
daemon/inertiad/daemon.go 0% <0%> (ø) ⬆️
daemon/inertiad/up.go 0% <0%> (ø) ⬆️
daemon/inertiad/reset.go 0% <0%> (ø) ⬆️
daemon/inertiad/webhook.go 0% <0%> (ø) ⬆️
daemon/inertiad/prune.go 0% <0%> (ø) ⬆️
daemon/inertiad/containers/containers.go 57.48% <0%> (-7.46%) ⬇️
daemon/inertiad/logs.go 0% <0%> (ø) ⬆️
daemon/inertiad/containers/docker.go 100% <100%> (ø)
daemon/inertiad/project/deployment.go 39.65% <24%> (-5.54%) ⬇️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 437fc52...a05c3d3. Read the comment docs.

@bobheadxi bobheadxi force-pushed the daemon/#161-container-failures branch from b213982 to 98b8d33 Compare July 28, 2018 23:46
@bobheadxi bobheadxi added pr: finalized needs review and final approval and removed pr: wip in progress but seeking feedback labels Jul 29, 2018
@bobheadxi bobheadxi requested review from brian-nguyen, bwdmonkey and a team July 29, 2018 00:44
return nil, errors.New("Build exited with non-zero status: " + strconv.FormatInt(status, 10))
if status.StatusCode != 0 {
return nil, fmt.Errorf(
"Build exited with non-zero status %s", strconv.FormatInt(status.StatusCode, 10))
Copy link
Member

Choose a reason for hiding this comment

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

Couldn't we just straight pass it into instead of casting?

close(stop)
if err != nil {
return nil, err
statusCh, errCh := cli.ContainerWait(ctx, resp.ID, "")
Copy link
Member

Choose a reason for hiding this comment

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

Seems like a bit of duplicate code is here. I think it would be nice to have a helper function instead.

"github.com/ubclaunchpad/inertia/daemon/inertiad/crypto"
"github.com/ubclaunchpad/inertia/daemon/inertiad/project"
)

const (
msgNoDeployment = "No deployment is currently active on this remote - try running 'inertia $REMOTE up'"
Copy link
Member

Choose a reason for hiding this comment

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

Standardization please. [remote]

Copy link
Member

@bwdmonkey bwdmonkey left a comment

Choose a reason for hiding this comment

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

Didn't run it yet. Just syntax stuff.

}
defer cli.Close()

if status, _ := deployment.GetStatus(cli); len(status.Containers) == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

💯

},
logger,
)
if err != nil {
logger.WriteErr(err.Error(), http.StatusPreconditionFailed)
return
}
deployment = d
Copy link
Member

Choose a reason for hiding this comment

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

lol

@bobheadxi bobheadxi force-pushed the daemon/#161-container-failures branch from 14add4e to 2bdc799 Compare July 29, 2018 02:21
@bobheadxi bobheadxi merged commit 9a21acc into master Jul 29, 2018
@bobheadxi bobheadxi deleted the daemon/#161-container-failures branch July 29, 2018 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: finalized needs review and final approval
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move deploy tests to package inertiad/build Gracefully handle container failures
2 participants