@geek-fun/serverlessinsight 0.8.8 → 0.9.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/.serverlessinsight/state-cdn-flow-app-cdn-flow-service.json.backup +1 -1
- package/.serverlessinsight/state-iam-test-app-iam-test-service.json.backup +2 -2
- package/.serverlessinsight/state-insight-poc-app-insight-poc-tencent.json.backup +2 -2
- package/.serverlessinsight/state-insight-poc-app-log-insight-poc-tencent-log.json.backup +123 -0
- package/.serverlessinsight/state-insight-poc-deploy-app-insight-poc-deploy.json.backup +4 -4
- package/.serverlessinsight/state-insight-poc-destroy-app-insight-poc-destroy.json.backup +1 -1
- package/.serverlessinsight/state-insight-volc-app-insight-volc.json.backup +2 -2
- package/.serverlessinsight/state-insight-volc-nested-app-insight-volc-nested.json.backup +93 -0
- package/.serverlessinsight/state-nested-drift-app-nested-drift-service.json.backup +148 -0
- package/.serverlessinsight/state-role-reconcile-test-app-role-reconcile-test-service.json.backup +3 -3
- package/CHANGELOG.md +29 -0
- package/dist/package.json +1 -1
- package/dist/src/commands/deploy.js +3 -1
- package/dist/src/commands/index.js +25 -0
- package/dist/src/common/aliyunClient/fc3Operations.js +5 -0
- package/dist/src/common/aliyunClient/index.js +44 -35
- package/dist/src/common/constants.js +5 -1
- package/dist/src/common/imsClient.js +2 -2
- package/dist/src/common/nameBuilder.js +13 -1
- package/dist/src/common/planCompare.js +31 -1
- package/dist/src/common/planFormatter.js +69 -54
- package/dist/src/common/refreshPlanner.js +31 -8
- package/dist/src/lang/en.js +20 -6
- package/dist/src/lang/zh-CN.js +20 -6
- package/dist/src/stack/aliyunStack/apigwPlanner.js +26 -5
- package/dist/src/stack/aliyunStack/databasePlanner.js +6 -1
- package/dist/src/stack/aliyunStack/databaseResource.js +10 -2
- package/dist/src/stack/aliyunStack/deployer.js +30 -13
- package/dist/src/stack/aliyunStack/fc3Planner.js +46 -25
- package/dist/src/stack/aliyunStack/fc3Resource.js +137 -87
- package/dist/src/stack/aliyunStack/ossPlanner.js +6 -1
- package/dist/src/stack/aliyunStack/ossResource.js +9 -2
- package/dist/src/stack/aliyunStack/tablestorePlanner.js +2 -1
- package/dist/src/stack/aliyunStack/tablestoreResource.js +2 -1
- package/dist/src/stack/deploy.js +10 -4
- package/dist/src/stack/scfStack/cosPlanner.js +6 -1
- package/dist/src/stack/scfStack/cosResource.js +6 -2
- package/dist/src/stack/scfStack/deployer.js +21 -6
- package/dist/src/stack/scfStack/esServerlessPlanner.js +6 -1
- package/dist/src/stack/scfStack/esServerlessResource.js +5 -1
- package/dist/src/stack/scfStack/scfPlanner.js +26 -27
- package/dist/src/stack/scfStack/scfResource.js +6 -2
- package/dist/src/stack/scfStack/tdsqlcPlanner.js +6 -1
- package/dist/src/stack/scfStack/tdsqlcResource.js +5 -1
- package/dist/src/stack/volcengineStack/apigwPlanner.js +5 -1
- package/dist/src/stack/volcengineStack/deployer.js +15 -4
- package/dist/src/stack/volcengineStack/tosPlanner.js +6 -1
- package/dist/src/stack/volcengineStack/tosResource.js +10 -3
- package/dist/src/stack/volcengineStack/vefaasPlanner.js +39 -11
- package/dist/src/stack/volcengineStack/vefaasResource.js +5 -1
- package/dist/src/validator/semanticValidation.js +24 -0
- package/package.json +1 -1
|
@@ -449,8 +449,7 @@ const createDependentResources = async (context, fn, serviceName, existingInstan
|
|
|
449
449
|
else {
|
|
450
450
|
const mountPoints = [];
|
|
451
451
|
for (const nasItem of fn.storage.nas) {
|
|
452
|
-
const
|
|
453
|
-
const accessGroupName = `${fn.name}-${context.stage}-nas-access-${mountPath}`;
|
|
452
|
+
const accessGroupName = (0, common_1.buildNasAccessGroupName)(fn.name, context.stage, nasItem.mount_path);
|
|
454
453
|
logger_1.logger.info(lang_1.lang.__('CREATING_NAS_ACCESS_GROUP', { accessGroupName }));
|
|
455
454
|
const accessGroup = await client.nas.createAccessGroup(accessGroupName);
|
|
456
455
|
logger_1.logger.info(lang_1.lang.__('CREATING_NAS_ACCESS_RULE', { accessGroupName }));
|
|
@@ -611,8 +610,10 @@ const createResource = async (context, fn, state) => {
|
|
|
611
610
|
},
|
|
612
611
|
};
|
|
613
612
|
}
|
|
614
|
-
|
|
615
|
-
|
|
613
|
+
// Container-only functions have no code block — mirror the planner's null
|
|
614
|
+
// codeHash (PR #237); the image lives in customContainerConfig, no zip push.
|
|
615
|
+
const codePath = fn.code?.path;
|
|
616
|
+
const codeHash = codePath ? await (0, common_1.computeZipContentHash)(codePath) : null;
|
|
616
617
|
const baseDefinition = (0, fc3Types_1.extractFc3Definition)(config, codeHash);
|
|
617
618
|
const definition = fn.iam ? { ...baseDefinition, iam: fn.iam } : baseDefinition;
|
|
618
619
|
const dependentInstances = dependentResources.instances.map((dep) => ({
|
|
@@ -637,11 +638,13 @@ const createResource = async (context, fn, state) => {
|
|
|
637
638
|
const isTainted = existingResourceState?.status === 'tainted';
|
|
638
639
|
const existingFunctionOnRetry = isTainted ? await client.fc3.getFunction(fn.name) : null;
|
|
639
640
|
if (existingFunctionOnRetry) {
|
|
640
|
-
logger_1.logger.info(
|
|
641
|
+
logger_1.logger.info(lang_1.lang.__('TAINTED_RECOVERY_SKIP_CREATE', { resourceType: 'Function', resourceName: fn.name }));
|
|
641
642
|
}
|
|
642
643
|
try {
|
|
643
644
|
if (!existingFunctionOnRetry) {
|
|
644
|
-
const ossCode =
|
|
645
|
+
const ossCode = codePath
|
|
646
|
+
? await ensureOssCodeUpload(client, codePath, context.region, fn.name)
|
|
647
|
+
: undefined;
|
|
645
648
|
await client.fc3.createFunction(config, codePath, ossCode);
|
|
646
649
|
}
|
|
647
650
|
}
|
|
@@ -681,7 +684,11 @@ const createResource = async (context, fn, state) => {
|
|
|
681
684
|
logger_1.logger.info(`Function ${fn.name} exists and carries ownership tag (${ownershipTag_1.OWNERSHIP_TAG_KEY}), adopting idempotently`);
|
|
682
685
|
}
|
|
683
686
|
else {
|
|
684
|
-
throw new types_1.PartialResourceError(stateAfterDependents, new Error(
|
|
687
|
+
throw new types_1.PartialResourceError(stateAfterDependents, new Error(lang_1.lang.__('RESOURCE_EXISTS_NOT_OWNED_ADOPT', {
|
|
688
|
+
resourceType: 'Function',
|
|
689
|
+
resourceName: fn.name,
|
|
690
|
+
tagKey: ownershipTag_1.OWNERSHIP_TAG_KEY,
|
|
691
|
+
})));
|
|
685
692
|
}
|
|
686
693
|
}
|
|
687
694
|
else {
|
|
@@ -761,6 +768,17 @@ const readResource = async (context, functionName) => {
|
|
|
761
768
|
return await client.fc3.getFunction(functionName);
|
|
762
769
|
};
|
|
763
770
|
exports.readResource = readResource;
|
|
771
|
+
/** Rewrite mount-target instance ids recorded before the M4 repair recreated
|
|
772
|
+
* their targets, so the returned state (and later destroy) tracks the live
|
|
773
|
+
* domains. */
|
|
774
|
+
const withRecreatedMountTargets = (instances, recreated) => instances.map((instance) => {
|
|
775
|
+
if (instance.type !== 'ALIYUN_NAS_MOUNT_TARGET') {
|
|
776
|
+
return instance;
|
|
777
|
+
}
|
|
778
|
+
const fileSystemId = instance.id.split('/')[0];
|
|
779
|
+
const liveDomain = recreated[fileSystemId];
|
|
780
|
+
return liveDomain ? { ...instance, id: `${fileSystemId}/${liveDomain}` } : instance;
|
|
781
|
+
});
|
|
764
782
|
const updateResource = async (context, fn, state, options) => {
|
|
765
783
|
const ctx = (0, common_1.getContext)();
|
|
766
784
|
const serviceName = `${ctx.app}-${ctx.service}`;
|
|
@@ -779,6 +797,10 @@ const updateResource = async (context, fn, state, options) => {
|
|
|
779
797
|
let role;
|
|
780
798
|
let securityGroup;
|
|
781
799
|
let nasConfig;
|
|
800
|
+
// File system id -> live mount target domain, captured by the M4 nested
|
|
801
|
+
// repair below; applied to the function config and the returned state so
|
|
802
|
+
// both track the target that actually exists after recreation.
|
|
803
|
+
const recreatedMountTargets = {};
|
|
782
804
|
// SLS dependent-instance types to drop from the resulting state when
|
|
783
805
|
// function logging is disabled (true -> false).
|
|
784
806
|
const droppedSlsDependentTypes = [];
|
|
@@ -803,20 +825,27 @@ const updateResource = async (context, fn, state, options) => {
|
|
|
803
825
|
// reconcile logstore ttl/shards and index presence against what si
|
|
804
826
|
// creates. Shard deficits are repaired upward; Aliyun cannot shrink.
|
|
805
827
|
if (options?.force) {
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
await client.sls.
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
828
|
+
// Nested repair is best-effort: a transient read/write failure here
|
|
829
|
+
// must not fail the function update itself (SLS ReadTimeout in prod).
|
|
830
|
+
try {
|
|
831
|
+
const liveLogstore = await client.sls.getLogstore(projectName, logstoreName);
|
|
832
|
+
if (!liveLogstore) {
|
|
833
|
+
logger_1.logger.warn(lang_1.lang.__('NESTED_LOGSTORE_RECREATED', { logstoreName }));
|
|
834
|
+
await client.sls.createLogstore(projectName, logstoreName);
|
|
835
|
+
}
|
|
836
|
+
else if (liveLogstore.ttl !== slsOperations_1.SLS_LOGSTORE_TTL ||
|
|
837
|
+
(liveLogstore.shardCount ?? 0) < slsOperations_1.SLS_LOGSTORE_SHARDS) {
|
|
838
|
+
await client.sls.updateLogstore(projectName, logstoreName, slsOperations_1.SLS_LOGSTORE_TTL, Math.max(liveLogstore.shardCount ?? 0, slsOperations_1.SLS_LOGSTORE_SHARDS));
|
|
839
|
+
logger_1.logger.info(lang_1.lang.__('NESTED_LOGSTORE_UPDATED', { logstoreName }));
|
|
840
|
+
}
|
|
841
|
+
const liveIndex = await client.sls.getIndex(projectName, logstoreName);
|
|
842
|
+
if (!liveIndex) {
|
|
843
|
+
logger_1.logger.warn(lang_1.lang.__('NESTED_INDEX_RECREATED', { logstoreName }));
|
|
844
|
+
await client.sls.createIndex(projectName, logstoreName);
|
|
845
|
+
}
|
|
815
846
|
}
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
logger_1.logger.warn(lang_1.lang.__('NESTED_INDEX_RECREATED', { logstoreName }));
|
|
819
|
-
await client.sls.createIndex(projectName, logstoreName);
|
|
847
|
+
catch (error) {
|
|
848
|
+
logger_1.logger.warn(lang_1.lang.__('NESTED_REPAIR_FAILED', { resource: logstoreName, error: String(error) }));
|
|
820
849
|
}
|
|
821
850
|
}
|
|
822
851
|
}
|
|
@@ -925,59 +954,65 @@ const updateResource = async (context, fn, state, options) => {
|
|
|
925
954
|
// config no longer declares. Invalid config rules are skipped at create
|
|
926
955
|
// time too.
|
|
927
956
|
if (options?.force && fn.network) {
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
957
|
+
// Best-effort: a transient SG read failure must not fail the update.
|
|
958
|
+
try {
|
|
959
|
+
const parseRule = (rule) => {
|
|
960
|
+
try {
|
|
961
|
+
return (0, ecsOperations_1.parseSecurityGroupRule)(rule);
|
|
962
|
+
}
|
|
963
|
+
catch {
|
|
964
|
+
return null;
|
|
965
|
+
}
|
|
966
|
+
};
|
|
967
|
+
const desiredIngress = (fn.network.security_group.ingress ?? [])
|
|
968
|
+
.map(parseRule)
|
|
969
|
+
.filter((r) => Boolean(r));
|
|
970
|
+
const desiredEgress = (fn.network.security_group.egress ?? [])
|
|
971
|
+
.map(parseRule)
|
|
972
|
+
.filter((r) => Boolean(r));
|
|
973
|
+
const live = await client.ecs.getSecurityGroupRules(sgInstance.id);
|
|
974
|
+
const liveIngressKeys = (live?.ingressRules ?? []).map((r) => (0, ecsOperations_1.canonicalSecurityGroupRule)(r.ipProtocol ?? '', r.portRange ?? '', r.sourceCidrIp ?? ''));
|
|
975
|
+
const liveEgressKeys = (live?.egressRules ?? []).map((r) => (0, ecsOperations_1.canonicalSecurityGroupRule)(r.ipProtocol ?? '', r.portRange ?? '', r.destCidrIp ?? ''));
|
|
976
|
+
const missingIngress = desiredIngress.filter((d) => !liveIngressKeys.includes((0, ecsOperations_1.canonicalSecurityGroupRule)(d.protocol, d.portRange, d.cidr)));
|
|
977
|
+
const missingEgress = desiredEgress.filter((d) => !liveEgressKeys.includes((0, ecsOperations_1.canonicalSecurityGroupRule)(d.protocol, d.portRange, d.cidr)));
|
|
978
|
+
// The extra check reuses the raw live canonical keys — the same space
|
|
979
|
+
// the missing check uses. Reconstructing a parsed rule here would
|
|
980
|
+
// collapse port ranges (80/443 -> 80) and wrongly revoke matching
|
|
981
|
+
// range rules.
|
|
982
|
+
const desiredIngressKeys = desiredIngress.map((d) => (0, ecsOperations_1.canonicalSecurityGroupRule)(d.protocol, d.portRange, d.cidr));
|
|
983
|
+
const desiredEgressKeys = desiredEgress.map((d) => (0, ecsOperations_1.canonicalSecurityGroupRule)(d.protocol, d.portRange, d.cidr));
|
|
984
|
+
const extraIngress = (live?.ingressRules ?? []).filter((r, i) => {
|
|
985
|
+
const key = liveIngressKeys[i];
|
|
986
|
+
return !key || !desiredIngressKeys.includes(key);
|
|
987
|
+
});
|
|
988
|
+
const extraEgress = (live?.egressRules ?? []).filter((r, i) => {
|
|
989
|
+
const key = liveEgressKeys[i];
|
|
990
|
+
return !key || !desiredEgressKeys.includes(key);
|
|
991
|
+
});
|
|
992
|
+
if (missingIngress.length > 0 || missingEgress.length > 0) {
|
|
993
|
+
await client.ecs.authorizeSecurityGroupRules(sgInstance.id, 'ingress', missingIngress);
|
|
994
|
+
await client.ecs.authorizeSecurityGroupRules(sgInstance.id, 'egress', missingEgress);
|
|
931
995
|
}
|
|
932
|
-
|
|
933
|
-
|
|
996
|
+
if (extraIngress.length > 0 || extraEgress.length > 0) {
|
|
997
|
+
const toParsed = (r) => ({
|
|
998
|
+
// Live portRange is already in Aliyun wire format — pass verbatim
|
|
999
|
+
// so the revoke matches the rule exactly (ranges included).
|
|
1000
|
+
protocol: r.ipProtocol ?? '',
|
|
1001
|
+
cidr: r.sourceCidrIp ?? r.destCidrIp ?? '',
|
|
1002
|
+
portRange: r.portRange ?? '',
|
|
1003
|
+
});
|
|
1004
|
+
await client.ecs.revokeSecurityGroupRules(sgInstance.id, 'ingress', extraIngress.map(toParsed));
|
|
1005
|
+
await client.ecs.revokeSecurityGroupRules(sgInstance.id, 'egress', extraEgress.map(toParsed));
|
|
934
1006
|
}
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
.map(parseRule)
|
|
941
|
-
.filter((r) => Boolean(r));
|
|
942
|
-
const live = await client.ecs.getSecurityGroupRules(sgInstance.id);
|
|
943
|
-
const liveIngressKeys = (live?.ingressRules ?? []).map((r) => (0, ecsOperations_1.canonicalSecurityGroupRule)(r.ipProtocol ?? '', r.portRange ?? '', r.sourceCidrIp ?? ''));
|
|
944
|
-
const liveEgressKeys = (live?.egressRules ?? []).map((r) => (0, ecsOperations_1.canonicalSecurityGroupRule)(r.ipProtocol ?? '', r.portRange ?? '', r.destCidrIp ?? ''));
|
|
945
|
-
const missingIngress = desiredIngress.filter((d) => !liveIngressKeys.includes((0, ecsOperations_1.canonicalSecurityGroupRule)(d.protocol, d.portRange, d.cidr)));
|
|
946
|
-
const missingEgress = desiredEgress.filter((d) => !liveEgressKeys.includes((0, ecsOperations_1.canonicalSecurityGroupRule)(d.protocol, d.portRange, d.cidr)));
|
|
947
|
-
// The extra check reuses the raw live canonical keys — the same space
|
|
948
|
-
// the missing check uses. Reconstructing a parsed rule here would
|
|
949
|
-
// collapse port ranges (80/443 -> 80) and wrongly revoke matching
|
|
950
|
-
// range rules.
|
|
951
|
-
const desiredIngressKeys = desiredIngress.map((d) => (0, ecsOperations_1.canonicalSecurityGroupRule)(d.protocol, d.portRange, d.cidr));
|
|
952
|
-
const desiredEgressKeys = desiredEgress.map((d) => (0, ecsOperations_1.canonicalSecurityGroupRule)(d.protocol, d.portRange, d.cidr));
|
|
953
|
-
const extraIngress = (live?.ingressRules ?? []).filter((r, i) => {
|
|
954
|
-
const key = liveIngressKeys[i];
|
|
955
|
-
return !key || !desiredIngressKeys.includes(key);
|
|
956
|
-
});
|
|
957
|
-
const extraEgress = (live?.egressRules ?? []).filter((r, i) => {
|
|
958
|
-
const key = liveEgressKeys[i];
|
|
959
|
-
return !key || !desiredEgressKeys.includes(key);
|
|
960
|
-
});
|
|
961
|
-
if (missingIngress.length > 0 || missingEgress.length > 0) {
|
|
962
|
-
await client.ecs.authorizeSecurityGroupRules(sgInstance.id, 'ingress', missingIngress);
|
|
963
|
-
await client.ecs.authorizeSecurityGroupRules(sgInstance.id, 'egress', missingEgress);
|
|
1007
|
+
logger_1.logger.info(lang_1.lang.__('NESTED_SG_RULES_REPAIRED', {
|
|
1008
|
+
securityGroupId: sgInstance.id,
|
|
1009
|
+
added: String(missingIngress.length + missingEgress.length),
|
|
1010
|
+
removed: String(extraIngress.length + extraEgress.length),
|
|
1011
|
+
}));
|
|
964
1012
|
}
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
// Live portRange is already in Aliyun wire format — pass verbatim
|
|
968
|
-
// so the revoke matches the rule exactly (ranges included).
|
|
969
|
-
protocol: r.ipProtocol ?? '',
|
|
970
|
-
cidr: r.sourceCidrIp ?? r.destCidrIp ?? '',
|
|
971
|
-
portRange: r.portRange ?? '',
|
|
972
|
-
});
|
|
973
|
-
await client.ecs.revokeSecurityGroupRules(sgInstance.id, 'ingress', extraIngress.map(toParsed));
|
|
974
|
-
await client.ecs.revokeSecurityGroupRules(sgInstance.id, 'egress', extraEgress.map(toParsed));
|
|
1013
|
+
catch (error) {
|
|
1014
|
+
logger_1.logger.warn(lang_1.lang.__('NESTED_REPAIR_FAILED', { resource: sgInstance.id, error: String(error) }));
|
|
975
1015
|
}
|
|
976
|
-
logger_1.logger.info(lang_1.lang.__('NESTED_SG_RULES_REPAIRED', {
|
|
977
|
-
securityGroupId: sgInstance.id,
|
|
978
|
-
added: String(missingIngress.length + missingEgress.length),
|
|
979
|
-
removed: String(extraIngress.length + extraEgress.length),
|
|
980
|
-
}));
|
|
981
1016
|
}
|
|
982
1017
|
}
|
|
983
1018
|
}
|
|
@@ -1005,23 +1040,38 @@ const updateResource = async (context, fn, state, options) => {
|
|
|
1005
1040
|
// (console deletions); extra mount targets are left alone — deleting
|
|
1006
1041
|
// shared infrastructure on a reconcile is never safe.
|
|
1007
1042
|
if (options?.force && fn.network) {
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
await client.nas.
|
|
1015
|
-
|
|
1043
|
+
// Best-effort: a transient NAS read failure must not fail the update.
|
|
1044
|
+
let failingFsId;
|
|
1045
|
+
try {
|
|
1046
|
+
const fsInstances = existingInstances.filter((i) => i.type === 'ALIYUN_NAS_FILE_SYSTEM');
|
|
1047
|
+
for (const fsEntry of fsInstances) {
|
|
1048
|
+
failingFsId = fsEntry.id;
|
|
1049
|
+
const liveTargets = await client.nas.listMountTargets(fsEntry.id);
|
|
1050
|
+
if (!liveTargets || liveTargets.length === 0) {
|
|
1051
|
+
const mountTarget = await client.nas.createMountTarget(fsEntry.id, (0, common_1.buildNasAccessGroupName)(fn.name, context.stage, nasStorageItems[0]?.mount_path ?? '/mnt/nas'), fn.network.vpc_id, fn.network.subnet_ids[0]);
|
|
1052
|
+
if (mountTarget?.mountTargetDomain) {
|
|
1053
|
+
recreatedMountTargets[fsEntry.id] = mountTarget.mountTargetDomain;
|
|
1054
|
+
}
|
|
1055
|
+
logger_1.logger.warn(lang_1.lang.__('NESTED_MOUNT_TARGET_RECREATED', { fileSystemId: fsEntry.id }));
|
|
1056
|
+
}
|
|
1016
1057
|
}
|
|
1017
1058
|
}
|
|
1059
|
+
catch (error) {
|
|
1060
|
+
logger_1.logger.warn(lang_1.lang.__('NESTED_REPAIR_FAILED', { resource: failingFsId ?? 'nas', error: String(error) }));
|
|
1061
|
+
}
|
|
1018
1062
|
}
|
|
1019
1063
|
if (mountTargetInstances.length > 0 && nasStorageItems.length > 0) {
|
|
1020
1064
|
nasConfig = {
|
|
1021
|
-
mountPoints: mountTargetInstances.map((mt, idx) =>
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1065
|
+
mountPoints: mountTargetInstances.map((mt, idx) => {
|
|
1066
|
+
const [fileSystemId, recordedDomain] = mt.id.split('/');
|
|
1067
|
+
// Mount the target that now exists — a just-recreated domain replaces
|
|
1068
|
+
// the stale one recorded in state.
|
|
1069
|
+
const liveDomain = recreatedMountTargets[fileSystemId] ?? recordedDomain;
|
|
1070
|
+
return {
|
|
1071
|
+
serverAddr: `${liveDomain}:/`,
|
|
1072
|
+
mountDir: nasStorageItems[idx]?.mount_path ?? '/mnt/nas',
|
|
1073
|
+
};
|
|
1074
|
+
}),
|
|
1025
1075
|
};
|
|
1026
1076
|
}
|
|
1027
1077
|
}
|
|
@@ -1063,10 +1113,10 @@ const updateResource = async (context, fn, state, options) => {
|
|
|
1063
1113
|
},
|
|
1064
1114
|
};
|
|
1065
1115
|
}
|
|
1066
|
-
const codePath = fn.code
|
|
1116
|
+
const codePath = fn.code?.path;
|
|
1067
1117
|
const currentCodeHash = existingState?.definition?.codeHash;
|
|
1068
|
-
const desiredCodeHash = await (0, common_1.computeZipContentHash)(codePath);
|
|
1069
|
-
const codeChanged = currentCodeHash !== desiredCodeHash;
|
|
1118
|
+
const desiredCodeHash = codePath ? await (0, common_1.computeZipContentHash)(codePath) : null;
|
|
1119
|
+
const codeChanged = codePath ? currentCodeHash !== desiredCodeHash : false;
|
|
1070
1120
|
const existingConfig = existingState?.definition;
|
|
1071
1121
|
const desiredDefinition = (0, fc3Types_1.extractFc3Definition)(config, desiredCodeHash);
|
|
1072
1122
|
const { codeHash: _existingCodeHash, iam: _existingIam, ...existingConfigOnly } = existingConfig || {};
|
|
@@ -1078,7 +1128,7 @@ const updateResource = async (context, fn, state, options) => {
|
|
|
1078
1128
|
if (configChanged || roleBindingChanged || options?.force) {
|
|
1079
1129
|
await client.fc3.updateFunctionConfiguration(config);
|
|
1080
1130
|
}
|
|
1081
|
-
if (codeChanged) {
|
|
1131
|
+
if (codeChanged && codePath) {
|
|
1082
1132
|
const ossCode = await ensureOssCodeUpload(client, codePath, context.region, fn.name);
|
|
1083
1133
|
await client.fc3.updateFunctionCode(fn.name, codePath, ossCode);
|
|
1084
1134
|
}
|
|
@@ -1224,7 +1274,7 @@ const updateResource = async (context, fn, state, options) => {
|
|
|
1224
1274
|
if (!functionInfo) {
|
|
1225
1275
|
throw new Error(`Failed to refresh state for function: ${fn.name}`);
|
|
1226
1276
|
}
|
|
1227
|
-
const codeHash = await (0, common_1.computeZipContentHash)(codePath);
|
|
1277
|
+
const codeHash = codePath ? await (0, common_1.computeZipContentHash)(codePath) : null;
|
|
1228
1278
|
const baseDefinition = (0, fc3Types_1.extractFc3Definition)(config, codeHash);
|
|
1229
1279
|
const definition = fn.iam ? { ...baseDefinition, iam: fn.iam } : baseDefinition;
|
|
1230
1280
|
const sid = (0, common_1.buildSid)('aliyun', 'fc3', context.stage, fn.name);
|
|
@@ -1279,7 +1329,7 @@ const updateResource = async (context, fn, state, options) => {
|
|
|
1279
1329
|
instances: [
|
|
1280
1330
|
fcInstance,
|
|
1281
1331
|
...lifecycleInstances,
|
|
1282
|
-
...existingDependentInstances,
|
|
1332
|
+
...withRecreatedMountTargets(existingDependentInstances, recreatedMountTargets),
|
|
1283
1333
|
...newDependentInstancesMapped,
|
|
1284
1334
|
],
|
|
1285
1335
|
lastUpdated: new Date().toISOString(),
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.generateBucketPlan = void 0;
|
|
7
7
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const lang_1 = require("../../lang");
|
|
8
9
|
const aliyunClient_1 = require("../../common/aliyunClient");
|
|
9
10
|
const refreshCache_1 = require("../../common/refreshCache");
|
|
10
11
|
const concurrency_1 = require("../../common/concurrency");
|
|
@@ -60,7 +61,11 @@ const generateBucketPlan = async (context, state, buckets) => {
|
|
|
60
61
|
desiredDefinition,
|
|
61
62
|
read: () => (0, refreshCache_1.cachedRefreshRead)(context, `oss.getBucket:${bucket.name}`, () => client.oss.getBucket(bucket.name)),
|
|
62
63
|
isOwned: (remote) => (0, ownershipTag_1.isOwnedByStack)(context, logicalId, toOwnershipTags(remote.tags)),
|
|
63
|
-
foreignError: () => new Error(
|
|
64
|
+
foreignError: () => new Error(lang_1.lang.__('RESOURCE_EXISTS_NOT_OWNED', {
|
|
65
|
+
resourceType: 'Bucket',
|
|
66
|
+
resourceName: bucket.name,
|
|
67
|
+
tagKey: ownershipTag_1.OWNERSHIP_TAG_KEY,
|
|
68
|
+
})),
|
|
64
69
|
cloudToDefinition: ossTypes_1.cloudOssToDefinition,
|
|
65
70
|
normalizeForDisplay: normalizeDefinitionForDisplay,
|
|
66
71
|
extraUpdate: () => Promise.resolve({ update: domainBindingPending, drifted: false }),
|
|
@@ -195,7 +195,10 @@ const createBucketResource = async (context, bucket, state) => {
|
|
|
195
195
|
const isTainted = existingResourceState?.status === 'tainted';
|
|
196
196
|
let existingBucketOnRetry = isTainted ? await client.oss.getBucket(config.bucketName) : null;
|
|
197
197
|
if (existingBucketOnRetry) {
|
|
198
|
-
logger_1.logger.info(
|
|
198
|
+
logger_1.logger.info(lang_1.lang.__('TAINTED_RECOVERY_SKIP_CREATE', {
|
|
199
|
+
resourceType: 'Bucket',
|
|
200
|
+
resourceName: config.bucketName,
|
|
201
|
+
}));
|
|
199
202
|
}
|
|
200
203
|
const instances = existingBucketOnRetry
|
|
201
204
|
? [buildOssInstanceFromProvider(existingBucketOnRetry, sid)]
|
|
@@ -216,7 +219,11 @@ const createBucketResource = async (context, bucket, state) => {
|
|
|
216
219
|
const isCdnEnabled = getIsCdnEnabled(bucket);
|
|
217
220
|
const isAccelerateEnabled = getIsAccelerateEnabled(bucket);
|
|
218
221
|
let cnameInfo;
|
|
219
|
-
const refuseAdoptionError = () => new Error(
|
|
222
|
+
const refuseAdoptionError = () => new Error(lang_1.lang.__('RESOURCE_EXISTS_NOT_OWNED_ADOPT', {
|
|
223
|
+
resourceType: 'Bucket',
|
|
224
|
+
resourceName: config.bucketName,
|
|
225
|
+
tagKey: ownershipTag_1.OWNERSHIP_TAG_KEY,
|
|
226
|
+
}));
|
|
220
227
|
try {
|
|
221
228
|
if (!existingBucketOnRetry) {
|
|
222
229
|
try {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateTablePlan = void 0;
|
|
4
|
+
const lang_1 = require("../../lang");
|
|
4
5
|
const aliyunClient_1 = require("../../common/aliyunClient");
|
|
5
6
|
const refreshCache_1 = require("../../common/refreshCache");
|
|
6
7
|
const concurrency_1 = require("../../common/concurrency");
|
|
@@ -38,7 +39,7 @@ const generateTablePlan = async (context, state, tables) => {
|
|
|
38
39
|
// TableStore has no table-level tags: an existing same-named table can
|
|
39
40
|
// never be verified as ours, so it is always refused on the probe path.
|
|
40
41
|
isOwned: () => false,
|
|
41
|
-
foreignError: () => new Error(
|
|
42
|
+
foreignError: () => new Error(lang_1.lang.__('TABLESTORE_EXISTS_UNVERIFIABLE_PROBE', { tableName: config.tableName })),
|
|
42
43
|
cloudToDefinition: tablestoreTypes_1.cloudTableStoreToDefinition,
|
|
43
44
|
refresh: context.refresh,
|
|
44
45
|
});
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deleteTableResource = exports.updateTableResource = exports.readTableResource = exports.createTableResource = void 0;
|
|
4
4
|
const aliyunClient_1 = require("../../common/aliyunClient");
|
|
5
|
+
const lang_1 = require("../../lang");
|
|
5
6
|
const common_1 = require("../../common");
|
|
6
7
|
const types_1 = require("../../types");
|
|
7
8
|
const tablestoreTypes_1 = require("./tablestoreTypes");
|
|
@@ -99,7 +100,7 @@ const createTableResource = async (context, table, state) => {
|
|
|
99
100
|
if ((0, alreadyExists_1.isResourceAlreadyExistsError)(error, ['OTSObjectAlreadyExist', 'OTSInstanceAlreadyExist'])) {
|
|
100
101
|
const existingTable = await tablestoreClient.getTable(config.tableName);
|
|
101
102
|
if (existingTable) {
|
|
102
|
-
throw new types_1.PartialResourceError(stateAfterDependents, new Error(
|
|
103
|
+
throw new types_1.PartialResourceError(stateAfterDependents, new Error(lang_1.lang.__('TABLESTORE_EXISTS_UNVERIFIABLE', { tableName: config.tableName })));
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
throw new types_1.PartialResourceError(stateAfterDependents, error instanceof Error ? error : new Error(String(error)));
|
package/dist/src/stack/deploy.js
CHANGED
|
@@ -10,18 +10,24 @@ const deployHuawei = async () => {
|
|
|
10
10
|
'The provider currently generates HCL templates but does not deploy them. ' +
|
|
11
11
|
'Please use Aliyun or Tencent providers, or contribute Huawei deployment support.');
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* `plan` (issue #246): the exact plan shown to the user for approval is the
|
|
15
|
+
* plan executed — deployers partition its items by resourceType instead of
|
|
16
|
+
* re-probing the cloud and re-deciding. Omit it to fall back to per-provider
|
|
17
|
+
* plan generation (legacy path kept for direct deployer callers).
|
|
18
|
+
*/
|
|
19
|
+
const deployStack = async (iac, backend, plan) => {
|
|
14
20
|
if (iac.provider.name === common_1.ProviderEnum.TENCENT) {
|
|
15
|
-
await (0, scfStack_1.deployTencentStack)(iac, backend);
|
|
21
|
+
await (0, scfStack_1.deployTencentStack)(iac, backend, plan);
|
|
16
22
|
}
|
|
17
23
|
else if (iac.provider.name === common_1.ProviderEnum.ALIYUN) {
|
|
18
|
-
await (0, aliyunStack_1.deployAliyunStack)(iac, backend);
|
|
24
|
+
await (0, aliyunStack_1.deployAliyunStack)(iac, backend, plan);
|
|
19
25
|
}
|
|
20
26
|
else if (iac.provider.name === common_1.ProviderEnum.HUAWEI) {
|
|
21
27
|
await deployHuawei();
|
|
22
28
|
}
|
|
23
29
|
else if (iac.provider.name === common_1.ProviderEnum.VOLCENGINE) {
|
|
24
|
-
await (0, volcengineStack_1.deployVolcengineStack)(iac, backend);
|
|
30
|
+
await (0, volcengineStack_1.deployVolcengineStack)(iac, backend, plan);
|
|
25
31
|
}
|
|
26
32
|
};
|
|
27
33
|
exports.deployStack = deployStack;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateBucketPlan = void 0;
|
|
4
|
+
const lang_1 = require("../../lang");
|
|
4
5
|
const tencentClient_1 = require("../../common/tencentClient");
|
|
5
6
|
const refreshCache_1 = require("../../common/refreshCache");
|
|
6
7
|
const concurrency_1 = require("../../common/concurrency");
|
|
@@ -38,7 +39,11 @@ const generateBucketPlan = async (context, state, buckets) => {
|
|
|
38
39
|
desiredDefinition,
|
|
39
40
|
read: readBucket,
|
|
40
41
|
isOwned: (remote) => (0, ownershipTag_1.isOwnedByStack)(context, logicalId, remote.Tags),
|
|
41
|
-
foreignError: () => new Error(
|
|
42
|
+
foreignError: () => new Error(lang_1.lang.__('RESOURCE_EXISTS_NOT_OWNED', {
|
|
43
|
+
resourceType: 'Bucket',
|
|
44
|
+
resourceName: bucket.name,
|
|
45
|
+
tagKey: ownershipTag_1.OWNERSHIP_TAG_KEY,
|
|
46
|
+
})),
|
|
42
47
|
cloudToDefinition: cosTypes_1.cloudCosToDefinition,
|
|
43
48
|
extraUpdate: async () => {
|
|
44
49
|
// Policy needs a canonical compare: the cloud returns a parsed
|
|
@@ -254,7 +254,7 @@ const createBucketResource = async (context, bucket, state) => {
|
|
|
254
254
|
if (!(0, alreadyExists_1.isResourceAlreadyExistsError)(error, ['BucketAlreadyExists', 'BucketAlreadyOwnedByYou'])) {
|
|
255
255
|
throw error;
|
|
256
256
|
}
|
|
257
|
-
logger_1.logger.info(
|
|
257
|
+
logger_1.logger.info(lang_1.lang.__('OWNERSHIP_VERIFYING', { resourceType: 'Bucket', resourceName: bucket.name }));
|
|
258
258
|
}
|
|
259
259
|
const bucketInfo = await client.cos.getBucket(bucket.name, context.region);
|
|
260
260
|
if (!bucketInfo) {
|
|
@@ -266,7 +266,11 @@ const createBucketResource = async (context, bucket, state) => {
|
|
|
266
266
|
// one may belong to another project and must fail loudly rather than be
|
|
267
267
|
// silently taken over (destroy would then remove a resource never ours).
|
|
268
268
|
if (!(0, ownershipTag_1.isOwnedByStack)(context, logicalId, bucketInfo.Tags)) {
|
|
269
|
-
throw new types_1.PartialResourceError(stateAfterDependents, new Error(
|
|
269
|
+
throw new types_1.PartialResourceError(stateAfterDependents, new Error(lang_1.lang.__('RESOURCE_EXISTS_NOT_OWNED_ADOPT', {
|
|
270
|
+
resourceType: 'Bucket',
|
|
271
|
+
resourceName: bucket.name,
|
|
272
|
+
tagKey: ownershipTag_1.OWNERSHIP_TAG_KEY,
|
|
273
|
+
})));
|
|
270
274
|
}
|
|
271
275
|
const sid = (0, common_1.buildSid)('tencent', 'cos', context.stage, bucket.name);
|
|
272
276
|
const instances = [
|
|
@@ -28,18 +28,33 @@ const handlePartialFailure = (failure) => {
|
|
|
28
28
|
throw error;
|
|
29
29
|
};
|
|
30
30
|
const collectSuccessfulItems = (results) => results.flatMap((result) => result.partialFailure?.successfulItems ?? []);
|
|
31
|
-
|
|
31
|
+
// Issue #246: when the approved plan is passed through, the executor runs
|
|
32
|
+
// exactly the displayed items — partitioned by resourceType, no re-probe.
|
|
33
|
+
const partitionPlan = (plan, types) => ({
|
|
34
|
+
items: plan.items.filter((item) => types.includes(item.resourceType)),
|
|
35
|
+
});
|
|
36
|
+
const deployTencentStack = async (iac, backend, approvedPlan) => {
|
|
32
37
|
const context = (0, common_1.getContext)();
|
|
33
38
|
common_1.logger.info(lang_1.lang.__('DEPLOYING_STACK_PUBLISHING_ASSETS'));
|
|
34
39
|
let state = await backend.loadState(iac.provider.name, iac.app, iac.service, context.stage);
|
|
35
40
|
const onStateChange = createSaveStateFn(backend, iac, context.stage);
|
|
36
41
|
common_1.logger.info(lang_1.lang.__('GENERATING_PLAN'));
|
|
37
|
-
const functionPlan =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
42
|
+
const functionPlan = approvedPlan
|
|
43
|
+
? partitionPlan(approvedPlan, ['SCF'])
|
|
44
|
+
: await (0, scfPlanner_1.generateFunctionPlan)(context, state, iac.functions);
|
|
45
|
+
const bucketPlan = approvedPlan
|
|
46
|
+
? partitionPlan(approvedPlan, ['COS_BUCKET'])
|
|
47
|
+
: await (0, cosPlanner_1.generateBucketPlan)(context, state, iac.buckets);
|
|
48
|
+
const databasePlan = approvedPlan
|
|
49
|
+
? partitionPlan(approvedPlan, ['TDSQL_C_SERVERLESS'])
|
|
50
|
+
: await (0, tdsqlcPlanner_1.generateDatabasePlan)(context, state, iac.databases);
|
|
51
|
+
const esPlan = approvedPlan
|
|
52
|
+
? partitionPlan(approvedPlan, ['TENCENT_ES_SERVERLESS'])
|
|
53
|
+
: await (0, esServerlessPlanner_1.generateEsPlan)(context, state, iac.databases);
|
|
41
54
|
const combinedPlan = {
|
|
42
|
-
items:
|
|
55
|
+
items: approvedPlan
|
|
56
|
+
? [...approvedPlan.items]
|
|
57
|
+
: [...functionPlan.items, ...bucketPlan.items, ...databasePlan.items, ...esPlan.items],
|
|
43
58
|
};
|
|
44
59
|
common_1.logger.info(`${lang_1.lang.__('PLAN_GENERATED')}: ${combinedPlan.items.length} ${lang_1.lang.__('ACTIONS')}`);
|
|
45
60
|
combinedPlan.items.forEach((item) => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateEsPlan = void 0;
|
|
4
|
+
const lang_1 = require("../../lang");
|
|
4
5
|
const tencentClient_1 = require("../../common/tencentClient");
|
|
5
6
|
const refreshCache_1 = require("../../common/refreshCache");
|
|
6
7
|
const concurrency_1 = require("../../common/concurrency");
|
|
@@ -44,7 +45,11 @@ const generateEsPlan = async (context, state, databases) => {
|
|
|
44
45
|
? (0, refreshCache_1.cachedRefreshRead)(context, `es.getSpace:${spaceId}`, () => client.es.getSpace(spaceId))
|
|
45
46
|
: Promise.resolve(null),
|
|
46
47
|
isOwned: (remote) => (0, ownershipTag_1.isOwnedByStack)(context, logicalId, remote.Tags),
|
|
47
|
-
foreignError: () => new Error(
|
|
48
|
+
foreignError: () => new Error(lang_1.lang.__('RESOURCE_EXISTS_NOT_OWNED', {
|
|
49
|
+
resourceType: 'ES space',
|
|
50
|
+
resourceName: config.SpaceName,
|
|
51
|
+
tagKey: ownershipTag_1.OWNERSHIP_TAG_KEY,
|
|
52
|
+
})),
|
|
48
53
|
cloudToDefinition: esServerlessTypes_1.cloudTencentEsToDefinition,
|
|
49
54
|
refresh: context.refresh,
|
|
50
55
|
});
|
|
@@ -113,7 +113,11 @@ const createEsResource = async (context, database, state) => {
|
|
|
113
113
|
logger_1.logger.info(`ES space ${config.SpaceName} exists and carries ownership tag (${ownershipTag_1.OWNERSHIP_TAG_KEY}), adopting idempotently`);
|
|
114
114
|
return (0, stateManager_1.setResource)(state, logicalId, buildResourceState(probe));
|
|
115
115
|
}
|
|
116
|
-
throw new types_1.PartialResourceError(stateAfterDependents, new Error(
|
|
116
|
+
throw new types_1.PartialResourceError(stateAfterDependents, new Error(lang_1.lang.__('RESOURCE_EXISTS_NOT_OWNED_ADOPT', {
|
|
117
|
+
resourceType: 'ES space',
|
|
118
|
+
resourceName: config.SpaceName,
|
|
119
|
+
tagKey: ownershipTag_1.OWNERSHIP_TAG_KEY,
|
|
120
|
+
})));
|
|
117
121
|
}
|
|
118
122
|
throw new types_1.PartialResourceError(stateAfterDependents, error instanceof Error ? error : new Error(String(error)));
|
|
119
123
|
}
|