Skip to content

Commit

Permalink
merge with dev
Browse files Browse the repository at this point in the history
  • Loading branch information
r2k1 committed Nov 3, 2024
2 parents 48ba334 + 654ed86 commit b86f84b
Show file tree
Hide file tree
Showing 40 changed files with 87 additions and 131 deletions.
45 changes: 0 additions & 45 deletions .github/workflows/golangci-lint-pr.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
branches:
- master
- main
pull_request:
branches:
- master
- main

permissions:
contents: read
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,11 @@ endif
ginkgoBuild: generate
make -C ./test/e2e ginkgo-build

test: test-node-bootstrapper
test: test-aks-node-controller
go test ./...

test-node-bootstrapper:
pushd node-bootstrapper && go test ./... && popd
test-aks-node-controller:
pushd aks-node-controller && go test ./... && popd

.PHONY: test-style
test-style: validate-go validate-shell validate-copyright-headers
Expand Down
1 change: 1 addition & 0 deletions aks-node-controller/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
aks-node-controller
8 changes: 4 additions & 4 deletions node-bootstrapper/app.go → aks-node-controller/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"os"
"os/exec"

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

Expand All @@ -31,13 +31,13 @@ type ProvisionFlags struct {
}

func (a *App) Run(ctx context.Context, args []string) int {
slog.Info("node-bootstrapper started")
slog.Info("aks-node-controller started")
err := a.run(ctx, args)
exitCode := errToExitCode(err)
if exitCode == 0 {
slog.Info("node-bootstrapper finished successfully")
slog.Info("aks-node-controller finished successfully")
} else {
slog.Error("node-bootstrapper failed", "error", err)
slog.Error("aks-node-controller failed", "error", err)
}
return exitCode
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ func TestApp_Run(t *testing.T) {
}{
{
name: "missing command argument",
args: []string{"node-bootstrapper"},
args: []string{"aks-node-controller"},
wantExit: 1,
},
{
name: "unknown command",
args: []string{"node-bootstrapper", "unknown"},
args: []string{"aks-node-controller", "unknown"},
wantExit: 1,
},
{
Expand All @@ -58,7 +58,7 @@ func TestApp_Run(t *testing.T) {
},
{
name: "provision command with valid flag",
args: []string{"node-bootstrapper", "provision", "--provision-config=parser/testdata/test_nbc.json"},
args: []string{"aks-node-controller", "provision", "--provision-config=parser/testdata/test_nbc.json"},
setupMocks: func(mc *MockCmdRunner) {
mc.RunFunc = func(cmd *exec.Cmd) error {
return nil
Expand All @@ -68,7 +68,7 @@ func TestApp_Run(t *testing.T) {
},
{
name: "provision command with command runner error",
args: []string{"node-bootstrapper", "provision", "--provision-config=parser/testdata/test_nbc.json"},
args: []string{"aks-node-controller", "provision", "--provision-config=parser/testdata/test_nbc.json"},
setupMocks: func(mc *MockCmdRunner) {
mc.RunFunc = func(cmd *exec.Cmd) error {
return &ExitError{Code: 666}
Expand Down
2 changes: 1 addition & 1 deletion node-bootstrapper/go.mod → aks-node-controller/go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/Azure/agentbaker/node-bootstrapper
module github.com/Azure/agentbaker/aks-node-controller

go 1.22.2

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion node-bootstrapper/main.go → aks-node-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// 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/node-bootstrapper.log"
LogFile = "/var/log/azure/aks-node-controller.log"
)

func main() {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"strings"
"testing"

"github.com/Azure/agentbaker/node-bootstrapper/parser"
"github.com/Azure/agentbaker/aks-node-controller/parser"
"github.com/Azure/agentbaker/pkg/agent/datamodel"
aksnodeconfigv1 "github.com/Azure/agentbaker/pkg/proto/aksnodeconfig/v1"
"github.com/Azure/go-autorest/autorest/to"
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion e2e/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type Configuration struct {
KeepVMSS bool `env:"KEEP_VMSS"`
BlobStorageAccountPrefix string `env:"BLOB_STORAGE_ACCOUNT_PREFIX" envDefault:"abe2e"`
BlobContainer string `env:"BLOB_CONTAINER" envDefault:"abe2e"`
EnableNodeBootstrapperTest bool `env:"ENABLE_NODE_BOOTSTRAPPER_TEST"`
EnableAKSNodeControllerTest bool `env:"ENABLE_AKS_NODE_CONTROLLER_TEST"`
}

func (c *Configuration) BlobStorageAccount() string {
Expand Down
2 changes: 1 addition & 1 deletion e2e/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func extractLogsFromVM(ctx context.Context, t *testing.T, vmssName, privateIP, s
"kubelet": "journalctl -u kubelet",
"cluster-provision-cse-output": "cat /var/log/azure/cluster-provision-cse-output.log",
"sysctl-out": "sysctl -a",
"node-bootstrapper": "cat /var/log/azure/node-bootstrapper.log",
"aks-node-controller": "cat /var/log/azure/aks-node-controller.log",
}

podName, err := getHostNetworkDebugPodName(ctx, cluster.Kube, t)
Expand Down
38 changes: 19 additions & 19 deletions e2e/node_bootstrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,31 @@ import (
"github.com/stretchr/testify/require"
)

// test node-bootstrapper binary without rebuilding VHD images.
// it compiles the node-bootstrapper binary and uploads it to Azure Storage.
// test aks-node-controller binary without rebuilding VHD images.
// it compiles the aks-node-controller binary and uploads it to Azure Storage.
// the binary is then downloaded and executed on the VM
// the test results are unreliable, as there can be a version mismatch between the binary and the rest content of VHD image
// it's intended to be used for quick testing without rebuilding VHD images
// mostly executed locally
func Test_ubuntu2204NodeBootstrapper(t *testing.T) {
func Test_ubuntu2204AKSNodeController(t *testing.T) {
ctx := newTestCtx(t)
if !config.Config.EnableNodeBootstrapperTest {
t.Skip("ENABLE_NODE_BOOTSTRAPPER_TEST is not set")
if !config.Config.EnableAKSNodeControllerTest {
t.Skip("ENABLE_AKS_NODE_CONTROLLER_TEST is not set")
}
// TODO: figure out how to properly parallelize test, maybe move t.Parallel to the top of each test?
cluster, err := ClusterKubenet(ctx, t)
require.NoError(t, err)
t.Cleanup(func() {
log, err := os.ReadFile("./scenario-logs/" + t.Name() + "/node-bootstrapper.stdout.txt")
log, err := os.ReadFile("./scenario-logs/" + t.Name() + "/aks-node-controller.stdout.txt")
if err != nil {
t.Logf("failed to read node-bootstrapper log: %v", err)
t.Logf("failed to read aks-node-controller log: %v", err)
}
t.Logf("node-bootstrapper log: %s", string(log))
t.Logf("aks-node-controller log: %s", string(log))
})
identity, err := config.Azure.CreateVMManagedIdentity(ctx)
require.NoError(t, err)
binary := compileNodeBootstrapper(t)
url, err := config.Azure.UploadAndGetLink(ctx, time.Now().Format("2006-01-02-15-04-05")+"/node-bootstrapper", binary)
binary := compileAKSNodeController(t)
url, err := config.Azure.UploadAndGetLink(ctx, time.Now().Format("2006-01-02-15-04-05")+"/aks-node-controller", binary)
require.NoError(t, err)

RunScenario(t, &Scenario{
Expand Down Expand Up @@ -72,7 +72,7 @@ func Test_ubuntu2204NodeBootstrapper(t *testing.T) {
Settings: map[string]any{},
ProtectedSettings: map[string]any{
"fileUris": []string{url},
"commandToExecute": CSENodeBootstrapper(t, cluster),
"commandToExecute": CSEAKSNodeController(t, cluster),
"managedIdentity": map[string]any{
"clientId": identity,
},
Expand All @@ -85,14 +85,14 @@ func Test_ubuntu2204NodeBootstrapper(t *testing.T) {
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"),
FileHasContentsValidator("/var/log/azure/aks-node-controller.log", "aks-node-controller finished successfully"),
},
AKSNodeConfigMutator: func(config *aksnodeconfigv1.Configuration) {},
},
})
}

func CSENodeBootstrapper(t *testing.T, cluster *Cluster) string {
func CSEAKSNodeController(t *testing.T, cluster *Cluster) string {
nbcAny, err := deepcopy.Anything(cluster.NodeBootstrappingConfiguration)
require.NoError(t, err)
nbc := nbcAny.(*datamodel.NodeBootstrappingConfiguration)
Expand All @@ -103,21 +103,21 @@ func CSENodeBootstrapper(t *testing.T, cluster *Cluster) string {
configJSON, err := json.Marshal(configContent)
require.NoError(t, err)

return fmt.Sprintf(`sh -c "(mkdir -p /etc/node-bootstrapper && echo '%s' | base64 -d > /etc/node-bootstrapper/config.json && ./node-bootstrapper provision --provision-config=/etc/node-bootstrapper/config.json)"`, base64.StdEncoding.EncodeToString(configJSON))
return fmt.Sprintf(`sh -c "(mkdir -p /etc/aks-node-controller && echo '%s' | base64 -d > /etc/aks-node-controller/config.json && ./aks-node-controller provision --provision-config=/etc/aks-node-controller/config.json)"`, base64.StdEncoding.EncodeToString(configJSON))
}

func compileNodeBootstrapper(t *testing.T) *os.File {
cmd := exec.Command("go", "build", "-o", "node-bootstrapper", "-v")
cmd.Dir = filepath.Join("..", "node-bootstrapper")
func compileAKSNodeController(t *testing.T) *os.File {
cmd := exec.Command("go", "build", "-o", "aks-node-controller", "-v")
cmd.Dir = filepath.Join("..", "aks-node-controller")
cmd.Env = append(os.Environ(),
"CGO_ENABLED=0",
"GOOS=linux",
"GOARCH=amd64",
)
log, err := cmd.CombinedOutput()
require.NoError(t, err, string(log))
t.Logf("Compiled node-bootstrapper")
f, err := os.Open(filepath.Join("..", "node-bootstrapper", "node-bootstrapper"))
t.Logf("Compiled aks-node-controller")
f, err := os.Open(filepath.Join("..", "aks-node-controller", "aks-node-controller"))
require.NoError(t, err)
return f
}
2 changes: 1 addition & 1 deletion e2e/scenario_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ func Test_ubuntu2204ScriptlessInstaller(t *testing.T) {
Cluster: ClusterKubenet,
VHD: config.VHDUbuntu2204Gen2Containerd,
LiveVMValidators: []*LiveVMValidator{
FileHasContentsValidator("/var/log/azure/node-bootstrapper.log", "node-bootstrapper finished successfully"),
FileHasContentsValidator("/var/log/azure/aks-node-controller.log", "aks-node-controller finished successfully"),
},
AKSNodeConfigMutator: func(config *aksnodeconfigv1.Configuration) {},
},
Expand Down
2 changes: 1 addition & 1 deletion e2e/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func leakedSecretsValidators(scenario *Scenario) []*LiveVMValidator {
}

validators := make([]*LiveVMValidator, 0)
for _, logFile := range []string{"/var/log/azure/cluster-provision.log", "/var/log/azure/node-bootstrapper.log"} {
for _, logFile := range []string{"/var/log/azure/cluster-provision.log", "/var/log/azure/aks-node-controller.log"} {
for secretName, secretValue := range secrets {
validators = append(validators, FileExcludesContentsValidator(logFile, secretValue, secretName))
}
Expand Down
1 change: 0 additions & 1 deletion node-bootstrapper/.gitignore

This file was deleted.

14 changes: 6 additions & 8 deletions packer.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ifeq (${ARCHITECTURE},ARM64)
GOARCH=arm64
endif

build-packer: generate-prefetch-scripts build-node-bootstrapper build-lister-binary
build-packer: generate-prefetch-scripts build-aks-node-controller build-lister-binary
ifeq (${ARCHITECTURE},ARM64)
@echo "${MODE}: Building with Hyper-v generation 2 ARM64 VM"
ifeq (${OS_SKU},Ubuntu)
Expand Down Expand Up @@ -112,14 +112,12 @@ ifeq (${MODE},linuxVhdMode)
@bash -c "pushd vhdbuilder/prefetch; go run cmd/main.go --components-path=../../parts/linux/cloud-init/artifacts/components.json --output-path=../packer/prefetch.sh || exit 1; popd"
endif

build-node-bootstrapper:
@echo "Building node bootstrapper binaries"
@bash -c "pushd node-bootstrapper && \
build-aks-node-controller:
@echo "Building aks-node-controller binaries"
@bash -c "pushd aks-node-controller && \
go test ./... && \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/node-bootstrapper-linux-amd64 && \
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o bin/node-bootstrapper-linux-arm64 && \
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o bin/node-bootstrapper-windows-amd64.exe && \
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -o bin/node-bootstrapper-windows-arm64.exe && \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/aks-node-controller-linux-amd64 && \
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o bin/aks-node-controller-linux-arm64 && \
popd"

build-lister-binary:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Wants=cloud-init.target

[Service]
Type=oneshot
ExecStart=/opt/azure/containers/node-bootstrapper provision --provision-config=/opt/azure/containers/node-bootstrapper-config.json
ExecStart=/opt/azure/containers/aks-node-controller provision --provision-config=/opt/azure/containers/aks-node-controller-config.json
RemainAfterExit=No

[Install]
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/bakerapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func getScriptlessCustomDataContent(config any) (string, error) {
encodedNBCJson := base64.StdEncoding.EncodeToString(nbcJSON)
customDataYAML := fmt.Sprintf(`#cloud-config
write_files:
- path: /opt/azure/containers/node-bootstrapper-config.json
- path: /opt/azure/containers/aks-node-controller-config.json
permissions: "0755"
owner: root
content: !!binary |
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/datamodel/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1744,7 +1744,7 @@ type NodeBootstrappingConfiguration struct {
// our added rule is overwritten by Cilium.
InsertIMDSRestrictionRuleToMangleTable bool

// Version is required for node-bootstrapper application to determine the version of the config file.
// Version is required for aks-node-controller application to determine the version of the config file.
Version string
}

Expand Down
1 change: 0 additions & 1 deletion pkg/proto/aksnodeconfig/v1/const.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package aksnodeconfigv1

const (
// Follow the semantic versioning format. <Major>.<Minor>.<Patch> //nolint: godot // no period is required after patch.
contractVersion = "v0"
)

Expand Down
16 changes: 8 additions & 8 deletions vhdbuilder/packer/packer_source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ copyPackerFiles() {
VHD_CLEANUP_SCRIPT_DEST=/opt/azure/containers/cleanup-vhd.sh
CONTAINER_IMAGE_PREFETCH_SCRIPT_SRC=/home/packer/prefetch.sh
CONTAINER_IMAGE_PREFETCH_SCRIPT_DEST=/opt/azure/containers/prefetch.sh
NODE_BOOTSTRAPPER_SRC=/home/packer/node-bootstrapper
NODE_BOOTSTRAPPER_DEST=/opt/azure/node-bootstrapper
AKS_NODE_CONTROLLER_SRC=/home/packer/aks-node-controller
AKS_NODE_CONTROLLER_DEST=/opt/azure/aks-node-controller

CSE_REDACT_SRC=/home/packer/cse_redact_cloud_config.py
CSE_REDACT_DEST=/opt/azure/containers/provision_redact_cloud_config.py
Expand Down Expand Up @@ -246,13 +246,13 @@ copyPackerFiles() {
CSE_HELPERS_DISTRO_DEST=/opt/azure/containers/provision_source_distro.sh
cpAndMode $CSE_HELPERS_DISTRO_SRC $CSE_HELPERS_DISTRO_DEST 0744

NODE_BOOTSTRAPPER_SRC=/home/packer/node-bootstrapper
NODE_BOOTSTRAPPER_DEST=/opt/azure/containers/node-bootstrapper
cpAndMode $NODE_BOOTSTRAPPER_SRC $NODE_BOOTSTRAPPER_DEST 755
AKS_NODE_CONTROLLER_SRC=/home/packer/aks-node-controller
AKS_NODE_CONTROLLER_DEST=/opt/azure/containers/aks-node-controller
cpAndMode $AKS_NODE_CONTROLLER_SRC $AKS_NODE_CONTROLLER_DEST 755

NODE_BOOTSTRAPPER_SERVICE_SRC=/home/packer/bootstrap.service
NODE_BOOTSTRAPPER_SERVICE_DEST=/etc/systemd/system/bootstrap.service
cpAndMode $NODE_BOOTSTRAPPER_SERVICE_SRC $NODE_BOOTSTRAPPER_SERVICE_DEST 0644
AKS_NODE_CONTROLLER_SERVICE_SRC=/home/packer/aks-node-controller.service
AKS_NODE_CONTROLLER_SERVICE_DEST=/etc/systemd/system/aks-node-controller.service
cpAndMode $AKS_NODE_CONTROLLER_SERVICE_SRC $AKS_NODE_CONTROLLER_SERVICE_DEST 0644

NOTICE_SRC=/home/packer/NOTICE.txt
NOTICE_DEST=/NOTICE.txt
Expand Down
4 changes: 2 additions & 2 deletions vhdbuilder/packer/pre-install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ capture_benchmark "${SCRIPT_NAME}_enable_modified_log_rotate_service"
systemctlEnableAndStart sync-container-logs.service || exit 1
capture_benchmark "${SCRIPT_NAME}_sync_container_logs"

# enable bootstrap.service
systemctl enable bootstrap.service
# enable aks-node-controller.service
systemctl enable aks-node-controller.service

# First handle Mariner + FIPS
if isMarinerOrAzureLinux "$OS"; then
Expand Down
Loading

0 comments on commit b86f84b

Please sign in to comment.