Merge lp:~natefinch/juju-core/042-sortaensure into lp:~go-bot/juju-core/trunk

Proposed by Nate Finch
Status: Merged
Merged at revision: 2620
Proposed branch: lp:~natefinch/juju-core/042-sortaensure
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 81 lines (+22/-11)
2 files modified
agent/mongo/mongo.go (+11/-2)
agent/mongo/mongo_test.go (+11/-9)
To merge this branch: bzr merge lp:~natefinch/juju-core/042-sortaensure
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+215504@code.launchpad.net

Description of the change

fix upgrade from 1.18 to 1.19

So, we can't start old mongo servers into replset mode just yet, which was causing the problem. So for now, we won't replace the old upstart scripts of existing servers.

https://codereview.appspot.com/86930046/

To post a comment you must log in.
Revision history for this message
Nate Finch (natefinch) wrote :
Download full text (3.6 KiB)

Reviewers: mp+215504_code.launchpad.net,

Message:
Please take a look.

Description:
fix upgrade from 1.18 to 1.19

So, we can't start old mongo servers into replset mode just yet, which
was causing the problem. So for now, we won't replace the old upstart
scripts of existing servers.

https://code.launchpad.net/~natefinch/juju-core/042-sortaensure/+merge/215504

(do not edit description out of merge proposal)

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

Affected files (+24, -11 lines):
   A [revision details]
   M agent/mongo/mongo.go
   M agent/mongo/mongo_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: tarmac-20140411112804-lhmoi3eyp2zaqx0g
+New revision: <email address hidden>

Index: agent/mongo/mongo.go
=== modified file 'agent/mongo/mongo.go'
--- agent/mongo/mongo.go 2014-04-10 09:58:05 +0000
+++ agent/mongo/mongo.go 2014-04-11 19:48:39 +0000
@@ -186,7 +186,6 @@
  // the local provider.
  func EnsureMongoServer(dataDir string, port int, namespace string) error {
   // NOTE: ensure that the right package is installed?
-
   logger.Infof("Ensuring mongo server is running; dataDir %s; port %d",
dataDir, port)
   dbDir := filepath.Join(dataDir, "db")

@@ -194,6 +193,12 @@
   if err != nil {
    return err
   }
+
+ // TODO(natefinch): remove this once we support upgrading to HA
+ if service.Installed() {
+ return nil
+ }
+
   if err := makeJournalDirs(dbDir); err != nil {
    return fmt.Errorf("Error creating journal directories: %v", err)
   }
@@ -222,7 +227,11 @@
   for x := 0; x < 3; x++ {
    name := fmt.Sprintf("prealloc.%d", x)
    filename := filepath.Join(journalDir, name)
- f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0700)
+ f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0700)
+ if os.IsExist(err) {
+ // already exists, don't overwrite
+ continue
+ }
    if err != nil {
     return fmt.Errorf("failed to open mongo prealloc file %q: %v",
filename, err)
    }

Index: agent/mongo/mongo_test.go
=== modified file 'agent/mongo/mongo_test.go'
--- agent/mongo/mongo_test.go 2014-04-08 15:04:46 +0000
+++ agent/mongo/mongo_test.go 2014-04-11 19:48:39 +0000
@@ -81,19 +81,19 @@
  func testJournalDirs(dir string, c *gc.C) {
   journalDir := path.Join(dir, "journal")

- c.Check(journalDir, jc.IsDirectory)
+ c.Assert(journalDir, jc.IsDirectory)
   info, err := os.Stat(filepath.Join(journalDir, "prealloc.0"))
- c.Check(err, gc.IsNil)
+ c.Assert(err, gc.IsNil)

   size := int64(1024 * 1024)

- c.Check(info.Size(), gc.Equals, size)
+ c.Assert(info.Size(), gc.Equals, size)
   info, err = os.Stat(filepath.Join(journalDir, "prealloc.1"))
- c.Check(err, gc.IsNil)
- c.Check(info.Size(), gc.Equals, size)
+ c.Assert(err, gc.IsNil)
+ c.Assert(info.Size(), gc.Equals, size)
   info, err = os.Stat(filepath.Join(journalDir, "prealloc.2"))
- c.Check(err, gc.IsNil)
- c.Check(info.Size(), gc.Equals, size)
+ c.Assert(err, gc.IsNil)
+ c.Assert(info.Size(), gc.Equals, size)
  }

  func (s *MongoSuite) TestEn...

Read more...

Revision history for this message
Ian Booth (wallyworld) wrote :

LGTM with another TODO added

https://codereview.appspot.com/86930046/diff/1/agent/mongo/mongo.go
File agent/mongo/mongo.go (right):

