Skip to content

Commit

Permalink
simplify VM creation
Browse files Browse the repository at this point in the history
  • Loading branch information
r2k1 committed Oct 29, 2024
1 parent 4736745 commit 777c874
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 17 deletions.
28 changes: 26 additions & 2 deletions e2e/node_bootstrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
"github.com/Azure/agentbaker/pkg/agent/datamodel"
nbcontractv1 "github.com/Azure/agentbaker/pkg/proto/nbcontract/v1"
"github.com/Azure/agentbakere2e/config"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
"github.com/barkimedes/go-deepcopy"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -48,13 +50,35 @@ func Test_ubuntu2204NodeBootstrapper(t *testing.T) {
//NodeBootstrappingType: Scriptless,
Cluster: ClusterKubenet,
VHD: config.VHDUbuntu2204Gen2Containerd,
VMConfigMutator: func(model *armcompute.VirtualMachineScaleSet) {
model.Properties.VirtualMachineProfile.OSProfile.CustomData = nil
model.Properties.VirtualMachineProfile.ExtensionProfile = &armcompute.VirtualMachineScaleSetExtensionProfile{
Extensions: []*armcompute.VirtualMachineScaleSetExtension{
{
Name: to.Ptr("vmssCSE"),
Properties: &armcompute.VirtualMachineScaleSetExtensionProperties{
Publisher: to.Ptr("Microsoft.Azure.Extensions"),
Type: to.Ptr("CustomScript"),
TypeHandlerVersion: to.Ptr("2.0"),
AutoUpgradeMinorVersion: to.Ptr(true),
Settings: map[string]any{},
ProtectedSettings: map[string]any{
//"fileUris": []string{},
"commandToExecute": CSENodeBootstrapper(ctx, t, cluster),
//"managedIdentity": map[string]any{
// "objectId": "",
//},
},
},
},
},
}
},
LiveVMValidators: []*LiveVMValidator{
mobyComponentVersionValidator("containerd", getExpectedPackageVersions("containerd", "ubuntu", "r2204")[0], "apt"),
mobyComponentVersionValidator("runc", getExpectedPackageVersions("runc", "ubuntu", "r2204")[0], "apt"),
FileHasContentsValidator("/var/log/azure/node-bootstrapper.log", "node-bootstrapper finished successfully"),
},
CSEOverride: CSENodeBootstrapper(ctx, t, cluster),
DisableCustomData: true,
AKSNodeConfigMutator: func(config *nbcontractv1.Configuration) {},
},
})
Expand Down
4 changes: 1 addition & 3 deletions e2e/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,7 @@ type Config struct {

// LiveVMValidators is a slice of LiveVMValidator objects for performing any live VM validation
// specific to the scenario that isn't covered in the set of common validators run with all scenarios
LiveVMValidators []*LiveVMValidator
CSEOverride string
DisableCustomData bool
LiveVMValidators []*LiveVMValidator
}

// VMCommandOutputAsserterFn is a function which takes in stdout and stderr stream content
Expand Down
11 changes: 1 addition & 10 deletions e2e/vmss.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,7 @@ func createVMSS(ctx context.Context, t *testing.T, vmssName string, scenario *Sc
require.NoError(t, err)
}

cse := nodeBootstrapping.CSE
if scenario.CSEOverride != "" {
cse = scenario.CSEOverride
}
customData := nodeBootstrapping.CustomData
if scenario.DisableCustomData {
customData = ""
}

model := getBaseVMSSModel(vmssName, string(publicKeyBytes), customData, cse, cluster)
model := getBaseVMSSModel(vmssName, string(publicKeyBytes), nodeBootstrapping.CustomData, nodeBootstrapping.CSE, cluster)

isAzureCNI, err := cluster.IsAzureCNI()
require.NoError(t, err, "checking if cluster is using Azure CNI")
Expand Down
3 changes: 2 additions & 1 deletion node-bootstrapper/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ type ProvisionFlags struct {
}

func (a *App) Run(ctx context.Context, args []string) int {
slog.Info("node-bootstrapper started")
err := a.run(ctx, args)
exitCode := errToExitCode(err)
if exitCode == 0 {
slog.Info("node-bootstrapper finished")
slog.Info("node-bootstrapper finished successfully")
} else {
slog.Error("node-bootstrapper failed", "error", err)
}
Expand Down
1 change: 0 additions & 1 deletion node-bootstrapper/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ func main() {

logger := slog.New(slog.NewJSONHandler(logFile, nil))
slog.SetDefault(logger)
slog.Info("node-bootstrapper started")

app := App{cmdRunner: cmdRunner}
exitCode := app.Run(context.Background(), os.Args)
Expand Down

0 comments on commit 777c874

Please sign in to comment.