Merge lp:~thumper/juju-core/upstart-retry-start-on-install 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: | 1918 |
Proposed branch: | lp:~thumper/juju-core/upstart-retry-start-on-install |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
81 lines (+22/-8) 2 files modified
upstart/upstart.go (+16/-1) upstart/upstart_test.go (+6/-7) |
To merge this branch: | bzr merge lp:~thumper/juju-core/upstart-retry-start-on-install |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email:
|
Commit message
Use a retry strategy to start new services.
On slower disks, upstart doesn't necessarily notice
the file straight away. Use a retry strategy to
start the newly written upstart file.
The first attempt happens straight away, so no slow
down on faster systems.
Description of the change
Use a retry strategy to start new services.
On slower disks, upstart doesn't necessarily notice
the file straight away. Use a retry strategy to
start the newly written upstart file.
The first attempt happens straight away, so no slow
down on faster systems.
To post a comment you must log in.
Reviewers: mp+188761_ code.launchpad. net,
Message:
Please take a look.
Description:
Use a retry strategy to start new services.
On slower disks, upstart doesn't necessarily notice
the file straight away. Use a retry strategy to
start the newly written upstart file.
The first attempt happens straight away, so no slow
down on faster systems.
https:/ /code.launchpad .net/~thumper/ juju-core/ upstart- retry-start- on-install/ +merge/ 188761
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/14260043/
Affected files (+24, -8 lines): upstart_ test.go
A [revision details]
M upstart/upstart.go
M upstart/
Index: [revision details] 20131002011707- z9ofwwxn0ra5xh9 t
=== 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-
+New revision: <email address hidden>
Index: upstart/upstart.go upstart. go' net/juju- core/utils"
=== modified file 'upstart/
--- upstart/upstart.go 2013-10-01 21:09:59 +0000
+++ upstart/upstart.go 2013-10-02 03:44:40 +0000
@@ -13,10 +13,18 @@
"path"
"regexp"
"text/template"
+ "time"
+
+ "launchpad.
)
var startedRE = regexp. MustCompile( `^.* start/running, process (\d+)\n$`)
+var InstallStartRet ryAttempts = utils.AttemptSt rategy{ WriteFile( c.confPath( ), conf, 0644); err != nil { ryAttempts. Start() ; attempt.Next(); {
+ Total: 1 * time.Second,
+ Delay: 250 * time.Millisecond,
+}
+
// Service provides visibility into and control over an upstart service.
type Service struct {
Name string
@@ -181,7 +189,14 @@
if err := ioutil.
return err
}
- return c.Start()
+ // On slower disks, upstart may take a short time to realise
+ // that there is a service there.
+ for attempt := InstallStartRet
+ if err = c.Start(); err == nil {
+ break
+ }
+ }
+ return err
}
// InstallCommands returns shell commands to install and start the service.
Index: upstart/ upstart_ test.go upstart_ test.go' upstart_ test.go 2013-10-02 00:16:23 +0000 upstart_ test.go 2013-10-02 03:44:40 +0000 net/gocheck"
=== modified file 'upstart/
--- upstart/
+++ upstart/
@@ -13,13 +13,15 @@
gc "launchpad.
jc "launchpad. net/juju- core/testing/ checkers" net/juju- core/testing/ testbase" net/juju- core/upstart" net/juju- core/utils"
+ "launchpad.
"launchpad.
+ "launchpad.
)
func Test(t *testing.T) { gc.TestingT(t) }
type UpstartSuite struct { LoggingSuite &UpstartSuite{ })
- origPath string
+ testbase.
testPath string
service *upstart.Service
}
@@ -27,18 +29,15 @@
var _ = gc.Suite(
func (s *UpstartSuite) SetUpTest(c *gc.C) { ":"+s.origPath) ent("PATH" , s.testPath+ ":"+origPath) &upstart. InstallStartRet ryAttempts, utils.AttemptSt rategy{ }) Service{ Name: "some-service", InitDir: c.MkDir()} filepath. Join(s. service. InitDir, "some-service. conf"))
- s.origPath = os.Getenv("PATH")
+ origPath := os.Getenv("PATH")
s.testPath = c.MkDir()
- os.Setenv("PATH", s.testPath+
+ s.PatchEnvironm
+ s.PatchValue(
s.service = &upstart.
_, err := os.Create(
c.Assert(err, gc.IsNil)
}
-func (s *UpstartSuite) TearDownTest(c *gc.C) {
- os.Setenv("PATH...