Skip to content

Commit

Permalink
Merge pull request #366 from aerospike/v7.6.0
Browse files Browse the repository at this point in the history
FIX auto-update DNS in the cloud to 1.1.1.1
  • Loading branch information
robertglonek authored Jul 25, 2024
2 parents b4d411a + ecec76c commit 8319e3e
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG/7.6.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ _Release Date: Month Day, Year_

**Release Notes:**
* FIX: The commands `cluster list -i` and `client list -i` would sometimes print nodes in duplicates; this fixes the duplicate issue.
* FIX: Patch `systemd-resolved` by default to use `1.1.1.1` and `8.8.8.8` DNS servers in cloud backends.
* Add support for ubuntu 24.04 (default with aerospike 7.2).
* Allow up to 24 char-long cluster and client names, from previous limit of 20, to support shortuuid.
* AGI: Add experimental feature `SingularSeriesExtend` in grafana plugin - if a series has only 1 datapoint, add predefined points one second before and after to force grafana to draw a line - so it's always visible at large zoom-out level.
Expand Down
18 changes: 18 additions & 0 deletions src/cmdClientDoBase.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type clientCreateBaseCmd struct {
ClientName TypeClientName `short:"n" long:"group-name" description:"Client group name" default:"client"`
ClientCount int `short:"c" long:"count" description:"Number of clients" default:"1"`
NoSetHostname bool `short:"H" long:"no-set-hostname" description:"by default, hostname of each machine will be set, use this to prevent hostname change"`
NoSetDNS bool `long:"no-set-dns" description:"set to prevent aerolab from updating resolved to use 1.1.1.1/8.8.8.8 DNS"`
StartScript flags.Filename `short:"X" long:"start-script" description:"optionally specify a script to be installed which will run when the client machine starts"`
osSelectorCmd
parallelThreadsCmd
Expand Down Expand Up @@ -377,6 +378,23 @@ func (c *clientCreateBaseCmd) createBase(args []string, nt string) (machines []i
log.Printf("Node IP map: %v", nip)
}
returns := parallelize.MapLimit(nodeListNew, c.ParallelThreads, func(nnode int) error {
if a.opts.Config.Backend.Type != "docker" && !c.NoSetDNS {
dnsScript := `mkdir -p /etc/systemd/resolved.conf.d
cat <<'EOF' > /etc/systemd/resolved.conf.d/aerolab.conf
[Resolve]
DNS=1.1.1.1
FallbackDNS=8.8.8.8
EOF
systemctl restart systemd-resolved
`
if err = b.CopyFilesToClusterReader(string(c.ClientName), []fileListReader{{filePath: "/tmp/fix-dns.sh", fileContents: strings.NewReader(dnsScript), fileSize: len(dnsScript)}}, []int{nnode}); err == nil {
if _, err = b.RunCommands(string(c.ClientName), [][]string{{"/bin/bash", "-c", "chmod 755 /tmp/fix-dns.sh; bash /tmp/fix-dns.sh"}}, []int{nnode}); err != nil {
log.Print("Failed to set DNS resolvers by running /tmp/fix-dns.sh")
}
} else {
log.Printf("Failed to upload DNS resolver script to /tmp/fix-dns.sh: %s", err)
}
}
repl := "cd aerospike-server-* ; ./asinstall || exit 1"
repl2 := "cd /root && tar -zxf installer.tgz || exit 1"
repl3 := "cd /root && tar -zxvf installer.tgz || exit 1"
Expand Down
18 changes: 18 additions & 0 deletions src/cmdClientDoNone.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type clientCreateNoneCmd struct {
ClientName TypeClientName `short:"n" long:"group-name" description:"Client group name" default:"client"`
ClientCount int `short:"c" long:"count" description:"Number of clients" default:"1"`
NoSetHostname bool `short:"H" long:"no-set-hostname" description:"by default, hostname of each machine will be set, use this to prevent hostname change"`
NoSetDNS bool `long:"no-set-dns" description:"set to prevent aerolab from updating resolved to use 1.1.1.1/8.8.8.8 DNS"`
StartScript flags.Filename `short:"X" long:"start-script" description:"optionally specify a script to be installed which will run when the client machine starts"`
Aws clusterCreateCmdAws `no-flag:"true"`
Gcp clusterCreateCmdGcp `no-flag:"true"`
Expand Down Expand Up @@ -383,6 +384,23 @@ func (c *clientCreateNoneCmd) createBase(args []string, nt string) (machines []i
log.Printf("Node IP map: %v", nip)
}
returns := parallelize.MapLimit(nodeListNew, c.ParallelThreads, func(nnode int) error {
if a.opts.Config.Backend.Type != "docker" && !c.NoSetDNS {
dnsScript := `mkdir -p /etc/systemd/resolved.conf.d
cat <<'EOF' > /etc/systemd/resolved.conf.d/aerolab.conf
[Resolve]
DNS=1.1.1.1
FallbackDNS=8.8.8.8
EOF
systemctl restart systemd-resolved
`
if err = b.CopyFilesToClusterReader(string(c.ClientName), []fileListReader{{filePath: "/tmp/fix-dns.sh", fileContents: strings.NewReader(dnsScript), fileSize: len(dnsScript)}}, []int{nnode}); err == nil {
if _, err = b.RunCommands(string(c.ClientName), [][]string{{"/bin/bash", "-c", "chmod 755 /tmp/fix-dns.sh; bash /tmp/fix-dns.sh"}}, []int{nnode}); err != nil {
log.Print("Failed to set DNS resolvers by running /tmp/fix-dns.sh")
}
} else {
log.Printf("Failed to upload DNS resolver script to /tmp/fix-dns.sh: %s", err)
}
}
// set hostnames for cloud
if a.opts.Config.Backend.Type != "docker" && !c.NoSetHostname {
newHostname := fmt.Sprintf("%s-%d", string(c.ClientName), nnode)
Expand Down
18 changes: 18 additions & 0 deletions src/cmdClusterCreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ type clusterCreateCmd struct {
AutoStartAerospike TypeYesNo `short:"s" long:"start" description:"Auto-start aerospike after creation of cluster (y/n)" default:"y" webchoice:"y,n"`
NoOverrideClusterName bool `short:"O" long:"no-override-cluster-name" description:"Aerolab sets cluster-name by default, use this parameter to not set cluster-name" simplemode:"false"`
NoSetHostname bool `short:"H" long:"no-set-hostname" description:"by default, hostname of each machine will be set, use this to prevent hostname change" simplemode:"false"`
NoSetDNS bool `long:"no-set-dns" description:"set to prevent aerolab from updating resolved to use 1.1.1.1/8.8.8.8 DNS"`
ScriptEarly flags.Filename `short:"X" long:"early-script" description:"optionally specify a script to be installed which will run before every aerospike start" simplemode:"false"`
ScriptLate flags.Filename `short:"Z" long:"late-script" description:"optionally specify a script to be installed which will run after every aerospike stop" simplemode:"false"`
parallelThreadsCmd
Expand Down Expand Up @@ -1191,6 +1192,23 @@ func (c *clusterCreateCmd) realExecute2(args []string, isGrow bool) error {
}
b.WorkOnServers()
returns := parallelize.MapLimit(nodeListNew, c.ParallelThreads, func(nnode int) error {
if a.opts.Config.Backend.Type != "docker" && !c.NoSetDNS {
dnsScript := `mkdir -p /etc/systemd/resolved.conf.d
cat <<'EOF' > /etc/systemd/resolved.conf.d/aerolab.conf
[Resolve]
DNS=1.1.1.1
FallbackDNS=8.8.8.8
EOF
systemctl restart systemd-resolved
`
if err = b.CopyFilesToClusterReader(string(c.ClusterName), []fileListReader{{filePath: "/tmp/fix-dns.sh", fileContents: strings.NewReader(dnsScript), fileSize: len(dnsScript)}}, []int{nnode}); err == nil {
if _, err = b.RunCommands(string(c.ClusterName), [][]string{{"/bin/bash", "-c", "chmod 755 /tmp/fix-dns.sh; bash /tmp/fix-dns.sh"}}, []int{nnode}); err != nil {
log.Print("Failed to set DNS resolvers by running /tmp/fix-dns.sh")
}
} else {
log.Printf("Failed to upload DNS resolver script to /tmp/fix-dns.sh: %s", err)
}
}
out, err := b.RunCommands(string(c.ClusterName), [][]string{{"cat", "/etc/aerospike/aerospike.conf"}}, []int{nnode})
if err != nil {
return err
Expand Down

0 comments on commit 8319e3e

Please sign in to comment.