fix+docs: FunctionJob label bugfix, job ErrAlreadyExists, python str→text/plain, operator.yaml v0.1.33, progress.md
- controllers/functionjob_controller.go: - PodTemplate labels: functionjob=, function= (k8s 1.27+ удалил job-name=) - getJobPodOutput принимает labelSelector вместо jobName - захват stderr при Failed job; truncateForStatus() helper - terraform/provider/internal/client/client.go: ErrJobAlreadyExists (409 Conflict) - terraform/provider/internal/resources/job_resource.go: при конфликте создания — читаем существующий job - runtimes/python3.11/server.py: str return → text/plain - internal/builder/context.go: python runtime base image → v0.1.3 - deployments/k8s/operator.yaml: image → v0.1.33 - doc/progress.md: добавлены секции FunctionJob bugfix, str→text/plain, web-console v0.2.0
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# Изменено: 2026-03-11
|
||||
# Изменено: 2026-03-18 (string return → text/plain без json.dumps)
|
||||
# HTTP-обёртка для serverless функций на Python 3.11.
|
||||
# Загружает модуль из SLESS_ENTRYPOINT или handler.py по умолчанию.
|
||||
# Формат SLESS_ENTRYPOINT: "module_name.func_name" (например: handler.handle)
|
||||
@@ -110,9 +110,16 @@ class FunctionHandler(BaseHTTPRequestHandler):
|
||||
self.wfile.write(body)
|
||||
|
||||
def _respond(self, status, data):
|
||||
body = json.dumps(data).encode("utf-8")
|
||||
# Если функция вернула строку — отдаём как text/plain без json.dumps.
|
||||
# Позволяет функциям возвращать человекочитаемый текст напрямую (curl без парсинга).
|
||||
if isinstance(data, str):
|
||||
body = data.encode("utf-8")
|
||||
ctype = "text/plain; charset=utf-8"
|
||||
else:
|
||||
body = json.dumps(data).encode("utf-8")
|
||||
ctype = "application/json"
|
||||
self.send_response(status)
|
||||
self.send_header("Content-Type", "application/json")
|
||||
self.send_header("Content-Type", ctype)
|
||||
self.send_header("Content-Length", str(len(body)))
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
|
||||
Reference in New Issue
Block a user