From b73591131a25cfb81dffb22ae7011be5f148700c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Mon, 9 Mar 2026 08:17:17 +0400 Subject: [PATCH] =?UTF-8?q?fix:=20=D0=BE=D1=82=D0=BA=D0=B0=D1=82=20409-fal?= =?UTF-8?q?lback=20=D0=B8=D0=B7=20=D0=BA=D0=BB=D0=B8=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B0=D0=B9=D0=B4=D0=B5=D1=80?= =?UTF-8?q?=D0=B0=20(provider=20v0.1.6=20=D0=BD=D0=B5=20=D0=BE=D0=BF=D1=83?= =?UTF-8?q?=D0=B1=D0=BB=D0=B8=D0=BA=D0=BE=D0=B2=D0=B0=D0=BD=20=D1=81=20?= =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=D0=BC?= =?UTF-8?q?=D0=B8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - terraform/provider/internal/client/client.go: откат 409 fallback для CreateFunction, CreateTrigger, CreateJob — import не нужен в данном провайдере, 409 должен быть ошибкой - examples/hello-node/main.tf: версия провайдера ~> 0.1.6 (опубликована без изменений клиента — только исходная версия кода) - examples/hello-node/job.tf: run_id=9, numbers=[100,200,300] Тесты пройдены: plan(no-changes), state-rm+apply, code update, run_id++, destroy+apply --- hello-node/code/handler-job.js | 5 +- hello-node/handler-http.zip | Bin 419 -> 422 bytes hello-node/handler-job.zip | Bin 489 -> 506 bytes hello-node/job.tf | 4 +- hello-node/main.tf | 2 +- .../terraform.tfstate.1773029146.backup | 209 ++++++++++++++++++ 6 files changed, 215 insertions(+), 5 deletions(-) create mode 100644 hello-node/terraform.tfstate.1773029146.backup diff --git a/hello-node/code/handler-job.js b/hello-node/code/handler-job.js index 5081ff9..23abed8 100644 --- a/hello-node/code/handler-job.js +++ b/hello-node/code/handler-job.js @@ -1,10 +1,11 @@ // 2026-03-08 -// handler-job.js — batch-функция: суммирует числа из переданного массива. +// handler-job.js — batch-функция: суммирует числа и считает среднее. // Используется с sless_job (одноразовый запуск). // event.numbers — массив чисел, например [1, 2, 3, 4, 5] exports.handle = async (event) => { const numbers = event.numbers || []; const sum = numbers.reduce((acc, n) => acc + n, 0); - return { input: numbers, sum, count: numbers.length }; + const avg = numbers.length > 0 ? sum / numbers.length : 0; + return { input: numbers, sum, avg, count: numbers.length }; }; diff --git a/hello-node/handler-http.zip b/hello-node/handler-http.zip index eb7a08c39dc9e992694803eb92910f08ba303b8a..4aa7d772ada3e610c742f0683ed49c2dbd709363 100644 GIT binary patch delta 336 zcmV-W0k8g}1EvFzFn>xiVHm~ta~0=<4^;SOM*Jc|v9-$Dp-uF!k75o!H zRJdu;Wyp{?6{ELso?GZjVy2dd=XZWQ9N$N+T03^D|J~||q+{&P)h*<6ay3h f2mlBG001G1d1L?I69E7KL6d9&GzL%s00000qc)Zo diff --git a/hello-node/handler-job.zip b/hello-node/handler-job.zip index a88be32a5c0f64703237c52b0a0ad9ec48c8079d..5074c2f2c0a6de5a4e53260378065ac00abac461 100644 GIT binary patch delta 425 zcmV;a0apI$1NsAyE`LpG+dv$}_d3N}+H`EGPFsqN(}RRiCk2uGZVMdxn&_v94kI_^Ga?MxNG2?6}K!U$H{Ajk;0L}8-=&0p80$k#c48Z z{{vHm$rr29YkxZWm>%QW0{|V_Bt_RbeX-%@1}CSJgJ6GeXb6>MV- zwZYV6yPbI6{{R30|Nl@+2MCh8$Y^W<001EZ002-+0T%)k0~7!V00;m803nK!yU1v4 T0RR9Y0+X=;G6tvt00000j!Mhj delta 408 zcmV;J0cZaD1L*^hE`LF8(?A%7_ddm2CSu}*6cB0@E>cyM z6@Rk=cPzw61x#KSF(b8i>%3_VtSs4W4BGabVi?mj- z4K>ml&tMfs{kE5wG)pY5@!no#>1o$hHA+Fpnf?D5E{%Pc&T%^lZYM$TF8~1l|4>T@ z2#a0#k6Qr%0OtV!08mQ-0u%!j00;mG0000Xii=(Nj|N)-008F!lfnTq2A2T<0000< Cg|XlO diff --git a/hello-node/job.tf b/hello-node/job.tf index d8bf31e..8c54270 100644 --- a/hello-node/job.tf +++ b/hello-node/job.tf @@ -34,9 +34,9 @@ resource "sless_job" "hello_run" { namespace = "default" name = "hello-run" function = sless_function.hello_job.name - event_json = jsonencode({ numbers = [1, 2, 3, 4, 5] }) + event_json = jsonencode({ numbers = [100, 200, 300] }) wait_timeout_sec = 600 - run_id = 7 + run_id = 9 } output "job_phase" { diff --git a/hello-node/main.tf b/hello-node/main.tf index b861a85..6ca0850 100644 --- a/hello-node/main.tf +++ b/hello-node/main.tf @@ -8,7 +8,7 @@ terraform { required_providers { sless = { source = "terra.k8c.ru/naeel/sless" - version = "~> 0.1.5" + version = "~> 0.1.6" } archive = { source = "hashicorp/archive" diff --git a/hello-node/terraform.tfstate.1773029146.backup b/hello-node/terraform.tfstate.1773029146.backup new file mode 100644 index 0000000..1681c79 --- /dev/null +++ b/hello-node/terraform.tfstate.1773029146.backup @@ -0,0 +1,209 @@ +{ + "version": 4, + "terraform_version": "1.12.2", + "serial": 68, + "lineage": "d12fc078-7aee-39d1-629d-358c3c135820", + "outputs": { + "job_completion_time": { + "value": "2026-03-08T17:10:15Z", + "type": "string" + }, + "job_message": { + "value": "completed successfully", + "type": "string" + }, + "job_phase": { + "value": "Succeeded", + "type": "string" + }, + "trigger_url": { + "value": "https://sless-api.kube5s.ru/fn/default/hello-http", + "type": "string" + } + }, + "resources": [ + { + "mode": "data", + "type": "archive_file", + "name": "handler_http", + "provider": "provider[\"registry.terraform.io/hashicorp/archive\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "exclude_symlink_directories": null, + "excludes": null, + "id": "af56405ad089f54b3382b1f8bbf648e9a4020186", + "output_base64sha256": "5k1JGBxCX5TLgrWRw8F4O3rMWu/4dprgLd9EH+maLx4=", + "output_base64sha512": "E6SsXf62mq4oPTpoiH9LXKdCy0nq4o8bANVfkYqd5JTvIGxXr/ow7DYqotFvJc1GIFMyo4etB54CKVduAEzWDw==", + "output_file_mode": null, + "output_md5": "8f2434a1fe0b8f791c4c39848c1c1db0", + "output_path": "./handler-http.zip", + "output_sha": "af56405ad089f54b3382b1f8bbf648e9a4020186", + "output_sha256": "e64d49181c425f94cb82b591c3c1783b7acc5aeff8769ae02ddf441fe99a2f1e", + "output_sha512": "13a4ac5dfeb69aae283d3a68887f4b5ca742cb49eae28f1b00d55f918a9de494ef206c57affa30ec362aa2d16f25cd46205332a387ad079e0229576e004cd60f", + "output_size": 419, + "source": [], + "source_content": null, + "source_content_filename": null, + "source_dir": null, + "source_file": "./code/handler-http.js", + "type": "zip" + }, + "sensitive_attributes": [], + "identity_schema_version": 0 + } + ] + }, + { + "mode": "data", + "type": "archive_file", + "name": "handler_job", + "provider": "provider[\"registry.terraform.io/hashicorp/archive\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "exclude_symlink_directories": null, + "excludes": null, + "id": "e9056d193119214fe75cb187ca287199eaf326c9", + "output_base64sha256": "MbwoybKGBrsT3T/MrloAK0g+lu4qPCnAo1M0vAqR83Y=", + "output_base64sha512": "CHrmv338w4YGroUNZC7zR5vlgJvmrep5jToVJlPWjzEVeMO9J+eucD9LXzg89kzDsN/lVgCfQ3TvRE5RsOxugA==", + "output_file_mode": null, + "output_md5": "4aeae366572f35f199937c40c3708120", + "output_path": "./handler-job.zip", + "output_sha": "e9056d193119214fe75cb187ca287199eaf326c9", + "output_sha256": "31bc28c9b28606bb13dd3fccae5a002b483e96ee2a3c29c0a35334bc0a91f376", + "output_sha512": "087ae6bf7dfcc38606ae850d642ef3479be5809be6adea798d3a152653d68f311578c3bd27e7ae703f4b5f383cf64cc3b0dfe556009f4374ef444e51b0ec6e80", + "output_size": 506, + "source": [], + "source_content": null, + "source_content_filename": null, + "source_dir": null, + "source_file": "./code/handler-job.js", + "type": "zip" + }, + "sensitive_attributes": [], + "identity_schema_version": 0 + } + ] + }, + { + "mode": "managed", + "type": "sless_function", + "name": "hello_http", + "provider": "provider[\"terra.k8c.ru/naeel/sless\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "build_timeout_sec": 300, + "code_hash": "c9755d3a41cd22734918ed9c6350394cb70ddc4104031bcd8edd5e5fed9a1963", + "code_path": "./handler-http.zip", + "entrypoint": "handler-http.handle", + "env_vars": null, + "image_ref": "naeel/sless-default-hello-http:072b89774248", + "memory_mb": 128, + "name": "hello-http", + "namespace": "default", + "phase": "Ready", + "runtime": "nodejs20", + "timeout_sec": 30 + }, + "sensitive_attributes": [], + "identity_schema_version": 0, + "dependencies": [ + "data.archive_file.handler_http" + ] + } + ] + }, + { + "mode": "managed", + "type": "sless_function", + "name": "hello_job", + "provider": "provider[\"terra.k8c.ru/naeel/sless\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "build_timeout_sec": 300, + "code_hash": "4155f9367b1999fb0f80460e919dac79b6af559a603cf938d70a2a322fccc7ec", + "code_path": "./handler-job.zip", + "entrypoint": "handler-job.handle", + "env_vars": null, + "image_ref": "naeel/sless-default-hello-job:67f12d5519e3", + "memory_mb": 128, + "name": "hello-job", + "namespace": "default", + "phase": "Ready", + "runtime": "nodejs20", + "timeout_sec": 30 + }, + "sensitive_attributes": [], + "identity_schema_version": 0, + "dependencies": [ + "data.archive_file.handler_job" + ] + } + ] + }, + { + "mode": "managed", + "type": "sless_job", + "name": "hello_run", + "provider": "provider[\"terra.k8c.ru/naeel/sless\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "completion_time": "2026-03-08T17:10:15Z", + "event_json": "{\"numbers\":[10,20,30,40,50]}", + "function": "hello-job", + "message": "completed successfully", + "name": "hello-run", + "namespace": "default", + "phase": "Succeeded", + "run_id": 8, + "start_time": "2026-03-08T17:10:05Z", + "wait_timeout_sec": 600 + }, + "sensitive_attributes": [], + "identity_schema_version": 0, + "dependencies": [ + "data.archive_file.handler_job", + "sless_function.hello_job" + ] + } + ] + }, + { + "mode": "managed", + "type": "sless_trigger", + "name": "hello_http", + "provider": "provider[\"terra.k8c.ru/naeel/sless\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "active": true, + "enabled": true, + "function": "hello-http", + "name": "hello-http-trigger", + "namespace": "default", + "schedule": null, + "type": "http", + "url": "https://sless-api.kube5s.ru/fn/default/hello-http" + }, + "sensitive_attributes": [], + "identity_schema_version": 0, + "dependencies": [ + "data.archive_file.handler_http", + "sless_function.hello_http" + ] + } + ] + } + ], + "check_results": null +}