Skip to content

Commit 4ca116f

Browse files
committed
feat: add CC_K8S_APP_MODE for kubernetes app mode selection
Signed-off-by: Anupam Kumar <kyteinsky@gmail.com>
1 parent cbca6e8 commit 4ca116f

4 files changed

Lines changed: 20 additions & 0 deletions

File tree

appinfo/info.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ Setup background job workers as described here: https://docs.nextcloud.com/serve
8181
<display-name>Password for authentication to CC_EM_BASE_URL</display-name>
8282
<description>Password to be used for authenticating requests to the OpenAI-compatible endpoint set in CC_EM_BASE_URL.</description>
8383
</variable>
84+
<variable>
85+
<name>CC_K8S_APP_MODE</name>
86+
<display-name>Mode to run the app in. Possible options: NORMAL, INDEXING, REQUEST_PROCESSING.</display-name>
87+
<description>Only applicable when the app is running with a Kubernetes daemon. Docker daemon installs should leave this at the NORMAL mode. INDEXING mode processes the documents, files and content providers, and processes the document and metadata updates. REQUEST_PROCESSING mode takes care of the query and document search requests. In Kubernetes, at least one pod should run with each type of mode.</description>
88+
<default>NORMAL</default>
89+
</variable>
8490
</environment-variables>
8591
</external-app>
8692
</info>

context_chat_backend/controller.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
def enabled_handler(enabled: bool, _: NextcloudApp | AsyncNextcloudApp) -> str:
7676
if enabled:
7777
app_enabled.set()
78+
# todo: start bg threads to fetch docs, updates and requests to process
7879
else:
7980
app_enabled.clear()
8081

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#
2+
# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
3+
# SPDX-License-Identifier: AGPL-3.0-or-later
4+
#

context_chat_backend/utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#
55
import logging
66
import multiprocessing as mp
7+
import os
78
import re
89
import traceback
910
from collections.abc import Callable
@@ -144,3 +145,11 @@ def redact_config(config: TConfig | TEmbeddingConfig) -> TConfig | TEmbeddingCon
144145
em_conf.auth.password = '***REDACTED***' # noqa: S105
145146

146147
return config_copy
148+
149+
150+
def get_app_mode() -> str:
151+
mode = os.getenv('CC_K8S_APP_MODE', 'NORMAL').upper()
152+
if mode not in ['NORMAL', 'INDEXING', 'REQUEST_PROCESSING']:
153+
_logger.warning(f'Invalid app mode: {mode}, defaulting to NORMAL')
154+
return 'NORMAL'
155+
return mode

0 commit comments

Comments
 (0)