Skip to content

Commit

Permalink
5.1.1 - handle SC-mode rackid setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Glonek committed Feb 6, 2023
1 parent ba74bd7 commit 493fa31
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### 5.1.1
* handle rack-id settings with roster in sc mode

#### 5.1.0
* add option `aerolab config docker` to handle multiple docker networks
* add option to specify network name when creating docker clusters/clients
Expand Down
2 changes: 1 addition & 1 deletion VERSION.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.1.0
5.1.1
1 change: 1 addition & 0 deletions docs/usage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* [Custom Startup Scripts](custom-start.md)
* [Limit Cluster Resource Use](limits.md)
* [Deploying a Rack-aware Cluster](racks.md)
* [Deploying a Rack-aware Cluster in strong consistency mode](rack-sc.md)
* [Create an Aerospike cluster with Strong Consistency](strong.md)

## Monitoring
Expand Down
31 changes: 31 additions & 0 deletions docs/usage/rack-sc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Deploy a Rack-Aware Cluster with strong-consistency
AeroLab makes it easy for you to deploy a [rack-aware](https://docs.aerospike.com/server/operations/configure/network/rack-aware)
Aerospike Database cluster.

## Create a size node Aerospike cluster, do not start aerospike

```bash
aerolab cluster create -c 6 -s n -o sc-template-file.conf
```

## Assign rack-id 1 to first three nodes, all namespaces

Do not re-roster with strong-consistency, we are not ready to do that yet.

```bash
aerolab conf rackid -l 1-3 -i 1 --no-roster
```

## Assign rack-id 2 to the next three nodes, all namespaces

This time we will allow strong consistency roster to be apply too and the cluster to be restarted.

```bash
aerolab conf rackid -l 4-6 -i 2
```

## Confirm the cluster is working

```bash
aerolab attach asadm -- -e info
```
4 changes: 2 additions & 2 deletions docs/usage/racks.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ aerolab cluster create -c 6 -s n
## Assign rack-id 1 to first three nodes, all namespaces

```bash
aerolab conf rackid -l 1-3 -i 1
aerolab conf rackid -l 1-3 -i 1 --no-restart
```

## Assign rack-id 2 to the next three nodes, all namespaces

```bash
aerolab conf rackid -l 4-6 -i 2
aerolab conf rackid -l 4-6 -i 2 --no-restart
```

## Start aerospike
Expand Down
47 changes: 46 additions & 1 deletion src/cmdConfRackid.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ type confRackIdCmd struct {
aerospikeStartCmd
RackId string `short:"i" long:"id" description:"Rack ID to use" default:"0"`
Namespaces string `short:"m" long:"namespaces" description:"comma-separated list of namespaces to modify; empty=all" default:""`
NoRoster bool `short:"r" long:"no-roster" description:"if SC namespaces are found: aerolab will automatically restart aerospike and reset the roster for SC namespaces to reflect the rack-id; set this to not set the roster"`
NoRestart bool `short:"e" long:"no-restart" description:"if no SC namespaces are found: aerolab will automatically restart aerospike when rackid is set; set this to prevent said action"`
}

func (c *confRackIdCmd) Execute(args []string) error {
Expand Down Expand Up @@ -68,6 +70,7 @@ func (c *confRackIdCmd) Execute(args []string) error {
foundns := 0

// fix config if needed, read custom config file path if needed
scFound := []string{}
for _, i := range nodes {
files := []fileList{}
var r [][]string
Expand All @@ -91,6 +94,13 @@ func (c *confRackIdCmd) Execute(args []string) error {
}
if len(namespaces) == 0 || inslice.HasString(namespaces, strings.Trim(ns[1], "\r\t\n ")) {
cc.Stanza(key).SetValue("rack-id", c.RackId)
if cc.Stanza(key).Type("strong-consistency") == aeroconf.ValueString {
if sc, err := cc.Stanza(key).GetValues("strong-consistency"); err == nil && len(sc) > 0 && strings.ToLower(*sc[0]) == "true" {
if !inslice.HasString(scFound, ns[1]) {
scFound = append(scFound, ns[1])
}
}
}
foundns++
}
}
Expand All @@ -111,6 +121,41 @@ func (c *confRackIdCmd) Execute(args []string) error {
}
}

log.Print("Done, do not forget to restart the aerospike service")
if len(scFound) > 0 {
if c.NoRoster {
log.Print("NOTE: strong-consistency namespace found, please set the roster to reflect the rack-id by re-running `aerolab roster apply` on the cluster")
log.Print("Do not forget to restart the aerospike service first to reload the configuration files")
} else {
log.Print("Strong-consistency namespaces found, restarting aerospike and setting up the roster")
a.opts.Aerospike.Restart.ClusterName = c.ClusterName
a.opts.Aerospike.Restart.Nodes = ""
err = a.opts.Aerospike.Restart.run(args, "restart")
if err != nil {
log.Printf("ERROR running 'aerospike restart': %s", err)
}
for _, namespace := range scFound {
a.opts.Roster.Apply.ClusterName = c.ClusterName
a.opts.Roster.Apply.Namespace = namespace
a.opts.Roster.Apply.Nodes = ""
err = a.opts.Roster.Apply.runApply(args)
if err != nil {
log.Printf("ERROR running 'roster apply': %s", err)
}
}
log.Print("Done")
}
} else {
if !c.NoRestart {
a.opts.Aerospike.Restart.ClusterName = c.ClusterName
a.opts.Aerospike.Restart.Nodes = c.Nodes
err = a.opts.Aerospike.Restart.run(args, "restart")
if err != nil {
log.Printf("ERROR running 'aerospike restart': %s", err)
}
log.Print("Done")
} else {
log.Print("Done, remember to restart aerospike for the changes to take effect")
}
}
return nil
}
9 changes: 8 additions & 1 deletion src/cmdRosterApply.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ func (c *rosterApplyCmd) Execute(args []string) error {
}

log.Print("Running roster.apply")
err := c.runApply(args)
if err != nil {
return err
}
log.Print("Done")
return nil
}

func (c *rosterApplyCmd) runApply(args []string) error {
clist, err := b.ClusterList()
if err != nil {
return err
Expand Down Expand Up @@ -110,6 +118,5 @@ func (c *rosterApplyCmd) Execute(args []string) error {
if err != nil {
return err
}
log.Print("Done")
return nil
}
2 changes: 1 addition & 1 deletion src/version.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package main

var version = "v5.1.0"
var version = "v5.1.1"

var simulateArmInstaller = false

0 comments on commit 493fa31

Please sign in to comment.