https://codereview.appspot.com/86930046/diff/1/agent/mongo/mongo.go#newcode231
agent/mongo/mongo.go:231: if os.IsExist(err) {
Can we add a TODO here as well please since I think this exists check is
only temporary.

https://codereview.appspot.com/86930046/

Revision history for this message
John A Meinel (jameinel) wrote :

Just to be clear, the "We can't upgrade" is because we have to do the
mongo-single-user song-and-dance to get API servers admin rights to be
able to configure the replica set details, is that correct?

If so, LGTM

https://codereview.appspot.com/86930046/

Revision history for this message
Roger Peppe (rogpeppe) wrote :

Yes
On 12 Apr 2014 06:31, "John A Meinel" <email address hidden> wrote:

> Just to be clear, the "We can't upgrade" is because we have to do the
> mongo-single-user song-and-dance to get API servers admin rights to be
> able to configure the replica set details, is that correct?
>
> If so, LGTM
>
> https://codereview.appspot.com/86930046/
>
> --
>
> https://code.launchpad.net/~natefinch/juju-core/042-sortaensure/+merge/215504
> Your team juju hackers is requested to review the proposed merge of
> lp:~natefinch/juju-core/042-sortaensure into lp:juju-core.
>

Revision history for this message
John A Meinel (jameinel) wrote :

I went ahead and added a TODO comment, and linked it to a Launchpad bug.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'agent/mongo/mongo.go'
2--- agent/mongo/mongo.go 2014-04-10 09:58:05 +0000
3+++ agent/mongo/mongo.go 2014-04-11 20:52:24 +0000
4@@ -186,7 +186,6 @@
5 // the local provider.
6 func EnsureMongoServer(dataDir string, port int, namespace string) error {
7 // NOTE: ensure that the right package is installed?
8-
9 logger.Infof("Ensuring mongo server is running; dataDir %s; port %d", dataDir, port)
10 dbDir := filepath.Join(dataDir, "db")
11
12@@ -194,6 +193,12 @@
13 if err != nil {
14 return err
15 }
16+
17+ // TODO(natefinch): remove this once we support upgrading to HA
18+ if service.Installed() {
19+ return nil
20+ }
21+
22 if err := makeJournalDirs(dbDir); err != nil {
23 return fmt.Errorf("Error creating journal directories: %v", err)
24 }
25@@ -222,7 +227,11 @@
26 for x := 0; x < 3; x++ {
27 name := fmt.Sprintf("prealloc.%d", x)
28 filename := filepath.Join(journalDir, name)
29- f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0700)
30+ f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0700)
31+ if os.IsExist(err) {
32+ // already exists, don't overwrite
33+ continue
34+ }
35 if err != nil {
36 return fmt.Errorf("failed to open mongo prealloc file %q: %v", filename, err)
37 }
38
39=== modified file 'agent/mongo/mongo_test.go'
40--- agent/mongo/mongo_test.go 2014-04-08 15:04:46 +0000
41+++ agent/mongo/mongo_test.go 2014-04-11 20:52:24 +0000
42@@ -81,19 +81,19 @@
43 func testJournalDirs(dir string, c *gc.C) {
44 journalDir := path.Join(dir, "journal")
45
46- c.Check(journalDir, jc.IsDirectory)
47+ c.Assert(journalDir, jc.IsDirectory)
48 info, err := os.Stat(filepath.Join(journalDir, "prealloc.0"))
49- c.Check(err, gc.IsNil)
50+ c.Assert(err, gc.IsNil)
51
52 size := int64(1024 * 1024)
53
54- c.Check(info.Size(), gc.Equals, size)
55+ c.Assert(info.Size(), gc.Equals, size)
56 info, err = os.Stat(filepath.Join(journalDir, "prealloc.1"))
57- c.Check(err, gc.IsNil)
58- c.Check(info.Size(), gc.Equals, size)
59+ c.Assert(err, gc.IsNil)
60+ c.Assert(info.Size(), gc.Equals, size)
61 info, err = os.Stat(filepath.Join(journalDir, "prealloc.2"))
62- c.Check(err, gc.IsNil)
63- c.Check(info.Size(), gc.Equals, size)
64+ c.Assert(err, gc.IsNil)
65+ c.Assert(info.Size(), gc.Equals, size)
66 }
67
68 func (s *MongoSuite) TestEnsureMongoServer(c *gc.C) {
69@@ -101,8 +101,10 @@
70 dbDir := filepath.Join(dir, "db")
71 port := 25252
72 namespace := "namespace"
73- oldsvc := makeService(ServiceName(namespace), c)
74- defer oldsvc.StopAndRemove()
75+
76+ // TODO(natefinch): uncomment when we support upgrading to HA
77+ //oldsvc := makeService(ServiceName(namespace), c)
78+ //defer oldsvc.StopAndRemove()
79
80 err := EnsureMongoServer(dir, port, namespace)
81 c.Assert(err, gc.IsNil)

Subscribers

People subscribed via source and target branches

to status/vote changes: