Skip to content

Commit 51f10f7

Browse files
committed
Fixing comments
1 parent 82ee8fa commit 51f10f7

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

pkg/flypg/node.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,12 @@ func (n *Node) Init() error {
120120
repmgr := n.RepMgr
121121
pgbouncer := n.PGBouncer
122122

123-
// Writes or updates the replication manager configuration.
124123
fmt.Println("Initializing replication manager")
125124
if err := repmgr.initialize(); err != nil {
126125
fmt.Printf("Failed to initialize replmgr: %s\n", err.Error())
127126
}
128127

129-
// Initialize PGBouncer
130-
fmt.Println("Initializing PGBouncer")
128+
fmt.Println("Initializing pgbouncer")
131129
if err := pgbouncer.initialize(); err != nil {
132130
return err
133131
}
@@ -217,18 +215,17 @@ func (n *Node) PostInit() error {
217215
return fmt.Errorf("no primary to follow and can't configure self as primary because primary region is '%s' and we are in '%s'", repmgr.Region, os.Getenv("PRIMARY_REGION"))
218216
}
219217

220-
// Initialize ourselves as the primary.
218+
// Create required users
221219
if err := n.createRequiredUsers(conn); err != nil {
222220
return fmt.Errorf("failed to create required users: %s", err)
223221
}
224222

225-
// Creates the replication manager database.
223+
// Setup repmgr database, extension, and register ourselves as the primary
226224
fmt.Println("Perform Repmgr setup")
227225
if err := repmgr.setup(conn); err != nil {
228226
return fmt.Errorf("failed to setup repmgr: %s", err)
229227
}
230228

231-
// Register ourselves with Consul
232229
if err := consul.RegisterPrimary(n.PrivateIP); err != nil {
233230
return fmt.Errorf("failed to register primary with consul: %s", err)
234231
}
@@ -250,6 +247,7 @@ func (n *Node) PostInit() error {
250247
return err
251248
}
252249

250+
// If we are a primary coming back from the dead, make sure we unregister ourselves as primary.
253251
if role == primaryRoleName {
254252
fmt.Println("Unregistering primary")
255253
if err := repmgr.unregisterPrimary(); err != nil {
@@ -272,6 +270,7 @@ func (n *Node) PostInit() error {
272270
}
273271
}
274272

273+
// Requery the primaryIP in case a new primary was assigned above.
275274
primaryIP, err = consul.CurrentPrimary()
276275
if err != nil {
277276
return fmt.Errorf("failed to query current primary: %s", err)

0 commit comments

Comments
 (0)