Skip to main content
Version: v1.1

Unit Configuration

Introduction

This page is the reference for the cloud-managed Unit configuration document. The Unit configuration is a versioned JSON file pushed from AosCloud to the Communication Manager, defining per-Node operational policies such as alert thresholds, resource allocation ratios, labels, and scheduling priority.

For an architectural explanation of how the CM loads, validates, and distributes this configuration, see CM Unit Configuration.

JSON Schema

The Unit configuration is a JSON object with three top-level fields:

{
"formatVersion": "7",
"version": "2.0.0",
"nodes": [
{ /* per-node configuration entry */ }
]
}

Top-Level Fields

FieldTypeRequiredDescription
formatVersionstringYesSchema version of the configuration format. Identifies which fields and structure the document uses.
versionstringYesSemantic version of this configuration instance. Used for update ordering — each update must have a strictly higher version than the currently installed one.
nodesarrayNoArray of per-Node configuration objects. If omitted or empty, no Node-specific policies are applied.

Node Configuration Entry

Each element in the nodes array defines configuration for a specific Node or Node type:

{
"version": "1.0.0",
"node": {
"codename": "node-1"
},
"nodeGroupSubject": {
"codename": "mainType"
},
"alertRules": { },
"resourceRatios": { },
"labels": ["mainNode"],
"priority": 1
}
FieldTypeRequiredDefaultDescription
nodeGroupSubjectobjectYesIdentifies the Node type (group) this entry applies to. Must contain a codename string field.
nodeobjectNoIdentifies a specific Node by ID. Contains a codename string field matching the Node's ID. When present, this entry takes precedence over type-based matching.
versionstringNo""Per-Node configuration version string.
alertRulesobjectNoNot setAlert threshold definitions for monitoring on this Node. See Alert Rules.
resourceRatiosobjectNoNot setResource allocation ratios for service scheduling. See Resource Ratios.
labelsarray of stringsNo[]Labels assigned to this Node for scheduling and identification purposes.
priorityinteger (uint64)No0Node priority for service placement. Higher values indicate higher priority.

Identity Fields

The node and nodeGroupSubject fields use the same structure — an object with a codename field:

{
"codename": "identifier-string"
}
  • node.codename — matches the Node's unique ID within the Unit
  • nodeGroupSubject.codename — matches the Node's type classification

Alert Rules

The alertRules object defines monitoring thresholds that trigger alerts when resource usage crosses defined boundaries. All fields are optional — only the rules you define are active.

{
"alertRules": {
"ram": {
"minTimeout": "PT1S",
"minThreshold": 0.1,
"maxThreshold": 0.9
},
"cpu": {
"minTimeout": "PT2S",
"minThreshold": 0.3,
"maxThreshold": 0.8
},
"partitions": [
{
"name": "services",
"minTimeout": "PT3S",
"minThreshold": 0.5,
"maxThreshold": 0.9
}
],
"download": {
"minTimeout": "PT5S",
"minThreshold": 100,
"maxThreshold": 200
},
"upload": {
"minTimeout": "PT6S",
"minThreshold": 300,
"maxThreshold": 400
}
}
}

Percentage-Based Rules (ram, cpu, partitions)

These rules use fractional thresholds (0.0–1.0) representing resource utilization percentage:

FieldTypeRequiredDefaultDescription
minTimeoutstring (ISO 8601 duration)No0 (immediate)Minimum duration the metric must exceed the threshold before an alert fires. Format: PT{n}S, PT{n}M, PT{n}H.
minThresholdnumber (double)YesLower bound (0.0–1.0). Crossing below this value clears an active alert.
maxThresholdnumber (double)YesUpper bound (0.0–1.0). Crossing above this value triggers an alert.

For partitions, each entry additionally requires:

FieldTypeRequiredDescription
namestringYesPartition name identifying which disk partition this rule monitors.

Points-Based Rules (download, upload)

These rules use absolute integer thresholds representing data transfer rates:

FieldTypeRequiredDefaultDescription
minTimeoutstring (ISO 8601 duration)No0 (immediate)Minimum duration the metric must exceed the threshold before an alert fires.
minThresholdinteger (uint64)YesLower bound (bytes/sec). Crossing below this value clears an active alert.
maxThresholdinteger (uint64)YesUpper bound (bytes/sec). Crossing above this value triggers an alert.

Alert Rule Summary

RuleKeyThreshold TypeMonitors
RAMramPercentage (0.0–1.0)RAM utilization
CPUcpuPercentage (0.0–1.0)CPU utilization
PartitionspartitionsPercentage (0.0–1.0)Per-partition disk usage
DownloaddownloadPoints (bytes/sec)Download bandwidth
UploaduploadPoints (bytes/sec)Upload bandwidth

Resource Ratios

The resourceRatios object defines how resources are proportioned for service scheduling on this Node. All fields are optional.

{
"resourceRatios": {
"cpu": 50,
"ram": 51,
"storage": 52,
"state": 53
}
}
FieldTypeRequiredDefaultDescription
cpunumber (double)NoNot setCPU allocation ratio for service scheduling.
ramnumber (double)NoNot setRAM allocation ratio for service scheduling.
storagenumber (double)NoNot setStorage allocation ratio for service scheduling.
statenumber (double)NoNot setState storage allocation ratio for service scheduling.

These ratios are used by the service scheduler to determine how much of each resource type is available for service instances on a given Node.

Node Resolution Logic

When the Communication Manager needs to resolve configuration for a specific Node, it applies the following precedence:

  1. Match by Node ID — search the nodes array for an entry whose node.codename matches the target Node's ID. If found, use that entry.
  2. Match by Node type — if no ID match exists, search for the first entry whose nodeGroupSubject.codename matches the target Node's type. If found, use that entry.
  3. Default — if neither matches, an empty NodeConfig is returned (no alert rules, no resource ratios, no labels, priority 0).

In all cases, the resolved configuration has its version set to the Unit config's top-level version and its Node ID set to the target Node's actual ID.

This resolution strategy allows operators to:

  • Define type-level defaults that apply to all Nodes of a given type
  • Override specific Nodes by including an entry with a matching node.codename
  • Leave Nodes unconfigured (they receive empty defaults) if no matching entry exists

Resolution Example

Given this configuration:

{
"formatVersion": "7",
"version": "3.0.0",
"nodes": [
{
"nodeGroupSubject": { "codename": "compute" },
"priority": 5,
"labels": ["general"]
},
{
"node": { "codename": "gpu-node-1" },
"nodeGroupSubject": { "codename": "compute" },
"priority": 10,
"labels": ["gpu", "high-perf"]
}
]
}
  • A Node with ID gpu-node-1 and type compute → resolves to the second entry (ID match, priority 10)
  • A Node with ID cpu-node-2 and type compute → resolves to the first entry (type match, priority 5)
  • A Node with ID sensor-1 and type sensor → resolves to empty defaults (no match, priority 0)

Version Management

Unit configuration uses semantic versioning (semver) for ordering updates:

RuleBehavior
Higher versionAccepted — configuration is updated
Same versionRejected — returns "already exists" error
Lower versionRejected — returns "wrong state" error

Version comparison follows standard semver rules, including pre-release version ordering.

Exception: if the current configuration state is absent (no configuration has ever been installed) or failed (the current configuration is corrupt), the version check is skipped. This allows initial installation and recovery from broken states.

Configuration States

The Unit configuration module tracks its state as one of three values:

StateMeaningTrigger
absentNo configuration file exists on diskInitial state, or file not found at startup
installedConfiguration is loaded and activeSuccessful load at startup, or successful update
failedConfiguration file exists but cannot be parsedParse error during load at startup

State transitions:

┌──────────────────────────┐
│ │
▼ │
┌─────────┐ load OK ┌───────────┐ update OK
│ absent │───────────▶│ installed │◀──────────┘
└─────────┘ └───────────┘
│ ▲
│ │ update OK
│ ┌────────┐ │
└───▶│ failed │─────────┘
load err └────────┘

Persistence

The Unit configuration is persisted to a local JSON file (default path: {workingDir}/aos_unit.cfg). The file:

  • Is written with permissions 0600 (owner read/write only)
  • Contains the complete Unit configuration JSON document
  • Is read at CM startup to restore the last known configuration
  • Is overwritten atomically on each successful update

Complete Example

A full Unit configuration with all fields populated:

{
"formatVersion": "7",
"version": "2.0.0",
"nodes": [
{
"version": "1.0.0",
"node": {
"codename": "node-1"
},
"nodeGroupSubject": {
"codename": "mainType"
},
"alertRules": {
"ram": {
"minTimeout": "PT1S",
"minThreshold": 0.1,
"maxThreshold": 0.2
},
"cpu": {
"minTimeout": "PT2S",
"minThreshold": 0.3,
"maxThreshold": 0.4
},
"partitions": [
{
"name": "partition1",
"minTimeout": "PT3S",
"minThreshold": 0.5,
"maxThreshold": 0.6
},
{
"name": "partition2",
"minTimeout": "PT4S",
"minThreshold": 0.6,
"maxThreshold": 0.7
}
],
"download": {
"minTimeout": "PT5S",
"minThreshold": 100,
"maxThreshold": 200
},
"upload": {
"minTimeout": "PT6S",
"minThreshold": 300,
"maxThreshold": 400
}
},
"resourceRatios": {
"cpu": 50,
"ram": 51,
"storage": 52,
"state": 53
},
"labels": [
"mainNode"
],
"priority": 1
},
{
"version": "1.0.0",
"node": {
"codename": "node-2"
},
"nodeGroupSubject": {
"codename": "secondaryType"
},
"labels": [
"secondaryNode"
],
"priority": 2
}
]
}

Minimal Example

A valid Unit configuration with only required fields:

{
"formatVersion": "7",
"version": "1.0.0",
"nodes": [
{
"nodeGroupSubject": {
"codename": "type1"
},
"priority": 0
}
]
}

Field Name Case Sensitivity

All field names in the Unit configuration JSON are parsed case-insensitively. For example, "formatVersion", "FormatVersion", and "FORMATVERSION" are all equivalent. However, the canonical form uses camelCase as shown in the examples above.