@@ -133,16 +133,25 @@ func (n *Node) Init(ctx context.Context) error {
133
133
return fmt .Errorf ("failed initialize cluster state store: %s" , err )
134
134
}
135
135
136
+ // Check to see if cluster has already been initialized.
137
+ clusterInitialized , err := store .IsInitializationFlagSet ()
138
+ if err != nil {
139
+ return fmt .Errorf ("failed to verify cluster state %s" , err )
140
+ }
141
+
136
142
// Ensure we have the required s3 credentials set.
137
143
if os .Getenv ("S3_ARCHIVE_CONFIG" ) != "" || os .Getenv ("S3_ARCHIVE_REMOTE_RESTORE_CONFIG" ) != "" {
138
144
if err := writeS3Credentials (ctx , s3AuthDir ); err != nil {
139
145
return fmt .Errorf ("failed to write s3 credentials: %s" , err )
140
146
}
141
147
}
142
148
143
- // Determine if we are performing a remote restore.
144
- if err := n .handleRemoteRestore (ctx , store ); err != nil {
145
- return fmt .Errorf ("failed to handle remote restore: %s" , err )
149
+ // Remote restores are only eligible on uninitialized clusters.
150
+ if ! clusterInitialized {
151
+ // Determine if we are performing a remote restore.
152
+ if err := n .handleRemoteRestore (ctx , store ); err != nil {
153
+ return fmt .Errorf ("failed to handle remote restore: %s" , err )
154
+ }
146
155
}
147
156
148
157
// Verify whether we are a booting zombie.
@@ -161,12 +170,6 @@ func (n *Node) Init(ctx context.Context) error {
161
170
}
162
171
163
172
if ! n .PGConfig .isInitialized () {
164
- // Check to see if cluster has already been initialized.
165
- clusterInitialized , err := store .IsInitializationFlagSet ()
166
- if err != nil {
167
- return fmt .Errorf ("failed to verify cluster state %s" , err )
168
- }
169
-
170
173
if clusterInitialized {
171
174
if n .RepMgr .Witness {
172
175
log .Println ("Provisioning witness" )
0 commit comments