Merge lp:~thumper/juju-core/apiserver-knows-logdir into lp:~go-bot/juju-core/trunk

Proposed by Tim Penhey
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 2564
Proposed branch: lp:~thumper/juju-core/apiserver-knows-logdir
Merge into: lp:~go-bot/juju-core/trunk
Prerequisite: lp:~thumper/juju-core/tailer-tweaks
Diff against target: 111 lines (+16/-5)
6 files modified
cmd/jujud/machine.go (+3/-1)
juju/testing/conn.go (+3/-0)
provider/dummy/environs.go (+2/-1)
state/apiserver/apiserver.go (+3/-1)
state/apiserver/login_test.go (+1/-1)
state/apiserver/server_test.go (+4/-1)
To merge this branch: bzr merge lp:~thumper/juju-core/apiserver-knows-logdir
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+214155@code.launchpad.net

Commit message

Have the apiserver know the logdir

The agent config now knows the logdir. In some places
the entire agent config is passed through, but in order
to keep the changes small(ish), we only pass through
the logdir (additionally).

This did require a few tweaks to tests, and in particular
the addition of LogDir to the base ConnSuite.

This logdir is used by the upcoming debug-log api.

https://codereview.appspot.com/84350043/

Description of the change

Have the apiserver know the logdir

The agent config now knows the logdir. In some places
the entire agent config is passed through, but in order
to keep the changes small(ish), we only pass through
the logdir (additionally).

This did require a few tweaks to tests, and in particular
the addition of LogDir to the base ConnSuite.

This logdir is used by the upcoming debug-log api.

https://codereview.appspot.com/84350043/

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :
Download full text (5.5 KiB)

Reviewers: mp+214155_code.launchpad.net,

Message:
Please take a look.

Description:
Have the apiserver know the logdir

The agent config now knows the logdir. In some places
the entire agent config is passed through, but in order
to keep the changes small(ish), we only pass through
the logdir (additionally).

This did require a few tweaks to tests, and in particular
the addition of LogDir to the base ConnSuite.

This logdir is used by the upcoming debug-log api.

https://code.launchpad.net/~thumper/juju-core/apiserver-knows-logdir/+merge/214155

Requires:
https://code.launchpad.net/~thumper/juju-core/tailer-tweaks/+merge/214150

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/84350043/

Affected files (+18, -5 lines):
   A [revision details]
   M cmd/jujud/machine.go
   M juju/testing/conn.go
   M provider/dummy/environs.go
   M state/apiserver/apiserver.go
   M state/apiserver/login_test.go
   M state/apiserver/server_test.go

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>

Index: cmd/jujud/machine.go
=== modified file 'cmd/jujud/machine.go'
--- cmd/jujud/machine.go 2014-04-02 12:52:25 +0000
+++ cmd/jujud/machine.go 2014-04-04 03:48:49 +0000
@@ -381,7 +381,9 @@
       return nil, &fatalError{"configuration does not have state server
cert/key"}
      }
      dataDir := agentConfig.DataDir()
