local

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2026 License: MIT Imports: 8 Imported by: 0

README

Local AKS Machine Backend

This package provides a file-backed implementation of aksmachine.MachineClient for e2e tests.

It is not a production AKS RP or ARM implementation. Production code should use an SDK-backed client once the AKS machine ARM contract is available in the public Azure SDK. This local backend exists so e2e tests can simulate AKS RP machine goal-state changes by mutating a JSON file on disk.

Purpose

The local backend lets tests validate agent behavior without depending on a live AKS RP endpoint.

It supports:

  • Creating a local machine JSON file with a desired Kubernetes version and settings version.
  • Reading the current local machine representation.
  • Patching machine status.
  • Simulating machine deletion by deleting the file.

When the file does not exist, Get returns *aksmachine.NotFoundError. This matches the reset/delete design where the agent treats a missing machine representation as an ARM 404 equivalent.

File Format

The file stores the local aksmachine.Machine JSON shape:

{
  "id": "local-test-machine",
  "goal": {
    "kubernetesVersion": "1.34.0",
    "settingsVersion": "42"
  },
  "status": {
    "provisioningState": "Succeeded",
    "observedSettingsVersion": "42",
    "message": ""
  }
}

The local backend always uses local-test-machine as the resource ID when creating the file.

CLI Usage

Use the dedicated e2e helper binary, not the main aks-flex-node binary.

Build it with:

make build-e2ehelper

Create or replace the local machine goal state:

./e2ehelper local-machine create \
  --path /tmp/aks-machine.json \
  --kubernetes-version 1.34.0 \
  --settings-version 42

Read the current machine file:

./e2ehelper local-machine get --path /tmp/aks-machine.json

Patch status:

./e2ehelper local-machine status \
  --path /tmp/aks-machine.json \
  --provisioning-state Succeeded \
  --observed-settings-version 42 \
  --message "applied"

Delete the local machine representation:

./e2ehelper local-machine delete --path /tmp/aks-machine.json

E2E Pattern

An e2e test can point the agent at this file-backed client, then trigger control-plane-like changes by mutating the file:

  • Upgrade/reimage/rollback: update goal.kubernetesVersion and goal.settingsVersion, then trigger the Kubernetes node signal used by the scenario.
  • Reset/delete: delete the file to simulate the ARM machine 404, then trigger the Kubernetes node annotation used by the scenario.

The backend writes JSON atomically through utilio.WriteFile, but e2e tests may also directly overwrite or delete the file when simulating external AKS RP behavior.

Documentation

Index

Constants

View Source
const E2EMachineFilePath = "/run/aks-flex-node/e2e-machine.json"

E2EMachineFilePath is the well-known local machine file used by e2e daemon mode and by e2ehelper when simulating AKS RP machine changes.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client implements aksmachine.MachineClient with a JSON file. It is intended for e2e tests that simulate AKS RP by mutating local disk state.

func NewClient

func NewClient(path string) (*Client, error)

func (*Client) Create

func (c *Client) Create(_ context.Context, desired aksmachine.GoalState) (*aksmachine.Machine, error)

func (*Client) Get

func (*Client) PatchStatus

func (c *Client) PatchStatus(_ context.Context, status aksmachine.Status) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL