From b9bd02978c96a701169e2a0c3f47049fd50deb47 Mon Sep 17 00:00:00 2001 From: Oleksander Piskun Date: Sat, 28 Feb 2026 17:19:20 +0200 Subject: [PATCH] feat(K8s): define second service role for easy testing Signed-off-by: Oleksander Piskun --- Makefile | 12 ++++++------ appinfo/info-latest.xml | 14 ++++++++++++++ appinfo/info.xml | 14 ++++++++++++++ ex_app/lib/main.py | 19 ++++++++++++++++++- 4 files changed, 52 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index bb82e05..b0e205b 100644 --- a/Makefile +++ b/Makefile @@ -18,10 +18,10 @@ help: @echo " > Next commands are only for the dev environment with nextcloud-docker-dev!" @echo " > They must be run from the host you are developing on, not in a Nextcloud container!" @echo " " - @echo " run31 installs $(APP_NAME) for Nextcloud 31" + @echo " run33 installs $(APP_NAME) for Nextcloud 31" @echo " run installs $(APP_NAME) for Nextcloud Latest" @echo " " - @echo " run31-latest installs $(APP_NAME) with 'latest' tag for Nextcloud 31" + @echo " run33-latest installs $(APP_NAME) with 'latest' tag for Nextcloud 31" @echo " run-latest installs $(APP_NAME) with 'latest' tag for Nextcloud Latest" .PHONY: build-push @@ -44,8 +44,8 @@ build-podman-latest: podman build --format=docker --platform linux/amd64 --tag ghcr.io/nextcloud/$(APP_ID):latest-cuda --build-arg BUILD_TYPE=cuda . podman build --format=docker --platform linux/amd64 --tag ghcr.io/nextcloud/$(APP_ID):latest-rocm --build-arg BUILD_TYPE=rocm . -.PHONY: run31 -run31: +.PHONY: run33 +run33: docker exec master-stable31-1 sudo -u www-data php occ app_api:app:register $(APP_ID) --test-deploy-mode \ --info-xml https://raw.githubusercontent.com/nextcloud/$(APP_ID)/main/appinfo/info.xml @@ -54,8 +54,8 @@ run: docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:register $(APP_ID) --test-deploy-mode \ --info-xml https://raw.githubusercontent.com/nextcloud/$(APP_ID)/main/appinfo/info.xml -.PHONY: run31-latest -run31-latest: +.PHONY: run33-latest +run33-latest: docker exec master-stable31-1 sudo -u www-data php occ app_api:app:register $(APP_ID) --test-deploy-mode \ --info-xml https://raw.githubusercontent.com/nextcloud/$(APP_ID)/main/appinfo/info-latest.xml diff --git a/appinfo/info-latest.xml b/appinfo/info-latest.xml index fe8933b..8e0bd78 100644 --- a/appinfo/info-latest.xml +++ b/appinfo/info-latest.xml @@ -25,5 +25,19 @@ nextcloud/test-deploy latest + + + rp + Request Processing + APP_ROLE=rp + true + + + worker + Background Worker + APP_ROLE=worker + false + + diff --git a/appinfo/info.xml b/appinfo/info.xml index a973b58..5dd88d4 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -25,5 +25,19 @@ nextcloud/test-deploy release + + + rp + Request Processing + APP_ROLE=rp + true + + + worker + Background Worker + APP_ROLE=worker + false + + diff --git a/ex_app/lib/main.py b/ex_app/lib/main.py index f5a202e..95b7fef 100644 --- a/ex_app/lib/main.py +++ b/ex_app/lib/main.py @@ -1,5 +1,8 @@ """Modified basic example for testing problems with deployment""" +import os +import socket +import time from contextlib import asynccontextmanager import httpx @@ -13,6 +16,8 @@ set_handlers, ) +APP_ROLE = os.environ.get("APP_ROLE", "") + @asynccontextmanager async def lifespan(app: FastAPI): @@ -119,6 +124,18 @@ def enabled_handler(enabled: bool, _nc: NextcloudApp) -> str: return r +def run_worker() -> None: + """Entry point for the worker role (no HTTP server).""" + hostname = socket.gethostname() + print(f"[worker] Starting on {hostname}, APP_ROLE={APP_ROLE}", flush=True) + while True: + print(f"[worker] {hostname} is alive", flush=True) + time.sleep(300) + + if __name__ == "__main__": print("Started", flush=True) - run_app("main:APP", log_level="trace") + if APP_ROLE == "worker": + run_worker() + else: + run_app("main:APP", log_level="trace")