Skip to content

Commit

Permalink
Prefix commonVMSS.sh to bootstrap script rather than postfix
Browse files Browse the repository at this point in the history
Fix deliminator character for mapfile in dnf update function. newline is needed.
commonVMSS.sh must be prepended to the bootstrap script rather than postfixed, because main needs to be called at the bottom after all declerations.
  • Loading branch information
s-fairchild committed May 17, 2024
1 parent 0a4e742 commit 869c313
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pkg/deploy/assets/env-development.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/deploy/assets/gateway-production.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/deploy/assets/rp-production.json

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions pkg/deploy/generator/resources_dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ func (g *generator) devProxyVMSS() *arm.Resource {

var sb strings.Builder

sb.WriteString(string(scriptDevProxyVMSS))
sb.WriteString("\n")
// VMSS extensions only support one custom script
// Because of this, the commonVMSS.sh is prefixed to the bootstrapping script
// main is called at the end of the bootstrapping script, so appending commonVMSS.sh won't work
sb.WriteString(string(scriptCommonVMSS))
sb.WriteString("\n#Start of devProxyVMSS.sh\n")
sb.WriteString(string(scriptDevProxyVMSS))

trailer := base64.StdEncoding.EncodeToString([]byte(sb.String()))

Expand Down
7 changes: 5 additions & 2 deletions pkg/deploy/generator/resources_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,12 @@ func (g *generator) gatewayVMSS() *arm.Resource {

var sb strings.Builder

sb.WriteString(string(scriptGatewayVMSS))
sb.WriteString("\n")
// VMSS extensions only support one custom script
// Because of this, the commonVMSS.sh is prefixed to the bootstrapping script
// main is called at the end of the bootstrapping script, so appending commonVMSS.sh won't work
sb.WriteString(string(scriptCommonVMSS))
sb.WriteString("\n#Start of gatewayVMSS.sh\n")
sb.WriteString(string(scriptGatewayVMSS))

trailer := base64.StdEncoding.EncodeToString([]byte(sb.String()))

Expand Down
7 changes: 5 additions & 2 deletions pkg/deploy/generator/resources_rp.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,9 +533,12 @@ func (g *generator) rpVMSS() *arm.Resource {

var sb strings.Builder

sb.WriteString(string(scriptRpVMSS))
sb.WriteString("\n")
// VMSS extensions only support one custom script
// Because of this, the commonVMSS.sh is prefixed to the bootstrapping script
// main is called at the end of the bootstrapping script, so appending commonVMSS.sh won't work
sb.WriteString(string(scriptCommonVMSS))
sb.WriteString("\n#Start of rpVMSS.sh\n")
sb.WriteString(string(scriptRpVMSS))

trailer := base64.StdEncoding.EncodeToString([]byte(sb.String()))

Expand Down
6 changes: 3 additions & 3 deletions pkg/deploy/generator/scripts/commonVMSS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ dnf_update_pkgs() {

if [ -n "${excludes+x}" ]; then
# See https://www.shellcheck.net/wiki/SC2206
mapfile -O 2 -d ' ' cmd <<< "${excludes[@]}"
mapfile -O 2 cmd <<< "${excludes[@]}"
else
# Remove empty string if we aren't replacing them, probably doesn't matter, but why not be safe
unset "cmd[2]"
Expand Down Expand Up @@ -289,8 +289,8 @@ reboot_vm() {
configure_selinux "true"

hour="$(date -d "1 hour" +%H:%M)"
log "Scheduling reboot at $hour"
at "$hour" systemctl reboot
shutdown_msg="$(shutdown -r "$hour" "Post deployment reboot is happening now")"
log "$shutdown_msg"
}

# log is a wrapper for echo that includes the function name
Expand Down

0 comments on commit 869c313

Please sign in to comment.