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

Rename node-bootstrapper => aks-node-controller #5191

Merged
merged 5 commits into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
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"
nbcontractv1 "github.com/Azure/agentbaker/pkg/proto/nbcontract/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.
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
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"
nbcontractv1 "github.com/Azure/agentbaker/pkg/proto/nbcontract/v1"
"github.com/Azure/go-autorest/autorest/to"
Expand Down
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 *nbcontractv1.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 *nbcontractv1.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
2 changes: 1 addition & 1 deletion parts/linux/cloud-init/artifacts/bootstrap.service
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
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/bootstrap.service
Copy link
Collaborator

@cameronmeissner cameronmeissner Oct 31, 2024

Choose a reason for hiding this comment

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

im okay either way, but should we rename bootstrap.service to aks-node-controller.service as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. It's confused me before.

I think it's nice to make the relationship clear. It's unlikely we will need to change insides to another binary without renaming it.

AKS_NODE_CONTROLLER_SERVICE_DEST=/etc/systemd/system/bootstrap.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
18 changes: 9 additions & 9 deletions vhdbuilder/packer/test/linux-vhd-content-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -964,19 +964,19 @@ testBccTools () {
return 0
}

testNodeBootstrapperBinary () {
local test="testNodeBootstrapperBinary"
local go_binary_path="/opt/azure/containers/node-bootstrapper"
testAKSNodeControllerBinary () {
local test="testAKSNodeControllerBinary"
local go_binary_path="/opt/azure/containers/aks-node-controller"

echo "$test: checking existence of node-bootstrapper go binary at $go_binary_path"
echo "$test: checking existence of aks-node-controller go binary at $go_binary_path"
if [ ! -f "$go_binary_path" ]; then
err "$test: node-bootstrapper go binary does not exist at $go_binary_path"
err "$test: aks-node-controller go binary does not exist at $go_binary_path"
return 1
fi
echo "$test: node-bootstrapper go binary exists at $go_binary_path"
echo "$test: aks-node-controller go binary exists at $go_binary_path"
}

testNodeBootstrapperService() {
testAKSNodeControllerService() {
local test="testNBCParserService"
local service_name="bootstrap.service"
echo "$test:Start"
Expand Down Expand Up @@ -1098,5 +1098,5 @@ testPamDSettings $OS_SKU $OS_VERSION
testPam $OS_SKU $OS_VERSION
testUmaskSettings
testContainerImagePrefetchScript
testNodeBootstrapperBinary
testNodeBootstrapperService
testAKSNodeControllerBinary
testAKSNodeControllerService
4 changes: 2 additions & 2 deletions vhdbuilder/packer/vhd-image-builder-arm64-gen2.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
},
{
"type": "file",
"source": "node-bootstrapper/bin/node-bootstrapper-linux-arm64",
"destination": "/home/packer/node-bootstrapper"
"source": "aks-node-controller/bin/aks-node-controller-linux-arm64",
"destination": "/home/packer/aks-node-controller"
},
{
"type": "file",
Expand Down
4 changes: 2 additions & 2 deletions vhdbuilder/packer/vhd-image-builder-base.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@
},
{
"type": "file",
"source": "node-bootstrapper/bin/node-bootstrapper-linux-amd64",
"destination": "/home/packer/node-bootstrapper"
"source": "aks-node-controller/bin/aks-node-controller-linux-amd64",
"destination": "/home/packer/aks-node-controller"
},
{
"type": "file",
Expand Down
4 changes: 2 additions & 2 deletions vhdbuilder/packer/vhd-image-builder-mariner-arm64.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@
},
{
"type": "file",
"source": "node-bootstrapper/bin/node-bootstrapper-linux-arm64",
"destination": "/home/packer/node-bootstrapper"
"source": "aks-node-controller/bin/aks-node-controller-linux-arm64",
"destination": "/home/packer/aks-node-controller"
},
{
"type": "file",
Expand Down
4 changes: 2 additions & 2 deletions vhdbuilder/packer/vhd-image-builder-mariner.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@
},
{
"type": "file",
"source": "node-bootstrapper/bin/node-bootstrapper-linux-amd64",
"destination": "/home/packer/node-bootstrapper"
"source": "aks-node-controller/bin/aks-node-controller-linux-amd64",
"destination": "/home/packer/aks-node-controller"
},
{
"type": "file",
Expand Down
Loading