Skip to navigation

OCI termination evidence

View as MarkdownOpen in Claude

The Compute and Support modules expose separate APIs for provider evidence and continuous termination observations. Neither API requests instance termination or changes a scheduler node or issue tracker. Module instance names depend on the tenant configuration.

Exact Compute reads

ocicompute.get_instance_strict(instance_ocid) returns instance details after a successful read of the exact immutable instance ID. It propagates the original lookup error with instance context. Empty IDs, incomplete results and mismatched IDs are errors, as are IDs with surrounding whitespace. A 404 or access error does not establish absence or termination.

The caller must verify the returned lifecycle and node identity before changing external state. Scheduler state and a cleared inventory mapping are insufficient proof that the provider completed termination.

Continuous observations

ocisr.observe_termination(instance_id, state, observed_at) records a verified lifecycle observation and returns first_seen and elapsed_seconds. observed_at must be an RFC3339 timestamp from the workflow observation. It is stored in UTC. A timestamp more than five minutes ahead of the worker clock is rejected, because it would make every later observation look older and freeze the clock. state must be an OCI instance lifecycle state in upper case or UNKNOWN; any other value is an error. An unavailable provider read must use UNKNOWN.

The observation clock is stored in the existing database key-value store and scoped by tenant and immutable instance ID. It survives workflow cancellation and restart. A different instance starts a separate clock. A non-TERMINATING state or an observation gap greater than 30 minutes resets the clock. UNKNOWN therefore also resets it: missing evidence can delay an escalation but never create one, at the cost that a provider read that keeps failing postpones escalation until reads succeed again. An older observation does not overwrite a newer one and returns no elapsed period. Concurrent calls for one instance are serialized by a row lock; repeating the same observed_at, as a Temporal retry does, is idempotent.

A workflow that escalates after 24 hours must require elapsed_seconds > 86400 and revalidate current provider evidence and operational eligibility before the Support call. The observation API does not authorize escalation itself.

Support requests

This change adds no support-request API. Workflows that escalate a stalled termination create the request with ocisr.create_request. Because that call does not search for an existing request, the caller must record the returned key and reuse it. A failure between OCI accepting the request and the caller recording the key can produce a second request.

Errors and retries

observe_termination returns caller mistakes, such as an invalid instance ID, an unsupported state or a bad timestamp, to the script immediately as non-retryable errors. Temporal does not re-run them with the same arguments. Database errors stay retryable.

Reserved collection

Observation records live in the collection _oci-termination-observations. The kv module rejects every collection name that start with an underscore, so scripts cannot read, overwrite or delete these rows.

Example

Use the tenant’s configured module names inside a workflow:

instance = ocicompute.get_instance_strict(instance_ocid)
if instance.lifecycle_state == "TERMINATING":
observation = ocisr.observe_termination(
instance_ocid,
"TERMINATING",
time.now().format("2006-01-02T15:04:05.999999999Z07:00"),
)

Before a later support escalation, verify the exact instance again and apply the workflow’s eligibility rules. If the Compute read fails, record UNKNOWN instead of continuing a previously observed termination period.