Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add scriptless bootstrap status poller #5173

Merged
merged 56 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
b1f47c3
preserve exit status of csecmd
Oct 22, 2024
1ef9491
move nbcparser code to node-bootstrapper
r2k1 Oct 20, 2024
ad220a4
move sensitive_string
r2k1 Oct 20, 2024
3fda9b6
config version isn't semantic
r2k1 Oct 20, 2024
af451af
use node-boostrapper with nbc contract
r2k1 Oct 20, 2024
fb30ef7
update tests
r2k1 Oct 20, 2024
2b3ea7d
fix node-bootstrapper test
r2k1 Oct 21, 2024
d68b75c
add config version validation
r2k1 Oct 21, 2024
19edb0d
fix tests
r2k1 Oct 21, 2024
a8936f6
update tests
r2k1 Oct 22, 2024
47cbaa9
clean things
r2k1 Oct 22, 2024
5c894c2
fix tests
r2k1 Oct 22, 2024
67798cd
don't build nbcparser
r2k1 Oct 22, 2024
3c25712
fix lint error
r2k1 Oct 23, 2024
da62a1d
use latest agentbaker version
r2k1 Oct 23, 2024
eef6761
merge with master
r2k1 Oct 23, 2024
2a499ff
fix tests
r2k1 Oct 23, 2024
ec8153b
fix test
r2k1 Oct 23, 2024
9a1596d
Merge branch 'r2k1/nbcparser2' of https://github.com/Azure/AgentBaker…
Oct 23, 2024
2b8027f
add boostrap status poller
Oct 24, 2024
bdf1bfa
add better error handling
Oct 24, 2024
f9ad487
improve logging
Oct 24, 2024
de266a7
update bootstrap status cse
Oct 24, 2024
3218d1e
Merge branch 'master' of https://github.com/Azure/AgentBaker into lil…
Oct 24, 2024
4e42e29
add cse script
Oct 24, 2024
1be1157
fix systemctl err handling
Oct 25, 2024
91c4a5c
add timeout to go monitor mode
Oct 25, 2024
4c04ec6
add cse parsing to e2e and provision.json output to go binary
Oct 28, 2024
ae67d6b
remove custom_error.go
Oct 28, 2024
6055dbe
resolve merge conflicts
Oct 28, 2024
ce08ecf
add consts.go
Oct 28, 2024
8f57438
add file check
Oct 29, 2024
fe869bd
fix scriptless validator
Oct 29, 2024
285b8d7
clean up
Oct 29, 2024
c57d992
resolve comments, use file wait for polling
Oct 29, 2024
3960344
fix file wait and more comments
Oct 29, 2024
20928e4
improve error handling for timeout
Oct 29, 2024
2f903b3
restore cmdrunner
Oct 30, 2024
d7b6183
preserve stdout and stderr of systemctl cmd
Oct 30, 2024
11b7055
Merge branch 'master' of https://github.com/Azure/AgentBaker into lil…
Oct 30, 2024
c5edade
fix directory watcher
Oct 30, 2024
e59f5e8
Merge branch 'dev' of https://github.com/Azure/AgentBaker into lily/b…
Oct 31, 2024
36ae4b8
add logging statement
Oct 31, 2024
8f22b14
fix file wait using inotify
Nov 1, 2024
0f9cfcc
go mod tidy
Nov 1, 2024
e50df41
Revert "fix file wait using inotify"
Nov 1, 2024
ea27368
wait for provision.complete
Nov 1, 2024
7f6060d
change nodebootstrapper bool to string mode
Nov 1, 2024
03bfd4e
make generate
Nov 1, 2024
5614012
remove timeout from provision-wait
Nov 4, 2024
b349ff1
Merge branch 'dev' of https://github.com/Azure/AgentBaker into lily/b…
Nov 4, 2024
961c9c1
fix merge conflicts
Nov 4, 2024
856cb20
go mod tidy
Nov 4, 2024
8cdad95
add wrappers around errors
Nov 5, 2024
14ff5ea
Merge branch 'dev' into lily/bootstrap-status-poller
lilypan26 Nov 5, 2024
cc332d7
Merge branch 'dev' into lily/bootstrap-status-poller
lilypan26 Nov 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 50 additions & 2 deletions aks-node-controller/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import (
"log/slog"
"os"
"os/exec"
"path/filepath"

"github.com/Azure/agentbaker/aks-node-controller/parser"
aksnodeconfigv1 "github.com/Azure/agentbaker/pkg/proto/aksnodeconfig/v1"
"gopkg.in/fsnotify.v1"
)

type App struct {
Expand Down Expand Up @@ -58,6 +60,11 @@ func (a *App) run(ctx context.Context, args []string) error {
return errors.New("--provision-config is required")
}
return a.Provision(ctx, ProvisionFlags{ProvisionConfig: *provisionConfig})
case "provision-wait":
provisionOutput, err := a.ProvisionWait(ctx)
fmt.Println(provisionOutput)
slog.Info("provision-wait finished", "provisionOutput", provisionOutput)
return err
default:
return fmt.Errorf("unknown command: %s", args[1])
}
Expand All @@ -66,7 +73,7 @@ func (a *App) run(ctx context.Context, args []string) error {
func (a *App) Provision(ctx context.Context, flags ProvisionFlags) error {
inputJSON, err := os.ReadFile(flags.ProvisionConfig)
if err != nil {
return fmt.Errorf("open proision file %s: %w", flags.ProvisionConfig, err)
return fmt.Errorf("open provision file %s: %w", flags.ProvisionConfig, err)
}

config := &aksnodeconfigv1.Configuration{}
Expand Down Expand Up @@ -95,6 +102,48 @@ func (a *App) Provision(ctx context.Context, flags ProvisionFlags) error {
return err
}

func (a *App) ProvisionWait(ctx context.Context) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to have a test watching for a file in tmp folder

Copy link
Contributor Author

@lilypan26 lilypan26 Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to add this in a follow-up PR

if _, err := os.Stat(provisionJSONFilePath); err == nil {
data, err := os.ReadFile(provisionJSONFilePath)
if err != nil {
return "", err
}
return string(data), nil
}

watcher, err := fsnotify.NewWatcher()
if err != nil {
return "", fmt.Errorf("failed to create watcher: %w", err)
}
defer watcher.Close()

// Watch the directory containing the provision complete file
dir := filepath.Dir(provisionCompleteFilePath)
err = os.MkdirAll(dir, 0755) // create the directory if it doesn't exist
if err != nil {
return "", err
lilypan26 marked this conversation as resolved.
Show resolved Hide resolved
}
if err = watcher.Add(dir); err != nil {
return "", fmt.Errorf("failed to watch directory: %w", err)
}

for {
select {
case event := <-watcher.Events:
if event.Op&fsnotify.Create == fsnotify.Create && event.Name == provisionCompleteFilePath {
data, err := os.ReadFile(provisionJSONFilePath)
if err != nil {
return "", err
}
return string(data), nil
}

case err := <-watcher.Errors:
return "", fmt.Errorf("error watching file: %w", err)
}
lilypan26 marked this conversation as resolved.
Show resolved Hide resolved
}
}

var _ ExitCoder = &exec.ExitError{}

type ExitCoder interface {
Expand All @@ -111,5 +160,4 @@ func errToExitCode(err error) int {
return exitErr.ExitCode()
}
return 1

}
10 changes: 10 additions & 0 deletions aks-node-controller/const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package main

// Some options are intentionally non-configurable to avoid customization by users
// it will help us to avoid introducing any breaking changes in the future.
const (
logFile = "/var/log/azure/aks-node-controller.log"
bootstrapService = "bootstrap.service"
provisionJSONFilePath = "/var/log/azure/aks/provision.json"
provisionCompleteFilePath = "/opt/azure/containers/provision.complete"
)
3 changes: 3 additions & 0 deletions aks-node-controller/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ require (
github.com/stretchr/testify v1.9.0
)

require golang.org/x/sys v0.22.0 // indirect

require (
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Masterminds/semver/v3 v3.2.1 // indirect
Expand All @@ -21,6 +23,7 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/fsnotify.v1 v1.4.7
gopkg.in/yaml.v3 v3.0.1 // indirect
)

Expand Down
1 change: 1 addition & 0 deletions aks-node-controller/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHh
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
Expand Down
8 changes: 1 addition & 7 deletions aks-node-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,8 @@ import (
"os"
)

// Some options are intentionally non-configurable to avoid customization by users
// it will help us to avoid introducing any breaking changes in the future.
const (
LogFile = "/var/log/azure/aks-node-controller.log"
)

func main() {
logFile, err := os.OpenFile(LogFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
logFile, err := os.OpenFile(logFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
//nolint:forbidigo // there is no other way to communicate the error
fmt.Printf("failed to open log file: %s\n", err)
Expand Down
6 changes: 6 additions & 0 deletions e2e/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ const (
buildIDTagKey = "buildID"
defaultNamespace = "default"
)

// cse output parsing consts
const (
extensionErrorCodeRegex = `ProvisioningState/failed/(\d+)`
lilypan26 marked this conversation as resolved.
Show resolved Hide resolved
linuxExtensionExitCodeStr = `Enable failed: failed to execute command: command terminated with exit status=(\d+)`
)
75 changes: 73 additions & 2 deletions e2e/scenario_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@ package e2e

import (
"context"
"encoding/json"
"errors"
"fmt"
"os"
"os/signal"
"regexp"
"strings"
"syscall"
"testing"

"github.com/Azure/agentbaker/pkg/agent/datamodel"
aksnodeconfigv1 "github.com/Azure/agentbaker/pkg/proto/aksnodeconfig/v1"
"github.com/Azure/agentbakere2e/config"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tidwall/gjson"
Expand Down Expand Up @@ -107,6 +111,9 @@ func createAndValidateVM(ctx context.Context, t *testing.T, scenario *Scenario)
vmssName := getVmssName(t)
createVMSS(ctx, t, vmssName, scenario, privateKeyBytes, publicKeyBytes)

err = getCustomScriptExtensionStatus(ctx, t, *scenario.Runtime.Cluster.Model.Properties.NodeResourceGroup, vmssName)
require.NoError(t, err)
lilypan26 marked this conversation as resolved.
Show resolved Hide resolved

t.Logf("vmss %s creation succeeded, proceeding with node readiness and pod checks...", vmssName)
nodeName := validateNodeHealth(ctx, t, scenario.Runtime.Cluster.Kube, vmssName, scenario.Tags.Airgap)

Expand All @@ -122,9 +129,8 @@ func createAndValidateVM(ctx context.Context, t *testing.T, scenario *Scenario)
t.Logf("node %s is ready, proceeding with validation commands...", vmssName)

vmPrivateIP, err := getVMPrivateIPAddress(ctx, *scenario.Runtime.Cluster.Model.Properties.NodeResourceGroup, vmssName)
require.NoError(t, err)
lilypan26 marked this conversation as resolved.
Show resolved Hide resolved

require.NoError(t, err, "get vm private IP %v", vmssName)

err = runLiveVMValidators(ctx, t, vmssName, vmPrivateIP, string(privateKeyBytes), scenario)
require.NoError(t, err)

Expand Down Expand Up @@ -153,3 +159,68 @@ func getExpectedPackageVersions(packageName, distro, release string) []string {
}
return expectedVersions
}

func getCustomScriptExtensionStatus(ctx context.Context, t *testing.T, resourceGroupName, vmssName string) error {
pager := config.Azure.VMSSVM.NewListPager(resourceGroupName, vmssName, nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
return fmt.Errorf("failed to get VMSS instances: %v", err)
}

for _, vmInstance := range page.Value {
instanceViewResp, err := config.Azure.VMSSVM.GetInstanceView(ctx, resourceGroupName, vmssName, *vmInstance.InstanceID, nil)
if err != nil {
return fmt.Errorf("failed to get instance view for VM %s: %v", *vmInstance.InstanceID, err)
}
for _, extension := range instanceViewResp.Extensions {
for _, status := range extension.Statuses {
resp, err := parseLinuxCSEMessage(*status)
if err != nil {
return fmt.Errorf("Parse CSE message with error, error %w", err)
}
if resp.ExitCode != "0" {
return fmt.Errorf("vmssCSE %s, output=%s, error=%s", resp.ExitCode, resp.Output, resp.Error)
}
t.Logf("CSE completed successfully with exit code 0, cse output: %s", *status.Message)
return nil
}
}
}
}
return fmt.Errorf("failed to get CSE output.")
}

func parseLinuxCSEMessage(status armcompute.InstanceViewStatus) (*datamodel.CSEStatus, error) {
if status.Code == nil || status.Message == nil {
return nil, datamodel.NewError(datamodel.InvalidCSEMessage, "No valid Status code or Message provided from cse extension")
}

start := strings.Index(*status.Message, "[stdout]") + len("[stdout]")
end := strings.Index(*status.Message, "[stderr]")

var linuxExtensionExitCodeStrRegex = regexp.MustCompile(linuxExtensionExitCodeStr)
var linuxExtensionErrorCodeRegex = regexp.MustCompile(extensionErrorCodeRegex)
extensionFailed := linuxExtensionErrorCodeRegex.MatchString(*status.Code)
if end <= start {
return nil, fmt.Errorf("Parse CSE failed with error cannot find [stdout] and [stderr], raw CSE Message: %s, delete vm: %t", *status.Message, extensionFailed)
}
rawInstanceViewInfo := (*status.Message)[start:end]
// Parse CSE message
var cseStatus datamodel.CSEStatus
err := json.Unmarshal([]byte(rawInstanceViewInfo), &cseStatus)
if err != nil {
exitCodeMatch := linuxExtensionExitCodeStrRegex.FindStringSubmatch(*status.Message)
if len(exitCodeMatch) > 1 && extensionFailed {
// Failed but the format is not expected.
cseStatus.ExitCode = exitCodeMatch[1]
cseStatus.Error = *status.Message
return &cseStatus, nil
}
return nil, fmt.Errorf("Parse CSE Json failed with error: %s, raw CSE Message: %s, delete vm: %t", err, *status.Message, extensionFailed)
}
if cseStatus.ExitCode == "" {
return nil, fmt.Errorf("CSE Json does not contain exit code, raw CSE Message: %s", *status.Message)
}
return &cseStatus, nil
}
8 changes: 2 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,16 @@ require (
github.com/stretchr/testify v1.9.0
google.golang.org/protobuf v1.33.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/apimachinery v0.28.5
sigs.k8s.io/yaml v1.4.0
)

require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6 v6.1.0 // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/felixge/httpsnoop v1.0.1 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/nxadm/tail v1.4.4 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
Expand Down
18 changes: 7 additions & 11 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 h1:GJHeeA2N7xrG3q30L2UXDyuWRzDM900/65j70wcM4Ww=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0/go.mod h1:l38EPgmsp71HHLq9j7De57JcKOWPyhrsW1Awm1JS6K0=
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY=
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6 v6.1.0 h1:zDeQI/PaWztI2tcrGO/9RIMey9NvqYbnyttf/0P3QWM=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6 v6.1.0/go.mod h1:zflC9v4VfViJrSvcvplqws/yGXVbUEMZi/iHpZdSPWA=
github.com/Azure/go-autorest v14.2.0+incompatible h1:V5VMDjClD3GiElqLWO7mz2MxNAK/vTfRHdAubSIPRgs=
github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24=
github.com/Azure/go-autorest/autorest/to v0.4.0 h1:oXVqrxakqqV1UZdSazDOPOLvOIz+XA683u8EctwboHk=
Expand All @@ -14,6 +8,9 @@ github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df h1:GSoSVRLo
github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df/go.mod h1:hiVxq5OP2bUGBRNS3Z/bt/reCLFNbdcST6gISi1fiOM=
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand All @@ -39,7 +36,6 @@ github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec=
Expand All @@ -49,6 +45,7 @@ github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
Expand All @@ -70,10 +67,12 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg=
github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
Expand All @@ -94,6 +93,7 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
Expand Down Expand Up @@ -124,7 +124,3 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
k8s.io/apimachinery v0.28.5 h1:EEj2q1qdTcv2p5wl88KavAn3VlFRjREgRu8Sm/EuMPY=
k8s.io/apimachinery v0.28.5/go.mod h1:wI37ncBvfAoswfq626yPTe6Bz1c22L7uaJ8dho83mgg=
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
1 change: 0 additions & 1 deletion parts/linux/cloud-init/artifacts/cse_main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,6 @@ fi

echo "Custom script finished. API server connection check code:" $VALIDATION_ERR
echo $(date),$(hostname), endcustomscript>>/opt/m
mkdir -p /opt/azure/containers && touch /opt/azure/containers/provision.complete

exit $VALIDATION_ERR

Expand Down
2 changes: 2 additions & 0 deletions parts/linux/cloud-init/artifacts/cse_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ JSON_STRING=$( jq -n \
mkdir -p /var/log/azure/aks
echo $JSON_STRING | tee /var/log/azure/aks/provision.json

mkdir -p /opt/azure/containers && touch /opt/azure/containers/provision.complete

# messsage_string is here because GA only accepts strings in Message.
message_string=$( jq -n \
--arg EXECUTION_DURATION "${EXECUTION_DURATION}" \
Expand Down
14 changes: 4 additions & 10 deletions pkg/agent/bakerapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ func (agentBaker *agentBakerImpl) GetNodeBootstrappingForScriptless(
distro datamodel.Distro,
cloudName string,
) (*datamodel.NodeBootstrapping, error) {
customData, err := getScriptlessCustomDataContent(config)
scriptlessCustomData, err := getScriptlessCustomDataContent(config)
if err != nil {
return nil, err
}

nodeBootstrapping := &datamodel.NodeBootstrapping{
CSE: "",
CustomData: customData,
CSE: scriptlessBootstrapStatusCSE,
lilypan26 marked this conversation as resolved.
Show resolved Hide resolved
CustomData: scriptlessCustomData,
}

if distro == datamodel.CustomizedWindowsOSImage || distro == datamodel.CustomizedImage || distro == datamodel.CustomizedImageKata {
Expand All @@ -127,13 +127,7 @@ func getScriptlessCustomDataContent(config any) (string, error) {
return "", fmt.Errorf("failed to marshal nbc, error: %w", err)
}
encodedNBCJson := base64.StdEncoding.EncodeToString(nbcJSON)
customDataYAML := fmt.Sprintf(`#cloud-config
write_files:
- path: /opt/azure/containers/aks-node-controller-config.json
permissions: "0755"
owner: root
content: !!binary |
%s`, encodedNBCJson)
customDataYAML := fmt.Sprintf(scriptlessCustomDataTemplate, encodedNBCJson)
return base64.StdEncoding.EncodeToString([]byte(customDataYAML)), nil
}

Expand Down
Loading
Loading