Skip to content

Commit adb5d8c

Browse files
feat: Add instance restart policy
1 parent a14bf8c commit adb5d8c

7 files changed

Lines changed: 101 additions & 3 deletions

File tree

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 52
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/hypeman-71aee51a5e8c3b045e5f554b096af26c16d76deafb3279fdfceba4349acf1f58.yml
3-
openapi_spec_hash: 5a00e48eb3e384355faf2eb57bd3b6f4
4-
config_hash: 7da023612dfc50a6be53b67f4dc233f2
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/hypeman-f9fed11ca56bb499302232ce70b65d8fa6c0f88c5274dbf16670283303449c63.yml
3+
openapi_spec_hash: 24530949a7f53ab57694443c45088190
4+
config_hash: 99e93e381d8384de5a44c6eeed4bd4b1

api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ Types:
4343
- <code><a href="./src/resources/instances/instances.ts">InstanceStats</a></code>
4444
- <code><a href="./src/resources/instances/instances.ts">PathInfo</a></code>
4545
- <code><a href="./src/resources/instances/instances.ts">PortMapping</a></code>
46+
- <code><a href="./src/resources/instances/instances.ts">RestartPolicy</a></code>
47+
- <code><a href="./src/resources/instances/instances.ts">RestartStatus</a></code>
4648
- <code><a href="./src/resources/instances/instances.ts">SetSnapshotScheduleRequest</a></code>
4749
- <code><a href="./src/resources/instances/instances.ts">SnapshotPolicy</a></code>
4850
- <code><a href="./src/resources/instances/instances.ts">SnapshotSchedule</a></code>

src/client.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ import {
105105
Instances,
106106
PathInfo,
107107
PortMapping,
108+
RestartPolicy,
109+
RestartStatus,
108110
SetSnapshotScheduleRequest,
109111
SnapshotPolicy,
110112
SnapshotSchedule,
@@ -868,6 +870,8 @@ export declare namespace Hypeman {
868870
type InstanceStats as InstanceStats,
869871
type PathInfo as PathInfo,
870872
type PortMapping as PortMapping,
873+
type RestartPolicy as RestartPolicy,
874+
type RestartStatus as RestartStatus,
871875
type SetSnapshotScheduleRequest as SetSnapshotScheduleRequest,
872876
type SnapshotPolicy as SnapshotPolicy,
873877
type SnapshotSchedule as SnapshotSchedule,

src/resources/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ export {
5454
type InstanceStats,
5555
type PathInfo,
5656
type PortMapping,
57+
type RestartPolicy,
58+
type RestartStatus,
5759
type SetSnapshotScheduleRequest,
5860
type SnapshotPolicy,
5961
type SnapshotSchedule,

src/resources/instances/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ export {
1414
type InstanceStats,
1515
type PathInfo,
1616
type PortMapping,
17+
type RestartPolicy,
18+
type RestartStatus,
1719
type SetSnapshotScheduleRequest,
1820
type SnapshotPolicy,
1921
type SnapshotSchedule,

src/resources/instances/instances.ts

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,16 @@ export interface Instance {
548548
*/
549549
phase_durations_ms?: { [key: string]: number };
550550

551+
/**
552+
* Whole-instance restart supervision policy.
553+
*/
554+
restart_policy?: RestartPolicy;
555+
556+
/**
557+
* Runtime status for restart policy decisions.
558+
*/
559+
restart_status?: RestartStatus;
560+
551561
/**
552562
* Base memory size (human-readable)
553563
*/
@@ -788,6 +798,66 @@ export interface PortMapping {
788798
protocol?: 'tcp' | 'udp';
789799
}
790800

801+
/**
802+
* Whole-instance restart supervision policy.
803+
*/
804+
export interface RestartPolicy {
805+
/**
806+
* Delay before each restart attempt, expressed as a Go duration like "5s" or "1m".
807+
*/
808+
backoff?: string;
809+
810+
/**
811+
* Consecutive automatic restart attempts before blocking retries. 0 means
812+
* unlimited.
813+
*/
814+
max_attempts?: number;
815+
816+
/**
817+
* Restart behavior when the guest program exits:
818+
*
819+
* - never: do not automatically restart
820+
* - always: restart after any guest exit
821+
* - on_failure: restart only for nonzero, signaled, OOM, or unknown exits
822+
*/
823+
policy?: 'never' | 'always' | 'on_failure';
824+
825+
/**
826+
* Running this long resets the consecutive restart attempt count.
827+
*/
828+
stable_after?: string;
829+
}
830+
831+
/**
832+
* Runtime status for restart policy decisions.
833+
*/
834+
export interface RestartStatus {
835+
/**
836+
* Consecutive automatic restart attempts in the current failure window.
837+
*/
838+
attempts?: number;
839+
840+
/**
841+
* Reason automatic restarts are currently blocked.
842+
*/
843+
blocked_reason?: 'manual_stop' | 'max_attempts_exceeded' | null;
844+
845+
/**
846+
* Last time Hypeman attempted an automatic restart.
847+
*/
848+
last_attempt_at?: string | null;
849+
850+
/**
851+
* Most recent non-exit failure signal that entered restart policy.
852+
*/
853+
last_reason?: 'health_check_failed' | null;
854+
855+
/**
856+
* Next scheduled automatic restart attempt after backoff.
857+
*/
858+
next_attempt_at?: string | null;
859+
}
860+
791861
export interface SetSnapshotScheduleRequest {
792862
/**
793863
* Snapshot interval (Go duration format, minimum 1m).
@@ -1043,6 +1113,11 @@ export interface InstanceCreateParams {
10431113
*/
10441114
overlay_size?: string;
10451115

1116+
/**
1117+
* Whole-instance restart supervision policy.
1118+
*/
1119+
restart_policy?: RestartPolicy;
1120+
10461121
/**
10471122
* Base memory size (human-readable format like "1GB", "512MB", "2G")
10481123
*/
@@ -1229,6 +1304,11 @@ export interface InstanceUpdateParams {
12291304
* lifecycle state.
12301305
*/
12311306
health_check?: HealthCheck;
1307+
1308+
/**
1309+
* Whole-instance restart supervision policy.
1310+
*/
1311+
restart_policy?: RestartPolicy;
12321312
}
12331313

12341314
export interface InstanceListParams {
@@ -1355,6 +1435,8 @@ export declare namespace Instances {
13551435
type InstanceStats as InstanceStats,
13561436
type PathInfo as PathInfo,
13571437
type PortMapping as PortMapping,
1438+
type RestartPolicy as RestartPolicy,
1439+
type RestartStatus as RestartStatus,
13581440
type SetSnapshotScheduleRequest as SetSnapshotScheduleRequest,
13591441
type SnapshotPolicy as SnapshotPolicy,
13601442
type SnapshotSchedule as SnapshotSchedule,

tests/api-resources/instances/instances.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ describe('resource instances', () => {
7979
enabled: true,
8080
},
8181
overlay_size: '20GB',
82+
restart_policy: {
83+
backoff: '5s',
84+
max_attempts: 10,
85+
policy: 'on_failure',
86+
stable_after: '10m',
87+
},
8288
size: '2GB',
8389
skip_guest_agent: false,
8490
skip_kernel_headers: true,

0 commit comments

Comments
 (0)