Skip to content

feat(anc): initialize Azure cloud natively in init-cloud for AKSNodeConfig - #10262

Closed
Abigail Liang (abigailliang-aks-sig-node) wants to merge 5 commits into
devfrom
pr-10252
Closed

Abigail Liang (abigailliang-aks-sig-node) wants to merge 5 commits into
devfrom
pr-10252

Conversation

@abigailliang-aks-sig-node

Copy link
Copy Markdown
Contributor

Summary

AKS Node Controller now initializes Azure cloud natively in Go for AKSNodeConfig (instead of shelling out). NBC paths remain unchanged.

Two-Path Design

`init-cloud` splits based on input:

  • AKSNodeConfig (`--provision-config`): Go implementation
  • NBC (`--nbc-cmd`): Shell script (unchanged)

Both install certificates → configure repos → schedule refresh → write marker.

On failure: No marker → launcher skips hotfix → CSE retries (graceful fallback).

What Changed

  • Split `cloudInitializationSettings()` into two functions:
    • `nativeCloudInitConfig()`: Parse AKSNodeConfig
    • `nbcCloudInitializationSettings()`: Parse NBC command
  • Added Go implementation: certificate installation, repo config, refresh scheduling
  • Full test coverage

Impact

Phase 3 no longer shells out for cloud init. Cleaner separation: AKSNodeConfig in Go, NBC in shell.

…onfig

The VHD launcher runs init-cloud before acquiring an ANC hotfix (#10066),
so custom and sovereign clouds can reach RepoDepot. When ANC provisions
from AKSNodeConfig alone (no --nbc-cmd, e.g. Phase 3), init-cloud now
installs Azure cloud certificates, configures RepoDepot repositories and
schedules certificate refresh in Go, in the shell's order, instead of
running init-aks-cloud.sh. It then writes the existing empty marker so
provisioning skips the shell.

Legacy CSE, Phase 1 and NBC provisioning (Phase 2/2.5) keep the shell
initializer unchanged. If native initialization fails, no marker is
written, the launcher skips hotfix acquisition and provisioning runs
init-aks-cloud.sh as before.

Re-running initialization after a hotfix that changes it is left to
follow-up changes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 27252e94-5b2b-4932-9585-70e98b9e21e4
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Mariner removal flattened these tests so the err from os.Stat shadowed the one in the repository loop, which govet shadow reports.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Scriptless nodes on VHDs that include the native cloud initialization run it
through aks-node-controller instead of init-aks-cloud.sh. The native path
logs different messages and installs the certificate refresh cron entry as
refresh-cloud-certificates rather than ca-refresh, so the RCV1P validators,
which matched only the shell output, failed even though certificates were
installed and refresh was scheduled.

Accept either implementation's output for the endpoint mode, opt-in and
not-opted-in log checks and for the refresh cron entry. NBC and older VHDs
still run init-aks-cloud.sh, so the shell output must keep passing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 27252e94-5b2b-4932-9585-70e98b9e21e4
Reduce verbosity while preserving key behavioral details:
- Replace 70+ lines of implementation minutiae with ~12 lines of core concepts
- Clarify the two-path design: AKSNodeConfig (Go) vs NBC (shell)
- Consolidate certificate, refresh, and repository handling descriptions
- Maintain technical accuracy while improving readability

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unguarded Unix syscalls prevent ANC from compiling on Windows. Separately, Ubuntu’s default cron PATH prevents the daily trust-bundle refresh; the APT directory check rejects usable repositories that return 403, causing hotfix acquisition to be skipped; and the two-minute timeout kills valid longer-running cache updates, potentially exhausting initialization’s deadline. Successful commands other than dnf also discard stderr, hiding repository-fetch failures and certificate warnings.

7 open issues
What changed in this PR

Moves AKSNodeConfig cloud initialization into ANC’s native Go implementation while preserving NBC’s shell path.

Changes:

  • Adds certificate installation, repository configuration, scheduled refresh, and event logging.
  • Separates initialization paths and adds a certificate-refresh command.
  • Adds Go tests and updates E2E validation and documentation.
File Description
e2e/​scenario/​validators.go Accepts shell and native initialization output.
aks-node-controller/​README.md Documents native initialization and refresh.
aks-node-controller/​cloud_test_helpers_test.go Adds shared cloud test fixtures.
aks-node-controller/​cloud_runtime.go Adds command, HTTP, and file helpers.
aks-node-controller/​cloud_runtime_test.go Tests runtime helpers and cancellation.
aks-node-controller/​cloud_runtime_events_test.go Tests operation event logging.
aks-node-controller/​cloud_repositories.go Configures Ubuntu and Azure Linux repositories.
aks-node-controller/​cloud_repositories_test.go Tests validation and cache retries.
aks-node-controller/​cloud_repositories_integration_test.go Tests repository initialization flow.
aks-node-controller/​cloud_repositories_configuration_test.go Tests generated repository configuration.
aks-node-controller/​cloud_refresh.go Implements certificate-refresh execution.
aks-node-controller/​cloud_refresh_test.go Tests refresh arguments and location normalization.
aks-node-controller/​cloud_refresh_schedule.go Installs cron jobs and systemd timers.
aks-node-controller/​cloud_refresh_schedule_test.go Tests refresh scheduling and failures.
aks-node-controller/​cloud_init.go Separates native and NBC initialization.
aks-node-controller/​cloud_init_test.go Tests initialization paths and marker behavior.
aks-node-controller/​cloud_certificates.go Selects certificate modes and checks opt-in.
aks-node-controller/​cloud_certificates_test.go Tests certificate refresh behavior across platforms.
aks-node-controller/​cloud_certificate_transport.go Retrieves certificate manifests and payloads.
aks-node-controller/​cloud_certificate_transport_test.go Tests retries, truncation, and redirects.
aks-node-controller/​cloud_certificate_transport_json_test.go Tests manifest JSON parsing.
aks-node-controller/​cloud_certificate_transport_behavior_test.go Tests transport compatibility with shell behavior.
aks-node-controller/​cloud_certificate_store.go Installs certificates and logs public PEMs.
aks-node-controller/​cloud_certificate_store_test.go Tests Ubuntu bundle symlink handling.
aks-node-controller/​cloud_certificate_store_behavior_test.go Tests trust-store installation and diagnostics.
aks-node-controller/​app.go Registers refresh command and test hooks.

Review effort: Max

Comment on lines +147 to +149
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
cmd.Cancel = func() error {
err := syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)
}
lines = append(lines, line)
}
lines = append(lines, "0 19 * * * "+command)
Comment on lines +118 to +121
microsoftSource := endpoint + "/microsoft/ubuntu/" + platform.Version + "/prod"
if _, err := c.repositoryGET(ctx, microsoftSource); err != nil {
return fmt.Errorf("check Ubuntu Microsoft repository: %w", err)
}
Comment on lines +144 to +145
ctx, cancel := context.WithTimeout(ctx, cloudCommandTimeout)
defer cancel()
Comment on lines +168 to +172
if name == "dnf" {
// DNF can report unavailable repositories on stderr despite exiting zero.
_, _ = stdout.Write(stderr.Bytes())
}
return stdout.Bytes(), nil
}
}

func TestCloudCertificateOptInNonTrueResponsesSkip(t *testing.T) {
"github.com/Azure/agentbaker/aks-node-controller/config"
)

func TestCloudUbuntuRepositoryConfiguration(t *testing.T) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants