NorskManager class

The entrypoint for all Norsk Manager applications

Signature:

export declare class NorskManager

Example

const norsk = await NorskManager.connect({ url: "localhost:6790" });

Properties

Property Type Description

hello

DaemonHello

The daemon’s hello: its wire-protocol version, build label and the protocol skew against this SDK. Set alongside version.

version

VersionInfo

Norsk Runtime version information

Methods

Method Modifiers Description

abortMigration(jobId, sourceRole, targetRole, reason, migrationId)

Abort an in-flight migration. Manager dispatches NodeControllerMigrationAbort to both the source and target workers (the source resumes output, the target tears its migration state down). migrationId lets a worker ignore an abort that belongs to a predecessor of the migration it is in.

appendAuditEntry(source, kind, payload)

Append a caller-supplied event to the durable audit log — for norsk-mgr-origin actions that don’t pass through another RPC. The daemon assigns the seq and chains it.

close()

Close down the Norsk connection

clusterMemberRegister(req)

Worker-facing call: the worker presents its registration token and tells Manager where to dial back. On success Manager raises Online on its provider bus and dials the worker; on Unauthenticated the token is unknown (or has been deregistered).

Most consumers won’t call this directly — norsk-ctl --mode=worker --token=… --manager-url=… does it on the worker side.

completeJob(jobId)

Stops a running job

connect(settings)

static

Connect to the Norsk Manager

createAwsNode(node)

Spawn a new EC2 instance running the worker image, and make it available for picking up jobs

createBundle(bundle)

Create a bundle (AutoManager v1). The bundle is passed in raw PB form — auto-manager (or any other consumer) is expected to convert its own typed Bundle to PB before calling. Returns the assigned bundleId so the caller can correlate later events.

createJob(job)

Create a new job

createOciNode(node)

Spawn a new OCI instance running the worker image, and make it available for picking up jobs

deleteBundle(bundleId)

Delete a bundle (AutoManager v1).

deleteJob(jobId)

Deletes a job

deregisterClusterNode(nodeId)

Remove a cluster slot. If a worker is currently connected on this slot, its gRPC stream is closed and any running jobs are stopped. The token is invalidated.

describeInstanceType(instanceType)

Cloud facts for a machine-type form prefill: vCPU / memory / architectures for an EC2 instance type, from the Manager’s instance-type cache. Authoritative for capacity ≡ vCPUs. Returns undefined when the instance type is unknown to the cloud.

eventStream(settings)

Provides a stream of the activity that is happening on the server-side. Reacting to these events is essential for the creation of client-side management logic.

getAuditLog(limit)

The most recent audit-log entries (newest first), plus whether the daemon’s hash chain verified on its last boot.

getNodeIdleExpiry(nodeId)

What idle expiry applies to a node: idleExpiryMs is the override as set (0 = none), effectiveIdleExpiryMs is what the reaper will actually apply — the override when one is set, otherwise the daemon-wide value.

jobById(id)

Search for jobs by id

jobSearch(settings)

Search for jobs by tag/date/etc. See JobSearchSettings

listClusterNodes()

List all registered cluster slots (active + inactive). Includes the tokens — visible to operators so they can re-copy on demand.

listNodes()

Return a list a all the nodes the manager knows about.

listWorkerSecurityGroups(region)

Security groups dev-ops marked selectable for workers (tagged id3as.Norsk.WorkerSecurityGroup = <label>) in the given region — the discovery feed for a launch form’s SG selector, each with its actual ingress rules so the form can hint port coverage. Also carries the region’s base worker SG(s) (always attached, never selectable) so deployment-opened ports count as covered.

markJobFailed(jobId, reason)

Record a durable terminal-failed verdict on a job (AutoManager writeback when it gives up: restart ceiling exceeded / bronze drop). The job is marked terminally failed and persisted so it is not re-placed after a restart.

notifyMigrationCutoverApply(targetJobKey, migrationId, payload)

Tell the target worker "the source stopped output at payload; begin output from there". payload is the source’s own, relayed opaque. The target answers with MigrationTargetAppliedEvent.

notifyMigrationCutoverReady(sourceJobKey, migrationId, payload)

Tell the source worker "the target is ready at payload; stop output at or after it". AutoManager calls this when it receives MigrationTargetReadyEvent from the target; payload is the target’s own, relayed opaque — the job owns its meaning.

notifyMigrationGetState(sourceJobKey, migrationId)

The propose step (Phase F): ask the SOURCE what state it would hand over, before any target has been placed. The source’s answer — a payload, or a refusal — comes back asynchronously on the event stream as migrationState; a refusal ends the migration with nothing started anywhere.

prefetchImages(nodeId, imageRefs)

Pre-warm a node (Phase G, warm nodes): tell its worker to pull these image refs now, so a later job start there finds them local. Returns as soon as the worker has been told — the per-ref outcome arrives asynchronously on the event stream as imagesPrefetched, and the node’s heldImages inventory updates right behind it.

A failure on one ref never fails the others; each ref’s result says for itself.

pruneAuditLog(beforeTimestampMs)

Operator-initiated retention prune of the audit log. Clears entries strictly older than beforeTimestampMs (0 = clear everything). The daemon front-prunes, records a checkpoint so the kept chain still verifies, and appends an audit-pruned marker. Returns how many entries were removed and the checkpoint boundary seq.

registerClusterNode(nodeName, pool)

Pre-register a cluster slot. Returns a nodeId and a one-shot token that must be handed to a worker — the worker calls clusterMemberRegister with the token + its listen address/port + hardware info. Until the worker calls in, the slot is registered-but-inactive.

setClusterNodePool(nodeId, pool)

Reassign a cluster slot to a different pool. Empty string = unassign. If the slot is currently active, Manager cycles Stopping/Terminated/ Online so the updated tags["pool"] propagates to AutoManager — containers on the worker survive (the worker preserves them across stream drops). Callers should ensure no jobs are currently assigned to the node; the brief reconnect window could otherwise interfere with in-flight placement.

setNodeIdleExpiry(nodeId, idleExpiryMs)

Give ONE node its own grace period before the empty-node reaper terminates it, overriding the daemon-wide value. Pass 0 to clear the override and go back to the daemon-wide value.

The setting is daemon-owned and persisted: it survives a Manager restart, which is exactly when a node deliberately kept warm would otherwise be reaped.

setNodeTags(nodeId, tags)

Merge tags onto a node: a key given here replaces its value, keys not given are untouched. The daemon persists the edit and re-applies it when it rediscovers the node after a restart, pushes it to the provider, and announces the node’s new metadata as a nodeTagsUpdated event. The spare tag is the daemon’s own: refused on an elastic node (FAILED_PRECONDITION — those spares are the AutoManager reconciler’s), while on a local server (cluster provider) spare: "true" marks it as a hot spare (refused while it holds a job) and any other value clears it; warmFor / reservedFor / exclusive beside it are the spare’s spec.

startBundleJob(bundleId, replicaIndex, jobName)

Activate a dormant (start_mode = "manual") bundle job. Manager removes the dormant tag and re-emits jobUpdated; placement picks the job up via the normal flow. See §10.2 of the AutoManager design.

startJob(jobId, role, nodeId, opts)

Start a job on a node

startPreparedJob(jobId, role, nodeId)

Start an instance that was provisioned with deferStart (the stop-then-start migration strategy): every container exists, none is running. Manager forwards start_prepared_job to the worker holding (jobId, role) on nodeId; the worker answers with JobRunning in the job’s history.

stopBundleJob(bundleId, replicaIndex, jobName)

Deactivate a bundle job by re-stamping the dormant tag.

v1 caveat: this is the tag-flip half only. Runtime termination of any currently-running workload and empty-node release with linger are tracked as Phase E.5 (pre-go-live). See §10.2.1.

stopJob(jobId, role, nodeId, opts)

Stop a job running on a node

terminateNode(nodeId)

Forcibly stop a node

updateBundle(bundle)

Update a bundle (AutoManager v1). Same convention as createBundle — caller passes raw PB.

updateJob(job)

Update a job