- return apiserver.NewServer(st, fmt.Sprintf(":%d", port), cert, key,
dataDir)
+ logDir := agentConfig.LogDir()
+ return apiserver.NewServer(
+ st, fmt.Sprintf(":%d", port), cert, key, dataDir, logDir)
     })
     a.startWorkerAfterUpgrade(runner, "cleaner", func() (worker.Worker,
error) {
      return cleaner.NewCleaner(st), nil

Index: juju/testing/conn.go
=== modified file 'juju/testing/conn.go'
--- juju/testing/conn.go 2014-04-02 01:59:59 +0000
+++ juju/testing/conn.go 2014-04-04 03:48:49 +0000
@@ -60,6 +60,7 @@
   ConfigStore configstore.Storage
   BackingState *state.State // The State being used by the API server
   RootDir string // The faked-up root directory.
+ LogDir string
   oldHome string
   oldJujuHome string
   environ environs.Environ
@@ -211,6 +212,8 @@
   // sanity check we've got the correct environment.
   c.Assert(environ.Name(), gc.Equals, "dummyenv")
   s.PatchValue(&dummy.DataDir, s.DataDir())
+ s.LogDir = c.MkDir()
+ s.PatchValue(&dummy.LogDir, s.LogDir)

   versions := PreferredDefaultVersions(environ.Config(), version.Current)
   versions = append(versions, version.Current)

Index: provider/dummy/environs.go
=== modified file 'provider/dummy/environs.go'
--- provider/dummy/environs.go 2014-04-03 04:46:51 +0000
+++ provider/dummy/environs.go 2014-04-04 03:48:49 +0000
@@ -501,6 +501,7 @@

  // Override for testing - the data directory with which the state api
server is initialised.
  var DataDir = ""
+var LogDir = ""

  func (e *environ) ecfg() *environCo...

Read more...

Revision history for this message
Andrew Wilkins (axwalk) wrote :

On 2014/04/04 04:47:42, thumper wrote:
> Please take a look.

LGTM

https://codereview.appspot.com/84350043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cmd/jujud/machine.go'
2--- cmd/jujud/machine.go 2014-04-02 12:52:25 +0000
3+++ cmd/jujud/machine.go 2014-04-04 04:45:42 +0000
4@@ -381,7 +381,9 @@
5 return nil, &fatalError{"configuration does not have state server cert/key"}
6 }
7 dataDir := agentConfig.DataDir()
8- return apiserver.NewServer(st, fmt.Sprintf(":%d", port), cert, key, dataDir)
9+ logDir := agentConfig.LogDir()
10+ return apiserver.NewServer(
11+ st, fmt.Sprintf(":%d", port), cert, key, dataDir, logDir)
12 })
13 a.startWorkerAfterUpgrade(runner, "cleaner", func() (worker.Worker, error) {
14 return cleaner.NewCleaner(st), nil
15
16=== modified file 'juju/testing/conn.go'
17--- juju/testing/conn.go 2014-04-02 01:59:59 +0000
18+++ juju/testing/conn.go 2014-04-04 04:45:42 +0000
19@@ -60,6 +60,7 @@
20 ConfigStore configstore.Storage
21 BackingState *state.State // The State being used by the API server
22 RootDir string // The faked-up root directory.
23+ LogDir string
24 oldHome string
25 oldJujuHome string
26 environ environs.Environ
27@@ -211,6 +212,8 @@
28 // sanity check we've got the correct environment.
29 c.Assert(environ.Name(), gc.Equals, "dummyenv")
30 s.PatchValue(&dummy.DataDir, s.DataDir())
31+ s.LogDir = c.MkDir()
32+ s.PatchValue(&dummy.LogDir, s.LogDir)
33
34 versions := PreferredDefaultVersions(environ.Config(), version.Current)
35 versions = append(versions, version.Current)
36
37=== modified file 'provider/dummy/environs.go'
38--- provider/dummy/environs.go 2014-04-03 04:46:51 +0000
39+++ provider/dummy/environs.go 2014-04-04 04:45:42 +0000
40@@ -501,6 +501,7 @@
41
42 // Override for testing - the data directory with which the state api server is initialised.
43 var DataDir = ""
44+var LogDir = ""
45
46 func (e *environ) ecfg() *environConfig {
47 e.ecfgMutex.Lock()
48@@ -607,7 +608,7 @@
49 if err != nil {
50 panic(err)
51 }
52- estate.apiServer, err = apiserver.NewServer(st, "localhost:0", []byte(testing.ServerCert), []byte(testing.ServerKey), DataDir)
53+ estate.apiServer, err = apiserver.NewServer(st, "localhost:0", []byte(testing.ServerCert), []byte(testing.ServerKey), DataDir, LogDir)
54 if err != nil {
55 panic(err)
56 }
57
58=== modified file 'state/apiserver/apiserver.go'
59--- state/apiserver/apiserver.go 2014-03-13 22:47:05 +0000
60+++ state/apiserver/apiserver.go 2014-04-04 04:45:42 +0000
61@@ -30,12 +30,13 @@
62 state *state.State
63 addr net.Addr
64 dataDir string
65+ logDir string
66 }
67
68 // Serve serves the given state by accepting requests on the given
69 // listener, using the given certificate and key (in PEM format) for
70 // authentication.
71-func NewServer(s *state.State, addr string, cert, key []byte, datadir string) (*Server, error) {
72+func NewServer(s *state.State, addr string, cert, key []byte, datadir, logDir string) (*Server, error) {
73 lis, err := net.Listen("tcp", addr)
74 if err != nil {
75 return nil, err
76@@ -49,6 +50,7 @@
77 state: s,
78 addr: lis.Addr(),
79 dataDir: datadir,
80+ logDir: logDir,
81 }
82 // TODO(rog) check that *srvRoot is a valid type for using
83 // as an RPC server.
84
85=== modified file 'state/apiserver/login_test.go'
86--- state/apiserver/login_test.go 2014-04-01 23:56:19 +0000
87+++ state/apiserver/login_test.go 2014-04-04 04:45:42 +0000
88@@ -54,7 +54,7 @@
89 "localhost:0",
90 []byte(coretesting.ServerCert),
91 []byte(coretesting.ServerKey),
92- "",
93+ "", "",
94 )
95 c.Assert(err, gc.IsNil)
96 info := &api.Info{
97
98=== modified file 'state/apiserver/server_test.go'
99--- state/apiserver/server_test.go 2014-03-13 07:54:56 +0000
100+++ state/apiserver/server_test.go 2014-04-04 04:45:42 +0000
101@@ -36,7 +36,10 @@
102 func (s *serverSuite) TestStop(c *gc.C) {
103 // Start our own instance of the server so we have
104 // a handle on it to stop it.
105- srv, err := apiserver.NewServer(s.State, "localhost:0", []byte(coretesting.ServerCert), []byte(coretesting.ServerKey), "")
106+ srv, err := apiserver.NewServer(
107+ s.State, "localhost:0",
108+ []byte(coretesting.ServerCert), []byte(coretesting.ServerKey),
109+ "", "")
110 c.Assert(err, gc.IsNil)
111 defer srv.Stop()
112

Subscribers

People subscribed via source and target branches

to status/vote changes: