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

Side by Side Diff: provider/azure/environ.go

Issue 13632056: Reduce unnecessary s3 timeouts (Closed)
Patch Set: Reduce unnecessary s3 timeouts Created 11 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 Canonical Ltd. 1 // Copyright 2013 Canonical Ltd.
2 // Licensed under the AGPLv3, see LICENCE file for details. 2 // Licensed under the AGPLv3, see LICENCE file for details.
3 3
4 package azure 4 package azure
5 5
6 import ( 6 import (
7 "fmt" 7 "fmt"
8 "net/http" 8 "net/http"
9 "sync" 9 "sync"
10 "time" 10 "time"
11 11
12 "launchpad.net/gwacl" 12 "launchpad.net/gwacl"
13 13
14 "launchpad.net/juju-core/constraints" 14 "launchpad.net/juju-core/constraints"
15 "launchpad.net/juju-core/environs" 15 "launchpad.net/juju-core/environs"
16 "launchpad.net/juju-core/environs/cloudinit" 16 "launchpad.net/juju-core/environs/cloudinit"
17 "launchpad.net/juju-core/environs/config" 17 "launchpad.net/juju-core/environs/config"
18 "launchpad.net/juju-core/environs/imagemetadata" 18 "launchpad.net/juju-core/environs/imagemetadata"
19 "launchpad.net/juju-core/environs/instances" 19 "launchpad.net/juju-core/environs/instances"
20 "launchpad.net/juju-core/environs/simplestreams" 20 "launchpad.net/juju-core/environs/simplestreams"
21 "launchpad.net/juju-core/environs/storage"
21 envtools "launchpad.net/juju-core/environs/tools" 22 envtools "launchpad.net/juju-core/environs/tools"
22 "launchpad.net/juju-core/instance" 23 "launchpad.net/juju-core/instance"
23 "launchpad.net/juju-core/provider" 24 "launchpad.net/juju-core/provider"
24 "launchpad.net/juju-core/state" 25 "launchpad.net/juju-core/state"
25 "launchpad.net/juju-core/state/api" 26 "launchpad.net/juju-core/state/api"
26 "launchpad.net/juju-core/tools" 27 "launchpad.net/juju-core/tools"
27 "launchpad.net/juju-core/utils/parallel" 28 "launchpad.net/juju-core/utils/parallel"
28 ) 29 )
29 30
30 const ( 31 const (
(...skipping 24 matching lines...) Expand all
55 // only be accessed using a lock or a snapshot. 56 // only be accessed using a lock or a snapshot.
56 sync.Mutex 57 sync.Mutex
57 58
58 // name is immutable; it does not need locking. 59 // name is immutable; it does not need locking.
59 name string 60 name string
60 61
61 // ecfg is the environment's Azure-specific configuration. 62 // ecfg is the environment's Azure-specific configuration.
62 ecfg *azureEnvironConfig 63 ecfg *azureEnvironConfig
63 64
64 // storage is this environ's own private storage. 65 // storage is this environ's own private storage.
65 » storage environs.Storage 66 » storage storage.Storage
66 67
67 // publicStorage is the public storage that this environ uses. 68 // publicStorage is the public storage that this environ uses.
68 » publicStorage environs.StorageReader 69 » publicStorage storage.StorageReader
69 70
70 // storageAccountKey holds an access key to this environment's 71 // storageAccountKey holds an access key to this environment's
71 // private storage. This is automatically queried from Azure on 72 // private storage. This is automatically queried from Azure on
72 // startup. 73 // startup.
73 storageAccountKey string 74 storageAccountKey string
74 } 75 }
75 76
76 // azureEnviron implements Environ and HasRegion. 77 // azureEnviron implements Environ and HasRegion.
77 var _ environs.Environ = (*azureEnviron)(nil) 78 var _ environs.Environ = (*azureEnviron)(nil)
78 var _ simplestreams.HasRegion = (*azureEnviron)(nil) 79 var _ simplestreams.HasRegion = (*azureEnviron)(nil)
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 // into a slice of instance.Instance objects. 660 // into a slice of instance.Instance objects.
660 func convertToInstances(services []gwacl.HostedServiceDescriptor, env *azureEnvi ron) []instance.Instance { 661 func convertToInstances(services []gwacl.HostedServiceDescriptor, env *azureEnvi ron) []instance.Instance {
661 instances := make([]instance.Instance, len(services)) 662 instances := make([]instance.Instance, len(services))
662 for i, service := range services { 663 for i, service := range services {
663 instances[i] = &azureInstance{service, env} 664 instances[i] = &azureInstance{service, env}
664 } 665 }
665 return instances 666 return instances
666 } 667 }
667 668
668 // Storage is specified in the Environ interface. 669 // Storage is specified in the Environ interface.
669 func (env *azureEnviron) Storage() environs.Storage { 670 func (env *azureEnviron) Storage() storage.Storage {
670 return env.getSnapshot().storage 671 return env.getSnapshot().storage
671 } 672 }
672 673
673 // PublicStorage is specified in the Environ interface. 674 // PublicStorage is specified in the Environ interface.
674 func (env *azureEnviron) PublicStorage() environs.StorageReader { 675 func (env *azureEnviron) PublicStorage() storage.StorageReader {
675 return env.getSnapshot().publicStorage 676 return env.getSnapshot().publicStorage
676 } 677 }
677 678
678 // Destroy is specified in the Environ interface. 679 // Destroy is specified in the Environ interface.
679 func (env *azureEnviron) Destroy(ensureInsts []instance.Instance) error { 680 func (env *azureEnviron) Destroy(ensureInsts []instance.Instance) error {
680 logger.Debugf("destroying environment %q", env.name) 681 logger.Debugf("destroying environment %q", env.name)
681 682
682 // Stop all instances. 683 // Stop all instances.
683 insts, err := env.AllInstances() 684 insts, err := env.AllInstances()
684 if err != nil { 685 if err != nil {
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 // It contains the central databases for the released and daily streams, but thi s may 902 // It contains the central databases for the released and daily streams, but thi s may
902 // become more configurable. This variable is here as a placeholder, but also 903 // become more configurable. This variable is here as a placeholder, but also
903 // as an injection point for tests. 904 // as an injection point for tests.
904 var baseURLs = []string{ 905 var baseURLs = []string{
905 "http://cloud-images.ubuntu.com/daily", 906 "http://cloud-images.ubuntu.com/daily",
906 } 907 }
907 908
908 // GetImageSources returns a list of sources which are used to search for simple streams image metadata. 909 // GetImageSources returns a list of sources which are used to search for simple streams image metadata.
909 func (env *azureEnviron) GetImageSources() ([]simplestreams.DataSource, error) { 910 func (env *azureEnviron) GetImageSources() ([]simplestreams.DataSource, error) {
910 sources := make([]simplestreams.DataSource, 1+len(baseURLs)) 911 sources := make([]simplestreams.DataSource, 1+len(baseURLs))
911 » sources[0] = environs.NewStorageSimpleStreamsDataSource(env.Storage(), " ") 912 » sources[0] = storage.NewStorageSimpleStreamsDataSource(env.Storage(), "" )
912 for i, url := range baseURLs { 913 for i, url := range baseURLs {
913 sources[i+1] = simplestreams.NewURLDataSource(url) 914 sources[i+1] = simplestreams.NewURLDataSource(url)
914 } 915 }
915 return sources, nil 916 return sources, nil
916 } 917 }
917 918
918 // GetToolsSources returns a list of sources which are used to search for simple streams tools metadata. 919 // GetToolsSources returns a list of sources which are used to search for simple streams tools metadata.
919 func (env *azureEnviron) GetToolsSources() ([]simplestreams.DataSource, error) { 920 func (env *azureEnviron) GetToolsSources() ([]simplestreams.DataSource, error) {
920 // Add the simplestreams source off the control bucket. 921 // Add the simplestreams source off the control bucket.
921 » return []simplestreams.DataSource{environs.NewStorageSimpleStreamsDataSo urce(env.Storage(), environs.BaseToolsPath)}, nil 922 » return []simplestreams.DataSource{storage.NewStorageSimpleStreamsDataSou rce(env.Storage(), storage.BaseToolsPath)}, nil
922 } 923 }
923 924
924 // getImageStream returns the name of the simplestreams stream from which 925 // getImageStream returns the name of the simplestreams stream from which
925 // this environment wants its images, e.g. "releases" or "daily", or the 926 // this environment wants its images, e.g. "releases" or "daily", or the
926 // blank string for the default. 927 // blank string for the default.
927 func (env *azureEnviron) getImageStream() string { 928 func (env *azureEnviron) getImageStream() string {
928 // Hard-coded to the default for now. 929 // Hard-coded to the default for now.
929 return "" 930 return ""
930 } 931 }
931 932
932 // getImageMetadataSigningRequired returns whether this environment requires 933 // getImageMetadataSigningRequired returns whether this environment requires
933 // image metadata from Simplestreams to be signed. 934 // image metadata from Simplestreams to be signed.
934 func (env *azureEnviron) getImageMetadataSigningRequired() bool { 935 func (env *azureEnviron) getImageMetadataSigningRequired() bool {
935 // Hard-coded to true for now. Once we support custom base URLs, 936 // Hard-coded to true for now. Once we support custom base URLs,
936 // this may have to change. 937 // this may have to change.
937 return true 938 return true
938 } 939 }
939 940
940 // Region is specified in the HasRegion interface. 941 // Region is specified in the HasRegion interface.
941 func (env *azureEnviron) Region() (simplestreams.CloudSpec, error) { 942 func (env *azureEnviron) Region() (simplestreams.CloudSpec, error) {
942 ecfg := env.getSnapshot().ecfg 943 ecfg := env.getSnapshot().ecfg
943 return simplestreams.CloudSpec{ 944 return simplestreams.CloudSpec{
944 Region: ecfg.location(), 945 Region: ecfg.location(),
945 Endpoint: string(gwacl.GetEndpoint(ecfg.location())), 946 Endpoint: string(gwacl.GetEndpoint(ecfg.location())),
946 }, nil 947 }, nil
947 } 948 }
OLDNEW

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