@highstate/backend 0.12.1 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-SEPC66ZL.js → chunk-4JUMOKLV.js} +4 -3
- package/dist/chunk-4JUMOKLV.js.map +1 -0
- package/dist/highstate.manifest.json +2 -2
- package/dist/index.js +86 -60
- package/dist/index.js.map +1 -1
- package/dist/shared/index.js +1 -1
- package/package.json +3 -3
- package/prisma/project/main.prisma +1 -1
- package/prisma/project/operation.prisma +1 -0
- package/src/business/instance-state.ts +61 -27
- package/src/database/_generated/project/browser.ts +244 -0
- package/src/database/_generated/project/client.ts +5 -30
- package/src/database/_generated/project/commonInputTypes.ts +2 -2
- package/src/database/_generated/project/enums.ts +3 -1
- package/src/database/_generated/project/internal/class.ts +11 -16
- package/src/database/_generated/project/internal/prismaNamespace.ts +7 -13
- package/src/database/_generated/project/internal/prismaNamespaceBrowser.ts +445 -0
- package/src/database/_generated/project/models/ApiKey.ts +21 -21
- package/src/database/_generated/project/models/Artifact.ts +31 -31
- package/src/database/_generated/project/models/HubModel.ts +11 -11
- package/src/database/_generated/project/models/InstanceCustomStatus.ts +23 -23
- package/src/database/_generated/project/models/InstanceEvaluationState.ts +15 -15
- package/src/database/_generated/project/models/InstanceLock.ts +15 -15
- package/src/database/_generated/project/models/InstanceModel.ts +11 -11
- package/src/database/_generated/project/models/InstanceOperationState.ts +44 -44
- package/src/database/_generated/project/models/InstanceState.ts +206 -206
- package/src/database/_generated/project/models/Operation.ts +70 -70
- package/src/database/_generated/project/models/OperationLog.ts +2 -2
- package/src/database/_generated/project/models/Page.ts +54 -54
- package/src/database/_generated/project/models/Secret.ts +44 -44
- package/src/database/_generated/project/models/ServiceAccount.ts +40 -40
- package/src/database/_generated/project/models/Terminal.ts +62 -62
- package/src/database/_generated/project/models/TerminalSession.ts +2 -2
- package/src/database/_generated/project/models/TerminalSessionLog.ts +2 -2
- package/src/database/_generated/project/models/Trigger.ts +32 -32
- package/src/database/_generated/project/models/UnlockMethod.ts +11 -11
- package/src/database/_generated/project/models/UserCompositeViewport.ts +17 -17
- package/src/database/_generated/project/models/UserProjectViewport.ts +11 -11
- package/src/database/_generated/project/models/Worker.ts +2 -2
- package/src/database/_generated/project/models/WorkerUnitRegistration.ts +23 -23
- package/src/database/_generated/project/models/WorkerVersion.ts +29 -29
- package/src/database/_generated/project/models/WorkerVersionLog.ts +2 -2
- package/src/database/_generated/project/models.ts +1 -1
- package/src/database/_generated/project/pjtg.ts +1 -0
- package/src/orchestrator/operation-workset.ts +22 -11
- package/src/orchestrator/operation.ts +11 -5
- package/src/shared/models/project/operation.ts +1 -0
- package/dist/chunk-SEPC66ZL.js.map +0 -1
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
/* !!! This is code generated by Prisma. Do not edit directly. !!! */
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
// @ts-nocheck
|
|
5
|
-
|
|
5
|
+
/*
|
|
6
6
|
* This file exports the `WorkerVersion` model and its related types.
|
|
7
7
|
*
|
|
8
8
|
* 🟢 You can import this file directly.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import type * as PJTG from '../pjtg.ts';
|
|
12
|
-
import * as runtime from "@prisma/client/runtime/client"
|
|
12
|
+
import type * as runtime from "@prisma/client/runtime/client"
|
|
13
13
|
import type * as $Enums from "../enums.ts"
|
|
14
14
|
import type * as Prisma from "../internal/prismaNamespace.ts"
|
|
15
15
|
|
|
@@ -184,7 +184,7 @@ export type WorkerVersionGroupByArgs<ExtArgs extends runtime.Types.Extensions.In
|
|
|
184
184
|
|
|
185
185
|
export type WorkerVersionGroupByOutputType = {
|
|
186
186
|
id: string
|
|
187
|
-
meta:
|
|
187
|
+
meta:PrismaJson.CommonObjectMeta
|
|
188
188
|
status: $Enums.WorkerVersionStatus
|
|
189
189
|
enabled: boolean
|
|
190
190
|
runtimeId: string | null
|
|
@@ -304,7 +304,7 @@ export type WorkerVersionScalarWhereWithAggregatesInput = {
|
|
|
304
304
|
|
|
305
305
|
export type WorkerVersionCreateInput = {
|
|
306
306
|
id?: string
|
|
307
|
-
meta:
|
|
307
|
+
meta:PrismaJson.CommonObjectMeta
|
|
308
308
|
status?: $Enums.WorkerVersionStatus
|
|
309
309
|
enabled?: boolean
|
|
310
310
|
runtimeId?: string | null
|
|
@@ -319,7 +319,7 @@ export type WorkerVersionCreateInput = {
|
|
|
319
319
|
|
|
320
320
|
export type WorkerVersionUncheckedCreateInput = {
|
|
321
321
|
id?: string
|
|
322
|
-
meta:
|
|
322
|
+
meta:PrismaJson.CommonObjectMeta
|
|
323
323
|
status?: $Enums.WorkerVersionStatus
|
|
324
324
|
enabled?: boolean
|
|
325
325
|
runtimeId?: string | null
|
|
@@ -334,7 +334,7 @@ export type WorkerVersionUncheckedCreateInput = {
|
|
|
334
334
|
|
|
335
335
|
export type WorkerVersionUpdateInput = {
|
|
336
336
|
id?: Prisma.StringFieldUpdateOperationsInput | string
|
|
337
|
-
meta?:
|
|
337
|
+
meta?:PrismaJson.CommonObjectMeta
|
|
338
338
|
status?: Prisma.EnumWorkerVersionStatusFieldUpdateOperationsInput | $Enums.WorkerVersionStatus
|
|
339
339
|
enabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
|
340
340
|
runtimeId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
@@ -349,7 +349,7 @@ export type WorkerVersionUpdateInput = {
|
|
|
349
349
|
|
|
350
350
|
export type WorkerVersionUncheckedUpdateInput = {
|
|
351
351
|
id?: Prisma.StringFieldUpdateOperationsInput | string
|
|
352
|
-
meta?:
|
|
352
|
+
meta?:PrismaJson.CommonObjectMeta
|
|
353
353
|
status?: Prisma.EnumWorkerVersionStatusFieldUpdateOperationsInput | $Enums.WorkerVersionStatus
|
|
354
354
|
enabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
|
355
355
|
runtimeId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
@@ -364,7 +364,7 @@ export type WorkerVersionUncheckedUpdateInput = {
|
|
|
364
364
|
|
|
365
365
|
export type WorkerVersionCreateManyInput = {
|
|
366
366
|
id?: string
|
|
367
|
-
meta:
|
|
367
|
+
meta:PrismaJson.CommonObjectMeta
|
|
368
368
|
status?: $Enums.WorkerVersionStatus
|
|
369
369
|
enabled?: boolean
|
|
370
370
|
runtimeId?: string | null
|
|
@@ -377,7 +377,7 @@ export type WorkerVersionCreateManyInput = {
|
|
|
377
377
|
|
|
378
378
|
export type WorkerVersionUpdateManyMutationInput = {
|
|
379
379
|
id?: Prisma.StringFieldUpdateOperationsInput | string
|
|
380
|
-
meta?:
|
|
380
|
+
meta?:PrismaJson.CommonObjectMeta
|
|
381
381
|
status?: Prisma.EnumWorkerVersionStatusFieldUpdateOperationsInput | $Enums.WorkerVersionStatus
|
|
382
382
|
enabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
|
383
383
|
runtimeId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
@@ -388,7 +388,7 @@ export type WorkerVersionUpdateManyMutationInput = {
|
|
|
388
388
|
|
|
389
389
|
export type WorkerVersionUncheckedUpdateManyInput = {
|
|
390
390
|
id?: Prisma.StringFieldUpdateOperationsInput | string
|
|
391
|
-
meta?:
|
|
391
|
+
meta?:PrismaJson.CommonObjectMeta
|
|
392
392
|
status?: Prisma.EnumWorkerVersionStatusFieldUpdateOperationsInput | $Enums.WorkerVersionStatus
|
|
393
393
|
enabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
|
394
394
|
runtimeId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
@@ -564,7 +564,7 @@ export type WorkerVersionUpdateOneRequiredWithoutLogsNestedInput = {
|
|
|
564
564
|
|
|
565
565
|
export type WorkerVersionCreateWithoutApiKeyInput = {
|
|
566
566
|
id?: string
|
|
567
|
-
meta:
|
|
567
|
+
meta:PrismaJson.CommonObjectMeta
|
|
568
568
|
status?: $Enums.WorkerVersionStatus
|
|
569
569
|
enabled?: boolean
|
|
570
570
|
runtimeId?: string | null
|
|
@@ -578,7 +578,7 @@ export type WorkerVersionCreateWithoutApiKeyInput = {
|
|
|
578
578
|
|
|
579
579
|
export type WorkerVersionUncheckedCreateWithoutApiKeyInput = {
|
|
580
580
|
id?: string
|
|
581
|
-
meta:
|
|
581
|
+
meta:PrismaJson.CommonObjectMeta
|
|
582
582
|
status?: $Enums.WorkerVersionStatus
|
|
583
583
|
enabled?: boolean
|
|
584
584
|
runtimeId?: string | null
|
|
@@ -608,7 +608,7 @@ export type WorkerVersionUpdateToOneWithWhereWithoutApiKeyInput = {
|
|
|
608
608
|
|
|
609
609
|
export type WorkerVersionUpdateWithoutApiKeyInput = {
|
|
610
610
|
id?: Prisma.StringFieldUpdateOperationsInput | string
|
|
611
|
-
meta?:
|
|
611
|
+
meta?:PrismaJson.CommonObjectMeta
|
|
612
612
|
status?: Prisma.EnumWorkerVersionStatusFieldUpdateOperationsInput | $Enums.WorkerVersionStatus
|
|
613
613
|
enabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
|
614
614
|
runtimeId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
@@ -622,7 +622,7 @@ export type WorkerVersionUpdateWithoutApiKeyInput = {
|
|
|
622
622
|
|
|
623
623
|
export type WorkerVersionUncheckedUpdateWithoutApiKeyInput = {
|
|
624
624
|
id?: Prisma.StringFieldUpdateOperationsInput | string
|
|
625
|
-
meta?:
|
|
625
|
+
meta?:PrismaJson.CommonObjectMeta
|
|
626
626
|
status?: Prisma.EnumWorkerVersionStatusFieldUpdateOperationsInput | $Enums.WorkerVersionStatus
|
|
627
627
|
enabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
|
628
628
|
runtimeId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
@@ -636,7 +636,7 @@ export type WorkerVersionUncheckedUpdateWithoutApiKeyInput = {
|
|
|
636
636
|
|
|
637
637
|
export type WorkerVersionCreateWithoutWorkerInput = {
|
|
638
638
|
id?: string
|
|
639
|
-
meta:
|
|
639
|
+
meta:PrismaJson.CommonObjectMeta
|
|
640
640
|
status?: $Enums.WorkerVersionStatus
|
|
641
641
|
enabled?: boolean
|
|
642
642
|
runtimeId?: string | null
|
|
@@ -650,7 +650,7 @@ export type WorkerVersionCreateWithoutWorkerInput = {
|
|
|
650
650
|
|
|
651
651
|
export type WorkerVersionUncheckedCreateWithoutWorkerInput = {
|
|
652
652
|
id?: string
|
|
653
|
-
meta:
|
|
653
|
+
meta:PrismaJson.CommonObjectMeta
|
|
654
654
|
status?: $Enums.WorkerVersionStatus
|
|
655
655
|
enabled?: boolean
|
|
656
656
|
runtimeId?: string | null
|
|
@@ -705,7 +705,7 @@ export type WorkerVersionScalarWhereInput = {
|
|
|
705
705
|
|
|
706
706
|
export type WorkerVersionCreateWithoutUnitRegistrationsInput = {
|
|
707
707
|
id?: string
|
|
708
|
-
meta:
|
|
708
|
+
meta:PrismaJson.CommonObjectMeta
|
|
709
709
|
status?: $Enums.WorkerVersionStatus
|
|
710
710
|
enabled?: boolean
|
|
711
711
|
runtimeId?: string | null
|
|
@@ -719,7 +719,7 @@ export type WorkerVersionCreateWithoutUnitRegistrationsInput = {
|
|
|
719
719
|
|
|
720
720
|
export type WorkerVersionUncheckedCreateWithoutUnitRegistrationsInput = {
|
|
721
721
|
id?: string
|
|
722
|
-
meta:
|
|
722
|
+
meta:PrismaJson.CommonObjectMeta
|
|
723
723
|
status?: $Enums.WorkerVersionStatus
|
|
724
724
|
enabled?: boolean
|
|
725
725
|
runtimeId?: string | null
|
|
@@ -749,7 +749,7 @@ export type WorkerVersionUpdateToOneWithWhereWithoutUnitRegistrationsInput = {
|
|
|
749
749
|
|
|
750
750
|
export type WorkerVersionUpdateWithoutUnitRegistrationsInput = {
|
|
751
751
|
id?: Prisma.StringFieldUpdateOperationsInput | string
|
|
752
|
-
meta?:
|
|
752
|
+
meta?:PrismaJson.CommonObjectMeta
|
|
753
753
|
status?: Prisma.EnumWorkerVersionStatusFieldUpdateOperationsInput | $Enums.WorkerVersionStatus
|
|
754
754
|
enabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
|
755
755
|
runtimeId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
@@ -763,7 +763,7 @@ export type WorkerVersionUpdateWithoutUnitRegistrationsInput = {
|
|
|
763
763
|
|
|
764
764
|
export type WorkerVersionUncheckedUpdateWithoutUnitRegistrationsInput = {
|
|
765
765
|
id?: Prisma.StringFieldUpdateOperationsInput | string
|
|
766
|
-
meta?:
|
|
766
|
+
meta?:PrismaJson.CommonObjectMeta
|
|
767
767
|
status?: Prisma.EnumWorkerVersionStatusFieldUpdateOperationsInput | $Enums.WorkerVersionStatus
|
|
768
768
|
enabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
|
769
769
|
runtimeId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
@@ -777,7 +777,7 @@ export type WorkerVersionUncheckedUpdateWithoutUnitRegistrationsInput = {
|
|
|
777
777
|
|
|
778
778
|
export type WorkerVersionCreateWithoutLogsInput = {
|
|
779
779
|
id?: string
|
|
780
|
-
meta:
|
|
780
|
+
meta:PrismaJson.CommonObjectMeta
|
|
781
781
|
status?: $Enums.WorkerVersionStatus
|
|
782
782
|
enabled?: boolean
|
|
783
783
|
runtimeId?: string | null
|
|
@@ -791,7 +791,7 @@ export type WorkerVersionCreateWithoutLogsInput = {
|
|
|
791
791
|
|
|
792
792
|
export type WorkerVersionUncheckedCreateWithoutLogsInput = {
|
|
793
793
|
id?: string
|
|
794
|
-
meta:
|
|
794
|
+
meta:PrismaJson.CommonObjectMeta
|
|
795
795
|
status?: $Enums.WorkerVersionStatus
|
|
796
796
|
enabled?: boolean
|
|
797
797
|
runtimeId?: string | null
|
|
@@ -821,7 +821,7 @@ export type WorkerVersionUpdateToOneWithWhereWithoutLogsInput = {
|
|
|
821
821
|
|
|
822
822
|
export type WorkerVersionUpdateWithoutLogsInput = {
|
|
823
823
|
id?: Prisma.StringFieldUpdateOperationsInput | string
|
|
824
|
-
meta?:
|
|
824
|
+
meta?:PrismaJson.CommonObjectMeta
|
|
825
825
|
status?: Prisma.EnumWorkerVersionStatusFieldUpdateOperationsInput | $Enums.WorkerVersionStatus
|
|
826
826
|
enabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
|
827
827
|
runtimeId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
@@ -835,7 +835,7 @@ export type WorkerVersionUpdateWithoutLogsInput = {
|
|
|
835
835
|
|
|
836
836
|
export type WorkerVersionUncheckedUpdateWithoutLogsInput = {
|
|
837
837
|
id?: Prisma.StringFieldUpdateOperationsInput | string
|
|
838
|
-
meta?:
|
|
838
|
+
meta?:PrismaJson.CommonObjectMeta
|
|
839
839
|
status?: Prisma.EnumWorkerVersionStatusFieldUpdateOperationsInput | $Enums.WorkerVersionStatus
|
|
840
840
|
enabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
|
841
841
|
runtimeId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
@@ -849,7 +849,7 @@ export type WorkerVersionUncheckedUpdateWithoutLogsInput = {
|
|
|
849
849
|
|
|
850
850
|
export type WorkerVersionCreateManyWorkerInput = {
|
|
851
851
|
id?: string
|
|
852
|
-
meta:
|
|
852
|
+
meta:PrismaJson.CommonObjectMeta
|
|
853
853
|
status?: $Enums.WorkerVersionStatus
|
|
854
854
|
enabled?: boolean
|
|
855
855
|
runtimeId?: string | null
|
|
@@ -861,7 +861,7 @@ export type WorkerVersionCreateManyWorkerInput = {
|
|
|
861
861
|
|
|
862
862
|
export type WorkerVersionUpdateWithoutWorkerInput = {
|
|
863
863
|
id?: Prisma.StringFieldUpdateOperationsInput | string
|
|
864
|
-
meta?:
|
|
864
|
+
meta?:PrismaJson.CommonObjectMeta
|
|
865
865
|
status?: Prisma.EnumWorkerVersionStatusFieldUpdateOperationsInput | $Enums.WorkerVersionStatus
|
|
866
866
|
enabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
|
867
867
|
runtimeId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
@@ -875,7 +875,7 @@ export type WorkerVersionUpdateWithoutWorkerInput = {
|
|
|
875
875
|
|
|
876
876
|
export type WorkerVersionUncheckedUpdateWithoutWorkerInput = {
|
|
877
877
|
id?: Prisma.StringFieldUpdateOperationsInput | string
|
|
878
|
-
meta?:
|
|
878
|
+
meta?:PrismaJson.CommonObjectMeta
|
|
879
879
|
status?: Prisma.EnumWorkerVersionStatusFieldUpdateOperationsInput | $Enums.WorkerVersionStatus
|
|
880
880
|
enabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
|
881
881
|
runtimeId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
@@ -889,7 +889,7 @@ export type WorkerVersionUncheckedUpdateWithoutWorkerInput = {
|
|
|
889
889
|
|
|
890
890
|
export type WorkerVersionUncheckedUpdateManyWithoutWorkerInput = {
|
|
891
891
|
id?: Prisma.StringFieldUpdateOperationsInput | string
|
|
892
|
-
meta?:
|
|
892
|
+
meta?:PrismaJson.CommonObjectMeta
|
|
893
893
|
status?: Prisma.EnumWorkerVersionStatusFieldUpdateOperationsInput | $Enums.WorkerVersionStatus
|
|
894
894
|
enabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
|
895
895
|
runtimeId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
@@ -1047,7 +1047,7 @@ export type $WorkerVersionPayload<ExtArgs extends runtime.Types.Extensions.Inter
|
|
|
1047
1047
|
*
|
|
1048
1048
|
* [CommonObjectMeta]
|
|
1049
1049
|
*/
|
|
1050
|
-
meta:
|
|
1050
|
+
meta:PrismaJson.CommonObjectMeta
|
|
1051
1051
|
/**
|
|
1052
1052
|
* The current status of the worker version reported by the runtime.
|
|
1053
1053
|
*/
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
/* !!! This is code generated by Prisma. Do not edit directly. !!! */
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
// @ts-nocheck
|
|
5
|
-
|
|
5
|
+
/*
|
|
6
6
|
* This file exports the `WorkerVersionLog` model and its related types.
|
|
7
7
|
*
|
|
8
8
|
* 🟢 You can import this file directly.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import type * as PJTG from '../pjtg.ts';
|
|
12
|
-
import * as runtime from "@prisma/client/runtime/client"
|
|
12
|
+
import type * as runtime from "@prisma/client/runtime/client"
|
|
13
13
|
import type * as $Enums from "../enums.ts"
|
|
14
14
|
import type * as Prisma from "../internal/prismaNamespace.ts"
|
|
15
15
|
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import type { InstanceId } from "@highstate/contract"
|
|
2
2
|
import type { InstanceStateService, UpdateOperationStateOptions } from "../business"
|
|
3
3
|
import type { InstanceOperationStatus } from "../database"
|
|
4
|
-
import type { InstanceStatus, OperationPhase, OperationPhaseType, ProjectOutput } from "../shared"
|
|
5
4
|
import type { OperationContext } from "./operation-context"
|
|
6
5
|
import { EventEmitter, on } from "node:events"
|
|
7
6
|
import { mapValues } from "remeda"
|
|
7
|
+
import {
|
|
8
|
+
type InstanceStatus,
|
|
9
|
+
isTransientInstanceOperationStatus,
|
|
10
|
+
type OperationPhase,
|
|
11
|
+
type OperationPhaseType,
|
|
12
|
+
type ProjectOutput,
|
|
13
|
+
} from "../shared"
|
|
8
14
|
|
|
9
15
|
type AbortControllerPair = {
|
|
10
16
|
abortController: AbortController
|
|
@@ -156,12 +162,12 @@ export class OperationWorkset {
|
|
|
156
162
|
options,
|
|
157
163
|
)
|
|
158
164
|
|
|
165
|
+
Object.assign(state, patch)
|
|
166
|
+
|
|
159
167
|
if (state.parentInstanceId && this.currentPhase !== "preview") {
|
|
160
168
|
// TODO: update all updates in single transaction
|
|
161
169
|
await this.recalculateCompositeInstanceState(state.parentInstanceId)
|
|
162
170
|
}
|
|
163
|
-
|
|
164
|
-
Object.assign(state, patch)
|
|
165
171
|
}
|
|
166
172
|
|
|
167
173
|
getAffectedCompositeChildren(instanceId: InstanceId): InstanceId[] {
|
|
@@ -184,38 +190,43 @@ export class OperationWorkset {
|
|
|
184
190
|
|
|
185
191
|
let currentResourceCount = 0
|
|
186
192
|
let totalResourceCount = 0
|
|
187
|
-
let
|
|
193
|
+
let knownTotalResourceCount = 0
|
|
188
194
|
|
|
189
195
|
const children = this.context.getStateChildIds(instanceId)
|
|
190
196
|
for (const childId of children) {
|
|
191
197
|
const child = this.context.getState(childId)
|
|
192
198
|
|
|
193
|
-
if (child?.lastOperationState?.currentResourceCount) {
|
|
199
|
+
if (child?.lastOperationState?.currentResourceCount != null) {
|
|
194
200
|
currentResourceCount += child.lastOperationState.currentResourceCount
|
|
195
201
|
}
|
|
196
202
|
|
|
197
|
-
if (child?.lastOperationState?.totalResourceCount) {
|
|
203
|
+
if (child?.lastOperationState?.totalResourceCount != null) {
|
|
198
204
|
totalResourceCount += child.lastOperationState.totalResourceCount
|
|
199
|
-
|
|
205
|
+
knownTotalResourceCount += 1
|
|
200
206
|
}
|
|
201
207
|
}
|
|
202
208
|
|
|
203
209
|
// extrapolate total resource count for other resources without total resource count
|
|
204
210
|
const averageTotalResourceCount =
|
|
205
|
-
|
|
211
|
+
knownTotalResourceCount > 0 ? Math.round(totalResourceCount / knownTotalResourceCount) : 0
|
|
206
212
|
|
|
207
|
-
const notKnownTotalResourceCount = children.length -
|
|
213
|
+
const notKnownTotalResourceCount = children.length - knownTotalResourceCount
|
|
208
214
|
totalResourceCount += notKnownTotalResourceCount * averageTotalResourceCount
|
|
209
215
|
|
|
210
216
|
const finalTotalResourceCount =
|
|
211
217
|
this.currentPhase === "destroy" && state.lastOperationState?.totalResourceCount
|
|
212
218
|
? // do not override totalResourceCount with lower values when destroying instances
|
|
213
|
-
Math.
|
|
219
|
+
Math.max(totalResourceCount, state.lastOperationState.totalResourceCount)
|
|
214
220
|
: totalResourceCount
|
|
215
221
|
|
|
216
222
|
await this.updateState(instanceId, {
|
|
217
223
|
operationState: {
|
|
218
|
-
status:
|
|
224
|
+
status:
|
|
225
|
+
!state.lastOperationState?.status ||
|
|
226
|
+
// do not override final statuses
|
|
227
|
+
isTransientInstanceOperationStatus(state.lastOperationState.status)
|
|
228
|
+
? this.getTransientStatusByOperationPhase()
|
|
229
|
+
: state.lastOperationState.status,
|
|
219
230
|
currentResourceCount,
|
|
220
231
|
totalResourceCount: finalTotalResourceCount,
|
|
221
232
|
},
|
|
@@ -60,10 +60,19 @@ export class RuntimeOperation {
|
|
|
60
60
|
|
|
61
61
|
cancel(): void {
|
|
62
62
|
this.workset.cancel()
|
|
63
|
+
this.tryMarkOperationCancelling()
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
cancelInstance(instanceId: InstanceId): void {
|
|
66
67
|
this.workset.cancelInstance(instanceId)
|
|
68
|
+
this.tryMarkOperationCancelling()
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private tryMarkOperationCancelling(): void {
|
|
72
|
+
if (this.operation.status === "pending" || this.operation.status === "running") {
|
|
73
|
+
this.operation.status = "cancelling"
|
|
74
|
+
this.promiseTracker.track(this.updateOperation({ status: this.operation.status }))
|
|
75
|
+
}
|
|
67
76
|
}
|
|
68
77
|
|
|
69
78
|
async operateSafe(): Promise<void> {
|
|
@@ -914,11 +923,6 @@ export class RuntimeOperation {
|
|
|
914
923
|
return
|
|
915
924
|
}
|
|
916
925
|
|
|
917
|
-
this.logger.warn(
|
|
918
|
-
"finalizing %d unfinished operation states before shutting down",
|
|
919
|
-
unfinishedStates.length,
|
|
920
|
-
)
|
|
921
|
-
|
|
922
926
|
for (const state of unfinishedStates) {
|
|
923
927
|
await this.workset.updateState(state.instanceId, {
|
|
924
928
|
operationState: {
|
|
@@ -929,6 +933,8 @@ export class RuntimeOperation {
|
|
|
929
933
|
status: state.status === "deployed" ? "deployed" : "failed",
|
|
930
934
|
},
|
|
931
935
|
})
|
|
936
|
+
|
|
937
|
+
this.logger.warn(`finalized operation state for unfinished instance "%s"`, state.instanceId)
|
|
932
938
|
}
|
|
933
939
|
}
|
|
934
940
|
|