Merge lp:~dimitern/juju-core/270-lp-1257649-ssh-timeout-bootstrap into lp:~go-bot/juju-core/trunk

Proposed by Dimiter Naydenov
Status: Merged
Approved by: Dimiter Naydenov
Approved revision: no longer in the source branch.
Merged at revision: 2282
Proposed branch: lp:~dimitern/juju-core/270-lp-1257649-ssh-timeout-bootstrap
Merge into: lp:~go-bot/juju-core/trunk
Prerequisite: lp:~dimitern/juju-core/260-lp-1067979-duplicate-charm
Diff against target: 401 lines (+187/-54)
5 files modified
cmd/juju/bootstrap.go (+10/-1)
environs/config/config.go (+78/-15)
environs/config/config_test.go (+86/-3)
provider/common/bootstrap.go (+11/-33)
provider/common/bootstrap_test.go (+2/-2)
To merge this branch: bzr merge lp:~dimitern/juju-core/270-lp-1257649-ssh-timeout-bootstrap
Reviewer Review Type Date Requested Status
Dimiter Naydenov (community) Approve
Review via email: mp+203832@code.launchpad.net

Commit message

bootstrap: Added configurable timeout and delays

Fixed bug #1257649: ssh timeout for bootstrap
could be configurable, by adding 3 new config
settings:
- bootstrap-timeout (default: 600s = 10m)
- bootstrap-retry-delay (default: 5s)
- bootstrap-addresses-delay (default: 10s)

All of them are integers, measured in seconds,
and also all of them are optional and have the
specified defaults.

Updated the bootstrap command's help text to
include the new config settings.

https://codereview.appspot.com/58170045/

R=natefinch

Description of the change

bootstrap: Added configurable timeout and delays

Fixed bug #1257649: ssh timeout for bootstrap
could be configurable, by adding 3 new config
settings:
- bootstrap-timeout (default: 600s = 10m)
- bootstrap-retry-delay (default: 5s)
- bootstrap-addresses-delay (default: 10s)

All of them are integers, measured in seconds,
and also all of them are optional and have the
specified defaults.

Updated the bootstrap command's help text to
include the new config settings.

https://codereview.appspot.com/58170045/

To post a comment you must log in.
Revision history for this message
Dimiter Naydenov (dimitern) wrote :

Reviewers: mp+203832_code.launchpad.net,

Message:
Please take a look.

Description:
bootstrap: Added configurable timeout and delays

Fixed bug #1257649: ssh timeout for bootstrap
could be configurable, by adding 3 new config
settings:
- bootstrap-ssh-timeout (default: 600s = 10m)
- bootstrap-ssh-retry-delay (default: 5s)
- bootstrap-ssh-addresses-delay (default: 10s)

All of them are integers, measured in seconds,
and also all of them are optional and have the
specified defaults.

Updated the bootstrap command's help text to
include the new config settings.

https://code.launchpad.net/~dimitern/juju-core/270-lp-1257649-ssh-timeout-bootstrap/+merge/203832

Requires:
https://code.launchpad.net/~dimitern/juju-core/260-lp-1067979-duplicate-charm/+merge/203291

(do not edit description out of merge proposal)

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

Affected files (+236, -101 lines):
   A [revision details]
   M cmd/juju/bootstrap.go
   M environs/config/config.go
   M environs/config/config_test.go
   M provider/common/bootstrap.go

Revision history for this message
Nate Finch (natefinch) wrote :

Please remove all user-facing mentions of SSH, since that's an internal
detail and something that would just confuse users. This is just a
bootstrap timeout to an end user, even if it does use SSH behind the
scenes.

https://codereview.appspot.com/58170045/diff/1/cmd/juju/bootstrap.go
File cmd/juju/bootstrap.go (right):

https://codereview.appspot.com/58170045/diff/1/cmd/juju/bootstrap.go#newcode48
cmd/juju/bootstrap.go:48: bootstrap-ssh-timeout: 600 # default: 10
minutes
ssh is an internal detail that will just be confusing to users. This is
just the "bootstrap-timeout" to an end user.
  Same goes for retry delay and addresses delay.

https://codereview.appspot.com/58170045/

Revision history for this message
Nate Finch (natefinch) wrote :

Oh yeah, otherwise LGTM :)

https://codereview.appspot.com/58170045/

Revision history for this message
Dimiter Naydenov (dimitern) wrote :
Revision history for this message
Go Bot (go-bot) wrote :
Revision history for this message
Dimiter Naydenov (dimitern) wrote :
Revision history for this message
Dimiter Naydenov (dimitern) wrote :

Self-approving after fixing merge conflicts.

review: Approve
Revision history for this message
Go Bot (go-bot) wrote :
Download full text (9.0 KiB)

The attempt to merge lp:~dimitern/juju-core/270-lp-1257649-ssh-timeout-bootstrap into lp:juju-core failed. Below is the output from the failed tests.

ok launchpad.net/juju-core/agent 1.242s
ok launchpad.net/juju-core/agent/tools 0.247s
ok launchpad.net/juju-core/bzr 7.292s
ok launchpad.net/juju-core/cert 3.276s
ok launchpad.net/juju-core/charm 0.675s
? launchpad.net/juju-core/charm/hooks [no test files]
? launchpad.net/juju-core/charm/testing [no test files]
ok launchpad.net/juju-core/cloudinit 0.033s
ok launchpad.net/juju-core/cloudinit/sshinit 1.206s
ok launchpad.net/juju-core/cmd 0.228s
ok launchpad.net/juju-core/cmd/charm-admin 0.839s
? launchpad.net/juju-core/cmd/charmd [no test files]
? launchpad.net/juju-core/cmd/charmload [no test files]
ok launchpad.net/juju-core/cmd/juju 253.798s
ok launchpad.net/juju-core/cmd/jujud 67.489s
ok launchpad.net/juju-core/cmd/plugins/juju-metadata 13.106s
? launchpad.net/juju-core/cmd/plugins/juju-restore [no test files]
ok launchpad.net/juju-core/constraints 0.028s
ok launchpad.net/juju-core/container 0.047s
ok launchpad.net/juju-core/container/factory 0.054s
ok launchpad.net/juju-core/container/kvm 0.299s
ok launchpad.net/juju-core/container/kvm/mock 0.064s
? launchpad.net/juju-core/container/kvm/testing [no test files]
ok launchpad.net/juju-core/container/lxc 0.368s
? launchpad.net/juju-core/container/lxc/mock [no test files]
? launchpad.net/juju-core/container/lxc/testing [no test files]
? launchpad.net/juju-core/container/testing [no test files]
ok launchpad.net/juju-core/downloader 5.289s
ok launchpad.net/juju-core/environs 3.146s
ok launchpad.net/juju-core/environs/bootstrap 4.543s
ok launchpad.net/juju-core/environs/cloudinit 0.614s
ok launchpad.net/juju-core/environs/config 2.040s
ok launchpad.net/juju-core/environs/configstore 0.041s
ok launchpad.net/juju-core/environs/filestorage 0.033s
ok launchpad.net/juju-core/environs/httpstorage 0.976s
ok launchpad.net/juju-core/environs/imagemetadata 0.658s
? launchpad.net/juju-core/environs/imagemetadata/testing [no test files]
ok launchpad.net/juju-core/environs/instances 0.062s
ok launchpad.net/juju-core/environs/jujutest 0.219s
ok launchpad.net/juju-core/environs/manual 9.762s
ok launchpad.net/juju-core/environs/simplestreams 0.331s
? launchpad.net/juju-core/environs/simplestreams/testing [no test files]
ok launchpad.net/juju-core/environs/sshstorage 1.488s
ok launchpad.net/juju-core/environs/storage 1.212s
ok launchpad.net/juju-core/environs/sync 37.095s
ok launchpad.net/juju-core/environs/testing 0.212s
ok launchpad.net/juju-core/environs/tools 6.858s
? launchpad.net/juju-core/environs/tools/testing [no test files]
ok launchpad.net/juju-core/errors 0.017s
ok launchpad.net/juju-core/instance 0.027s
? launchpad.net/juju-core/instance/testing [no test files]
ok launchpad.net/juju-core/juju 25.189s
ok launchpad.net/juju-core/juju/osenv 0.021s
? launchpad.net/juju-core/juju/testing [no test files]
ok launchpad.net/juju-core/log 0.027s
ok launchpad.net/juju-core/log/syslog 0.023s
ok launchpad.net/juju-core/names 0.030s
? lau...

Read more...

Revision history for this message
Dimiter Naydenov (dimitern) wrote :
Revision history for this message
Dimiter Naydenov (dimitern) wrote :

Self-approving after fixing a test.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'cmd/juju/bootstrap.go'
--- cmd/juju/bootstrap.go 2014-01-30 06:21:03 +0000
+++ cmd/juju/bootstrap.go 2014-01-30 17:28:09 +0000
@@ -42,7 +42,16 @@
42Bootstrap initializes the cloud environment synchronously and displays information42Bootstrap initializes the cloud environment synchronously and displays information
43about the current installation steps. The time for bootstrap to complete varies 43about the current installation steps. The time for bootstrap to complete varies
44across cloud providers from a few seconds to several minutes. Once bootstrap has 44across cloud providers from a few seconds to several minutes. Once bootstrap has
45completed, you can run other juju commands against your environment.45completed, you can run other juju commands against your environment. You can change
46the default timeout and retry delays used during the bootstrap by changing the
47following settings in your environments.yaml (all values represent number of seconds):
48
49 # How long to wait for a connection to the state server.
50 bootstrap-timeout: 600 # default: 10 minutes
51 # How long to wait between connection attempts to a state server address.
52 bootstrap-retry-delay: 5 # default: 5 seconds
53 # How often to refresh state server addresses from the API server.
54 bootstrap-addresses-delay: 10 # default: 10 seconds
4655
47Private clouds may need to specify their own custom image metadata, and possibly upload56Private clouds may need to specify their own custom image metadata, and possibly upload
48Juju tools to cloud storage if no outgoing Internet access is available. In this case,57Juju tools to cloud storage if no outgoing Internet access is available. In this case,
4958
=== modified file 'environs/config/config.go'
--- environs/config/config.go 2014-01-29 09:58:08 +0000
+++ environs/config/config.go 2014-01-30 17:28:09 +0000
@@ -45,6 +45,19 @@
45 // DefaultSyslogPort is the default port that the syslog UDP listener is45 // DefaultSyslogPort is the default port that the syslog UDP listener is
46 // listening on.46 // listening on.
47 DefaultSyslogPort int = 51447 DefaultSyslogPort int = 514
48
49 // DefaultBootstrapSSHTimeout is the amount of time to wait
50 // contacting a state server, in seconds.
51 DefaultBootstrapSSHTimeout int = 600
52
53 // DefaultBootstrapSSHRetryDelay is the amount of time between
54 // attempts to connect to an address, in seconds.
55 DefaultBootstrapSSHRetryDelay int = 5
56
57 // DefaultBootstrapSSHAddressesDelay is the amount of time between
58 // refreshing the addresses, in seconds. Not too frequent, as we
59 // refresh addresses from the provider each time.
60 DefaultBootstrapSSHAddressesDelay int = 10
48)61)
4962
50// Config holds an immutable environment configuration.63// Config holds an immutable environment configuration.
@@ -473,6 +486,26 @@
473 return c.getWithFallback("apt-ftp-proxy", "ftp-proxy")486 return c.getWithFallback("apt-ftp-proxy", "ftp-proxy")
474}487}
475488
489// BootstrapSSHOpts returns the SSH timeout and retry delays used
490// during bootstrap.
491func (c *Config) BootstrapSSHOpts() SSHTimeoutOpts {
492 opts := SSHTimeoutOpts{
493 Timeout: time.Duration(DefaultBootstrapSSHTimeout) * time.Second,
494 RetryDelay: time.Duration(DefaultBootstrapSSHRetryDelay) * time.Second,
495 AddressesDelay: time.Duration(DefaultBootstrapSSHAddressesDelay) * time.Second,
496 }
497 if v, ok := c.m["bootstrap-timeout"].(int); ok && v != 0 {
498 opts.Timeout = time.Duration(v) * time.Second
499 }
500 if v, ok := c.m["bootstrap-retry-delay"].(int); ok && v != 0 {
501 opts.RetryDelay = time.Duration(v) * time.Second
502 }
503 if v, ok := c.m["bootstrap-addresses-delay"].(int); ok && v != 0 {
504 opts.AddressesDelay = time.Duration(v) * time.Second
505 }
506 return opts
507}
508
476// CACert returns the certificate of the CA that signed the state server509// CACert returns the certificate of the CA that signed the state server
477// certificate, in PEM format, and whether the setting is available.510// certificate, in PEM format, and whether the setting is available.
478func (c *Config) CACert() ([]byte, bool) {511func (c *Config) CACert() ([]byte, bool) {
@@ -639,6 +672,9 @@
639 "apt-http-proxy": schema.String(),672 "apt-http-proxy": schema.String(),
640 "apt-https-proxy": schema.String(),673 "apt-https-proxy": schema.String(),
641 "apt-ftp-proxy": schema.String(),674 "apt-ftp-proxy": schema.String(),
675 "bootstrap-timeout": schema.ForceInt(),
676 "bootstrap-retry-delay": schema.ForceInt(),
677 "bootstrap-addresses-delay": schema.ForceInt(),
642678
643 // Deprecated fields, retain for backwards compatibility.679 // Deprecated fields, retain for backwards compatibility.
644 "tools-url": schema.String(),680 "tools-url": schema.String(),
@@ -653,21 +689,24 @@
653// but some fields listed as optional here are actually mandatory689// but some fields listed as optional here are actually mandatory
654// with NoDefaults and are checked at the later Validate stage.690// with NoDefaults and are checked at the later Validate stage.
655var alwaysOptional = schema.Defaults{691var alwaysOptional = schema.Defaults{
656 "agent-version": schema.Omit,692 "agent-version": schema.Omit,
657 "ca-cert": schema.Omit,693 "ca-cert": schema.Omit,
658 "authorized-keys": schema.Omit,694 "authorized-keys": schema.Omit,
659 "authorized-keys-path": schema.Omit,695 "authorized-keys-path": schema.Omit,
660 "ca-cert-path": schema.Omit,696 "ca-cert-path": schema.Omit,
661 "ca-private-key-path": schema.Omit,697 "ca-private-key-path": schema.Omit,
662 "logging-config": schema.Omit,698 "logging-config": schema.Omit,
663 "provisioner-safe-mode": schema.Omit,699 "provisioner-safe-mode": schema.Omit,
664 "http-proxy": schema.Omit,700 "http-proxy": schema.Omit,
665 "https-proxy": schema.Omit,701 "https-proxy": schema.Omit,
666 "ftp-proxy": schema.Omit,702 "ftp-proxy": schema.Omit,
667 "apt-http-proxy": schema.Omit,703 "apt-http-proxy": schema.Omit,
668 "apt-https-proxy": schema.Omit,704 "apt-https-proxy": schema.Omit,
669 "apt-ftp-proxy": schema.Omit,705 "apt-ftp-proxy": schema.Omit,
670 "image-stream": schema.Omit,706 "image-stream": schema.Omit,
707 "bootstrap-timeout": schema.Omit,
708 "bootstrap-retry-delay": schema.Omit,
709 "bootstrap-addresses-delay": schema.Omit,
671710
672 // Deprecated fields, retain for backwards compatibility.711 // Deprecated fields, retain for backwards compatibility.
673 "tools-url": "",712 "tools-url": "",
@@ -706,6 +745,9 @@
706 "state-port": DefaultStatePort,745 "state-port": DefaultStatePort,
707 "api-port": DefaultAPIPort,746 "api-port": DefaultAPIPort,
708 "syslog-port": DefaultSyslogPort,747 "syslog-port": DefaultSyslogPort,
748 "bootstrap-timeout": DefaultBootstrapSSHTimeout,
749 "bootstrap-retry-delay": DefaultBootstrapSSHRetryDelay,
750 "bootstrap-addresses-delay": DefaultBootstrapSSHAddressesDelay,
709 }751 }
710 for attr, val := range alwaysOptional {752 for attr, val := range alwaysOptional {
711 d[attr] = val753 d[attr] = val
@@ -739,6 +781,9 @@
739 "state-port",781 "state-port",
740 "api-port",782 "api-port",
741 "syslog-port",783 "syslog-port",
784 "bootstrap-timeout",
785 "bootstrap-retry-delay",
786 "bootstrap-addresses-delay",
742}787}
743788
744var (789var (
@@ -802,6 +847,24 @@
802 return repo847 return repo
803}848}
804849
850// SSHTimeoutOpts lists the amount of time we will wait for various
851// parts of the SSH connection to complete. This is similar to
852// DialOpts, see http://pad.lv/1258889 about possibly deduplicating
853// them.
854type SSHTimeoutOpts struct {
855 // Timeout is the amount of time to wait contacting a state
856 // server.
857 Timeout time.Duration
858
859 // RetryDelay is the amount of time between attempts to connect to
860 // an address.
861 RetryDelay time.Duration
862
863 // AddressesDelay is the amount of time between refreshing the
864 // addresses.
865 AddressesDelay time.Duration
866}
867
805// ProxyConfigMap returns a map suitable to be applied to a Config to update868// ProxyConfigMap returns a map suitable to be applied to a Config to update
806// proxy settings.869// proxy settings.
807func ProxyConfigMap(proxy osenv.ProxySettings) map[string]interface{} {870func ProxyConfigMap(proxy osenv.ProxySettings) map[string]interface{} {
808871
=== modified file 'environs/config/config_test.go'
--- environs/config/config_test.go 2014-01-29 09:58:08 +0000
+++ environs/config/config_test.go 2014-01-30 17:28:09 +0000
@@ -513,6 +513,57 @@
513 },513 },
514 err: `syslog-port: expected number, got string\("illegal"\)`,514 err: `syslog-port: expected number, got string\("illegal"\)`,
515 }, {515 }, {
516 about: "Explicit bootstrap timeout",
517 useDefaults: config.UseDefaults,
518 attrs: testing.Attrs{
519 "type": "my-type",
520 "name": "my-name",
521 "bootstrap-timeout": 300,
522 },
523 }, {
524 about: "Invalid bootstrap timeout",
525 useDefaults: config.UseDefaults,
526 attrs: testing.Attrs{
527 "type": "my-type",
528 "name": "my-name",
529 "bootstrap-timeout": "illegal",
530 },
531 err: `bootstrap-timeout: expected number, got string\("illegal"\)`,
532 }, {
533 about: "Explicit bootstrap retry delay",
534 useDefaults: config.UseDefaults,
535 attrs: testing.Attrs{
536 "type": "my-type",
537 "name": "my-name",
538 "bootstrap-retry-delay": 5,
539 },
540 }, {
541 about: "Invalid bootstrap retry delay",
542 useDefaults: config.UseDefaults,
543 attrs: testing.Attrs{
544 "type": "my-type",
545 "name": "my-name",
546 "bootstrap-retry-delay": "illegal",
547 },
548 err: `bootstrap-retry-delay: expected number, got string\("illegal"\)`,
549 }, {
550 about: "Explicit bootstrap addresses delay",
551 useDefaults: config.UseDefaults,
552 attrs: testing.Attrs{
553 "type": "my-type",
554 "name": "my-name",
555 "bootstrap-addresses-delay": 15,
556 },
557 }, {
558 about: "Invalid bootstrap addresses delay",
559 useDefaults: config.UseDefaults,
560 attrs: testing.Attrs{
561 "type": "my-type",
562 "name": "my-name",
563 "bootstrap-addresses-delay": "illegal",
564 },
565 err: `bootstrap-addresses-delay: expected number, got string\("illegal"\)`,
566 }, {
516 about: "Invalid logging configuration",567 about: "Invalid logging configuration",
517 useDefaults: config.UseDefaults,568 useDefaults: config.UseDefaults,
518 attrs: testing.Attrs{569 attrs: testing.Attrs{
@@ -854,6 +905,25 @@
854 } else {905 } else {
855 c.Assert(cfg.ProvisionerSafeMode(), gc.Equals, false)906 c.Assert(cfg.ProvisionerSafeMode(), gc.Equals, false)
856 }907 }
908 sshOpts := cfg.BootstrapSSHOpts()
909 test.assertDuration(
910 c,
911 "bootstrap-timeout",
912 sshOpts.Timeout,
913 config.DefaultBootstrapSSHTimeout,
914 )
915 test.assertDuration(
916 c,
917 "bootstrap-retry-delay",
918 sshOpts.RetryDelay,
919 config.DefaultBootstrapSSHRetryDelay,
920 )
921 test.assertDuration(
922 c,
923 "bootstrap-addresses-delay",
924 sshOpts.AddressesDelay,
925 config.DefaultBootstrapSSHAddressesDelay,
926 )
857927
858 if v, ok := test.attrs["image-stream"]; ok {928 if v, ok := test.attrs["image-stream"]; ok {
859 c.Assert(cfg.ImageStream(), gc.Equals, v)929 c.Assert(cfg.ImageStream(), gc.Equals, v)
@@ -888,6 +958,15 @@
888 }958 }
889}959}
890960
961func (test configTest) assertDuration(c *gc.C, name string, actual time.Duration, defaultInSeconds int) {
962 value, ok := test.attrs[name].(int)
963 if !ok || value == 0 {
964 c.Assert(actual, gc.Equals, time.Duration(defaultInSeconds)*time.Second)
965 } else {
966 c.Assert(actual, gc.Equals, time.Duration(value)*time.Second)
967 }
968}
969
891func (s *ConfigSuite) TestConfigAttrs(c *gc.C) {970func (s *ConfigSuite) TestConfigAttrs(c *gc.C) {
892 // Normally this is handled by testing.FakeHome971 // Normally this is handled by testing.FakeHome
893 s.PatchEnvironment(osenv.JujuLoggingConfigEnvKey, "")972 s.PatchEnvironment(osenv.JujuLoggingConfigEnvKey, "")
@@ -905,6 +984,9 @@
905 "state-port": 1234,984 "state-port": 1234,
906 "api-port": 4321,985 "api-port": 4321,
907 "syslog-port": 2345,986 "syslog-port": 2345,
987 "bootstrap-timeout": 3600,
988 "bootstrap-retry-delay": 30,
989 "bootstrap-addresses-delay": 10,
908 "default-series": "precise",990 "default-series": "precise",
909 "charm-store-auth": "token=auth",991 "charm-store-auth": "token=auth",
910 }992 }
@@ -921,17 +1003,18 @@
921 attrs["tools-url"] = ""1003 attrs["tools-url"] = ""
922 // Default firewall mode is instance1004 // Default firewall mode is instance
923 attrs["firewall-mode"] = string(config.FwInstance)1005 attrs["firewall-mode"] = string(config.FwInstance)
924 c.Assert(cfg.AllAttrs(), gc.DeepEquals, attrs)1006 c.Assert(cfg.AllAttrs(), jc.DeepEquals, attrs)
925 c.Assert(cfg.UnknownAttrs(), gc.DeepEquals, map[string]interface{}{"unknown": "my-unknown"})1007 c.Assert(cfg.UnknownAttrs(), jc.DeepEquals, map[string]interface{}{"unknown": "my-unknown"})
9261008
927 newcfg, err := cfg.Apply(map[string]interface{}{1009 newcfg, err := cfg.Apply(map[string]interface{}{
928 "name": "new-name",1010 "name": "new-name",
929 "new-unknown": "my-new-unknown",1011 "new-unknown": "my-new-unknown",
930 })1012 })
1013 c.Assert(err, gc.IsNil)
9311014
932 attrs["name"] = "new-name"1015 attrs["name"] = "new-name"
933 attrs["new-unknown"] = "my-new-unknown"1016 attrs["new-unknown"] = "my-new-unknown"
934 c.Assert(newcfg.AllAttrs(), gc.DeepEquals, attrs)1017 c.Assert(newcfg.AllAttrs(), jc.DeepEquals, attrs)
935}1018}
9361019
937type validationTest struct {1020type validationTest struct {
9381021
=== modified file 'provider/common/bootstrap.go'
--- provider/common/bootstrap.go 2014-01-28 04:58:43 +0000
+++ provider/common/bootstrap.go 2014-01-30 17:28:09 +0000
@@ -19,6 +19,7 @@
19 "launchpad.net/juju-core/environs"19 "launchpad.net/juju-core/environs"
20 "launchpad.net/juju-core/environs/bootstrap"20 "launchpad.net/juju-core/environs/bootstrap"
21 "launchpad.net/juju-core/environs/cloudinit"21 "launchpad.net/juju-core/environs/cloudinit"
22 "launchpad.net/juju-core/environs/config"
22 "launchpad.net/juju-core/instance"23 "launchpad.net/juju-core/instance"
23 coretools "launchpad.net/juju-core/tools"24 coretools "launchpad.net/juju-core/tools"
24 "launchpad.net/juju-core/utils"25 "launchpad.net/juju-core/utils"
@@ -191,10 +192,14 @@
191 exit 1192 exit 1
192 fi193 fi
193 `, nonceFile, utils.ShQuote(machineConfig.MachineNonce))194 `, nonceFile, utils.ShQuote(machineConfig.MachineNonce))
194 // TODO: jam 2013-12-04 bug #1257649195 addr, err := waitSSH(
195 // It would be nice if users had some controll over their bootstrap196 ctx,
196 // timeout, since it is unlikely to be a perfect match for all clouds.197 interrupted,
197 addr, err := waitSSH(ctx, interrupted, client, checkNonceCommand, inst, DefaultBootstrapSSHTimeout())198 client,
199 checkNonceCommand,
200 inst,
201 machineConfig.Config.BootstrapSSHOpts(),
202 )
198 if err != nil {203 if err != nil {
199 return err204 return err
200 }205 }
@@ -216,33 +221,6 @@
216 })221 })
217}222}
218223
219// SSHTimeoutOpts lists the amount of time we will wait for various parts of
220// the SSH connection to complete. This is similar to DialOpts, see
221// http://pad.lv/1258889 about possibly deduplicating them.
222type SSHTimeoutOpts struct {
223 // Timeout is the amount of time to wait contacting
224 // a state server.
225 Timeout time.Duration
226
227 // ConnectDelay is the amount of time between attempts to connect to an address.
228 ConnectDelay time.Duration
229
230 // AddressesDelay is the amount of time between refreshing the addresses.
231 AddressesDelay time.Duration
232}
233
234// DefaultBootstrapSSHTimeout is the time we'll wait for SSH to come up on the bootstrap node
235func DefaultBootstrapSSHTimeout() SSHTimeoutOpts {
236 return SSHTimeoutOpts{
237 Timeout: 10 * time.Minute,
238
239 ConnectDelay: 5 * time.Second,
240
241 // Not too frequent, as we refresh addresses from the provider each time.
242 AddressesDelay: 10 * time.Second,
243 }
244}
245
246type addresser interface {224type addresser interface {
247 // Refresh refreshes the addresses for the instance.225 // Refresh refreshes the addresses for the instance.
248 Refresh() error226 Refresh() error
@@ -377,7 +355,7 @@
377// the presence of a file on the machine that contains the355// the presence of a file on the machine that contains the
378// machine's nonce. The "checkHostScript" is a bash script356// machine's nonce. The "checkHostScript" is a bash script
379// that performs this file check.357// that performs this file check.
380func waitSSH(ctx environs.BootstrapContext, interrupted <-chan os.Signal, client ssh.Client, checkHostScript string, inst addresser, timeout SSHTimeoutOpts) (addr string, err error) {358func waitSSH(ctx environs.BootstrapContext, interrupted <-chan os.Signal, client ssh.Client, checkHostScript string, inst addresser, timeout config.SSHTimeoutOpts) (addr string, err error) {
381 globalTimeout := time.After(timeout.Timeout)359 globalTimeout := time.After(timeout.Timeout)
382 pollAddresses := time.NewTimer(0)360 pollAddresses := time.NewTimer(0)
383361
@@ -389,7 +367,7 @@
389 client: client,367 client: client,
390 stderr: ctx.Stderr(),368 stderr: ctx.Stderr(),
391 active: make(map[instance.Address]chan struct{}),369 active: make(map[instance.Address]chan struct{}),
392 checkDelay: timeout.ConnectDelay,370 checkDelay: timeout.RetryDelay,
393 checkHostScript: checkHostScript,371 checkHostScript: checkHostScript,
394 }372 }
395 defer checker.Kill()373 defer checker.Kill()
396374
=== modified file 'provider/common/bootstrap_test.go'
--- provider/common/bootstrap_test.go 2014-01-28 04:58:43 +0000
+++ provider/common/bootstrap_test.go 2014-01-30 17:28:09 +0000
@@ -261,9 +261,9 @@
261 return nil, nil261 return nil, nil
262}262}
263263
264var testSSHTimeout = common.SSHTimeoutOpts{264var testSSHTimeout = config.SSHTimeoutOpts{
265 Timeout: coretesting.ShortWait,265 Timeout: coretesting.ShortWait,
266 ConnectDelay: 1 * time.Millisecond,266 RetryDelay: 1 * time.Millisecond,
267 AddressesDelay: 1 * time.Millisecond,267 AddressesDelay: 1 * time.Millisecond,
268}268}
269269

Subscribers

People subscribed via source and target branches

to status/vote changes: