Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(940)

Issue 7134051: worker/stater: new package (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 1 month ago by dave
Modified:
11 years, 11 months ago
Reviewers:
rog, mp+143629, fwereade, niemeyer
Visibility:
Public.

Description

worker/stater: new package This proposal introduces a new jujud worker, a Stater. The roll of the Stater is to handle installing and configuring a state server (read mongodb). In this initial implementation the Stater is capable of replacing the bash scripting in environs/cloudinit/cloudinit, although The actual change to cloudinit is the following proposal. https://code.launchpad.net/~dave-cheney/juju-core/069-worker-stater-I/+merge/143629 (do not edit description out of merge proposal)

Patch Set 1 #

Patch Set 2 : worker/stater: new package #

Patch Set 3 : worker/stater: new package #

Patch Set 4 : worker/stater: new package #

Total comments: 17

Patch Set 5 : worker/stater: new package #

Total comments: 6

Patch Set 6 : worker/stater: new package #

Total comments: 15
Unified diffs Side-by-side diffs Delta from patch set Stats (+434 lines, --1 lines) Patch
A [revision details] View 1 2 3 4 5 1 chunk +2 lines, -0 lines 0 comments Download
A worker/stater/config_test.go View 1 1 chunk +61 lines, -0 lines 0 comments Download
A worker/stater/stater.go View 1 2 3 4 5 1 chunk +218 lines, -0 lines 13 comments Download
A worker/stater/stater_test.go View 1 2 3 4 1 chunk +108 lines, -0 lines 0 comments Download
A worker/stater/testdata/fakemongo-2.2.0-quantal-amd64.tgz View 1 0 chunks +-1 lines, --1 lines 0 comments Download
A worker/stater/tools.go View 1 2 3 4 5 1 chunk +23 lines, -0 lines 2 comments Download
A worker/stater/tools_test.go View 1 2 3 4 1 chunk +23 lines, -0 lines 0 comments Download

Messages

Total messages: 12
dave_cheney.net
Please take a look.
12 years, 1 month ago (2013-01-17 06:57:49 UTC) #1
dave_cheney.net
Please take a look.
12 years, 1 month ago (2013-01-17 07:04:34 UTC) #2
dave_cheney.net
On 2013/01/17 07:04:34, dfc wrote: > Please take a look. WIP followup proposal that introduces ...
12 years, 1 month ago (2013-01-17 07:15:08 UTC) #3
fwereade
A few comments; the large-scale concern is that I'm not sure we benefit by making ...
12 years, 1 month ago (2013-01-17 10:36:36 UTC) #4
dave_cheney.net
Thanks for your feedback William. Addressing your first comment "A few comments; the large-scale concern ...
12 years, 1 month ago (2013-01-17 10:50:20 UTC) #5
fwereade
On 2013/01/17 10:50:20, dfc wrote: > Thanks for your feedback William. Addressing your first comment ...
12 years, 1 month ago (2013-01-18 07:21:13 UTC) #6
fwereade
A couple more comments... https://codereview.appspot.com/7134051/diff/8001/worker/stater/export_test.go File worker/stater/export_test.go (right): https://codereview.appspot.com/7134051/diff/8001/worker/stater/export_test.go#newcode16 worker/stater/export_test.go:16: func (c *Config) MongoDataDirX() string ...
12 years, 1 month ago (2013-01-18 07:26:12 UTC) #7
dave_cheney.net
https://codereview.appspot.com/7134051/diff/8001/worker/stater/stater.go File worker/stater/stater.go (right): https://codereview.appspot.com/7134051/diff/8001/worker/stater/stater.go#newcode22 worker/stater/stater.go:22: // unpacked too On 2013/01/17 10:36:36, fwereade wrote: > ...
12 years, 1 month ago (2013-01-18 19:49:40 UTC) #8
dave_cheney.net
Please take a look.
12 years, 1 month ago (2013-01-18 19:50:36 UTC) #9
niemeyer
https://codereview.appspot.com/7134051/diff/17001/worker/stater/stater.go File worker/stater/stater.go (right): https://codereview.appspot.com/7134051/diff/17001/worker/stater/stater.go#newcode46 worker/stater/stater.go:46: tomb.Tomb This should not be an anonymous field, I ...
12 years, 1 month ago (2013-01-23 17:22:08 UTC) #10
dave_cheney.net
Please take a look. https://codereview.appspot.com/7134051/diff/17001/worker/stater/stater.go File worker/stater/stater.go (right): https://codereview.appspot.com/7134051/diff/17001/worker/stater/stater.go#newcode46 worker/stater/stater.go:46: tomb.Tomb On 2013/01/23 17:22:08, niemeyer ...
12 years, 1 month ago (2013-01-25 05:51:17 UTC) #11
rog
12 years, 1 month ago (2013-01-25 17:51:04 UTC) #12
great direction. some comments and queries below.

https://codereview.appspot.com/7134051/diff/20001/worker/stater/stater.go
File worker/stater/stater.go (right):

https://codereview.appspot.com/7134051/diff/20001/worker/stater/stater.go#new...
worker/stater/stater.go:27: defaultMongoDataDir = "/var/lib/juju/db"
rather than having all these default constants and special methods to return
them, why not just define:

var DefaultConfig = Config{
    MongoDir: "/opt",
    MongoDataDir: "/var/lib/juju/db",
    MongoURL: mustParseURL("http://juju-dist.s3.amazonaws.com/tools"),
}

?

https://codereview.appspot.com/7134051/diff/20001/worker/stater/stater.go#new...
worker/stater/stater.go:31: defaultPreallocSize = 1 << 20
s/defaultPreallocSize/preallocSize/

(it's not overridable, so "default" is a misnomer)

https://codereview.appspot.com/7134051/diff/20001/worker/stater/stater.go#new...
worker/stater/stater.go:43: // TODO(dfc) add support for watching the state
i don't think we'll need to watch the state here.

https://codereview.appspot.com/7134051/diff/20001/worker/stater/stater.go#new...
worker/stater/stater.go:58: func (sr *Stater) run() {
given the comment above, i'm not sure that structuring this as a worker makes
sense. the only thing that's continually running is mongod itself, and that's
managed by upstart.

i think perhaps we could just have two functions:

func Start(config *Config) error
func Stop(config *Config) error

each would be idempotent, so when the machiner is not running JobServeState (or
whatever that constant will be), it can call stater.Stop to ensure that the
state server is not running;
likewise it can call stater.Start to start it running (and maybe download the
mongo tar archive, install upstart script, etc).

https://codereview.appspot.com/7134051/diff/20001/worker/stater/stater.go#new...
worker/stater/stater.go:63: func (sr *Stater) Wait() error {
i think this can go, see above.

https://codereview.appspot.com/7134051/diff/20001/worker/stater/stater.go#new...
worker/stater/stater.go:69: // the lifetime of the agent.
this isn't an exported function, so this comment seems inappropriate here. the
only callers are in this package.

https://codereview.appspot.com/7134051/diff/20001/worker/stater/stater.go#new...
worker/stater/stater.go:110: log.Debugf("creating journal file: %v, size %d",
file, defaultPreallocSize)
i think we could probably do without the debug statements in this function.
creating files isn't that interesting. perhaps just one for the function, if you
think it's worth it.

https://codereview.appspot.com/7134051/diff/20001/worker/stater/stater.go#new...
worker/stater/stater.go:121: log.Printf("fetching mongo from: %v",
sr.config.mongoUrl())
s/://

https://codereview.appspot.com/7134051/diff/20001/worker/stater/stater.go#new...
worker/stater/stater.go:127: return nil, fmt.Errorf("fetch %q return status: %d
%v", sr.config.mongoUrl(), resp.StatusCode, resp.Status)
"cannot fetch %q: %s", sr.config.mongoUrl, resp.Status)

(i believe the status string includes the status code).

https://codereview.appspot.com/7134051/diff/20001/worker/stater/stater.go#new...
worker/stater/stater.go:133: // archive, using the base directory of
sr.config.mongoDir().
// unpack reads a gzipped tar archive from r
// and unpacks it into sr.config.MongoDir.
?

https://codereview.appspot.com/7134051/diff/20001/worker/stater/stater.go#new...
worker/stater/stater.go:148: return err
should we clean up the partially unpacked directory if this happens?

https://codereview.appspot.com/7134051/diff/20001/worker/stater/stater.go#new...
worker/stater/stater.go:170: return fmt.Errorf("cannot handle tar file with
type: %d", hdr.Typeflag)
"cannot handle tar file %q with type %d", hdr.Name, hdr.Typeflag)

?

https://codereview.appspot.com/7134051/diff/20001/worker/stater/stater.go#new...
worker/stater/stater.go:189: MongoUrl *url.URL
if we're only ever going to use it as a string (http.Get takes a string), why
not store it as a string?

also
s/Url/URL/

https://codereview.appspot.com/7134051/diff/20001/worker/stater/tools.go
File worker/stater/tools.go (right):

https://codereview.appspot.com/7134051/diff/20001/worker/stater/tools.go#newc...
worker/stater/tools.go:9: func createPreallocFile(name string, size int) error {
i'm not sure this function justifies its own file.

https://codereview.appspot.com/7134051/diff/20001/worker/stater/tools.go#newc...
worker/stater/tools.go:18: if _, err := f.Seek(int64(size)-1, 0); err != nil {
f.Truncate(int64(size)) ?
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b