@@ -49,8 +49,10 @@ func (s *Context) stackProvisioner(c *Stack) *cfnstack.Provisioner {
49
49
)
50
50
}
51
51
52
- func (s * Context ) InspectEtcdExistingState (c * Config ) (api.EtcdExistingState , error ) {
52
+ func (s * Context ) InspectEtcdExistingState (c * Config ) (bool , api.EtcdExistingState , error ) {
53
53
var err error
54
+ var exists bool
55
+
54
56
if s .ProvidedCFInterrogator == nil {
55
57
s .ProvidedCFInterrogator = cloudformation .New (s .Session )
56
58
}
@@ -59,18 +61,18 @@ func (s *Context) InspectEtcdExistingState(c *Config) (api.EtcdExistingState, er
59
61
}
60
62
61
63
state := api.EtcdExistingState {}
62
- state . StackExists , err = cfnstack .NestedStackExists (s .ProvidedCFInterrogator , c .ClusterName , naming .FromStackToCfnResource (c .Etcd .LogicalName ()))
64
+ exists , err = cfnstack .NestedStackExists (s .ProvidedCFInterrogator , c .ClusterName , naming .FromStackToCfnResource (c .Etcd .LogicalName ()))
63
65
if err != nil {
64
- return state , fmt .Errorf ("failed to check for existence of etcd cloud-formation stack: %v" , err )
66
+ return exists , state , fmt .Errorf ("failed to check for existence of etcd cloud-formation stack: %v" , err )
65
67
}
66
68
// when the Etcd stack exists we need to check for the MajorMinor version of Etcd running and trigger a migration if different to ours.
67
- if state . StackExists {
69
+ if exists {
68
70
if state .EtcdMigrationEnabled , err = s .isAMajorEtcdUpgrade (c ); err != nil {
69
- return state , fmt .Errorf ("failed to check existing etcd major minor version: %v" , err )
71
+ return exists , state , fmt .Errorf ("failed to check existing etcd major minor version: %v" , err )
70
72
}
71
73
if state .EtcdMigrationEnabled {
72
74
if state .EtcdMigrationExistingEndpoints , err = s .lookupExistingEtcdEndpoints (c ); err != nil {
73
- return state , fmt .Errorf ("failed to lookup existing etcd endpoints: %v" , err )
75
+ return exists , state , fmt .Errorf ("failed to lookup existing etcd endpoints: %v" , err )
74
76
}
75
77
logger .Warn ("Performing a Major Etcd Version Upgrade: -" )
76
78
logger .Warn ("To do this we will spin up new etcd servers and then export the existing kubernetes state to them." )
@@ -80,7 +82,23 @@ func (s *Context) InspectEtcdExistingState(c *Config) (api.EtcdExistingState, er
80
82
logger .Warn ("This operation is best scheduled for a quiet time or in an outage window." )
81
83
}
82
84
}
83
- return state , nil
85
+ return exists , state , nil
86
+ }
87
+
88
+ // Check for the existence of a worker nodepool stack by looking it up in cloudformation.
89
+ func (s * Context ) InspectWorkerExistingState (npconf * NodePoolConfig ) (bool , error ) {
90
+ var err error
91
+ var exists bool
92
+
93
+ if s .ProvidedCFInterrogator == nil {
94
+ s .ProvidedCFInterrogator = cloudformation .New (s .Session )
95
+ }
96
+
97
+ exists , err = cfnstack .NestedStackExists (s .ProvidedCFInterrogator , npconf .ClusterName , npconf .NestedStackName ())
98
+ if err != nil {
99
+ return exists , fmt .Errorf ("failed to check worker cloud-formation stack %s: %v" , npconf .NestedStackName (), err )
100
+ }
101
+ return exists , nil
84
102
}
85
103
86
104
// isAMajorEtcdUpgrade looks for etcd instances using tag kube-aws:etcd_upgrade_group and the config clusters major-minor version.
0 commit comments