diff --git a/chart/apl/templates/deployment.yaml b/chart/apl/templates/deployment.yaml index 27545924b3..fc07ababcf 100644 --- a/chart/apl/templates/deployment.yaml +++ b/chart/apl/templates/deployment.yaml @@ -73,9 +73,15 @@ spec: - name: GIT_REPO value: {{ .Values.operator.gitRepo | default "values" | quote }} - name: POLL_INTERVAL_MS - value: {{ .Values.operator.pollIntervalMs | default "30000" | quote }} + value: {{ .Values.operator.pollIntervalMs | quote }} - name: RECONCILE_INTERVAL_MS - value: {{ .Values.operator.reconcileIntervalMs | default "300000" | quote }} + value: {{ .Values.operator.reconcileIntervalMs | quote }} + - name: GIT_OP_TIMEOUT_MS + value: {{ .Values.operator.gitOpTimeoutMs | quote }} + - name: INSTALL_RETRIES + value: {{ .Values.operator.installRetries | quote }} + - name: INSTALL_MAX_TIMEOUT_MS + value: {{ .Values.operator.installMaxTimeoutMs | quote }} volumeMounts: - name: otomi-values mountPath: /home/app/stack/env diff --git a/chart/apl/values.yaml b/chart/apl/values.yaml index 9ec9beee63..24cbb4bf98 100644 --- a/chart/apl/values.yaml +++ b/chart/apl/values.yaml @@ -145,9 +145,13 @@ operator: # Git repository name (will be configured during installation) gitRepo: "values" # Polling interval for git changes (milliseconds) - pollIntervalMs: 1000 + pollIntervalMs: 30000 # Reconcile interval for applying changes (milliseconds) reconcileIntervalMs: 300000 + gitOpTimeoutMs: 10000 + installRetries: 1000 + installMaxTimeoutMs: 10000 + installation: mode: standard diff --git a/charts/apl-operator/templates/deployment.yaml b/charts/apl-operator/templates/deployment.yaml index 2ddbf7bab2..7409a36c7b 100644 --- a/charts/apl-operator/templates/deployment.yaml +++ b/charts/apl-operator/templates/deployment.yaml @@ -45,6 +45,16 @@ spec: env: - name: CI value: "true" + - name: POLL_INTERVAL_MS + value: {{ .Values.operator.pollIntervalMs | quote }} + - name: RECONCILE_INTERVAL_MS + value: {{ .Values.operator.reconcileIntervalMs | quote }} + - name: GIT_OP_TIMEOUT_MS + value: {{ .Values.operator.gitOpTimeoutMs | quote }} + - name: INSTALL_RETRIES + value: {{ .Values.operator.installRetries | quote }} + - name: INSTALL_MAX_TIMEOUT_MS + value: {{ .Values.operator.installMaxTimeoutMs | quote }} envFrom: - secretRef: name: apl-sops-secrets diff --git a/charts/apl-operator/values.yaml b/charts/apl-operator/values.yaml index bd0661b900..b7b5dc9b10 100644 --- a/charts/apl-operator/values.yaml +++ b/charts/apl-operator/values.yaml @@ -47,6 +47,17 @@ resources: {} # memory: 128Mi +## APL Operator configuration +operator: + # Git organization/user name (will be configured during installation) + gitOrg: "otomi" + # Git repository name (will be configured during installation) + gitRepo: "values" + pollIntervalMs: 15000 + reconcileIntervalMs: 300000 + gitOpTimeoutMs: 10000 + installRetries: 1000 + installMaxTimeoutMs: 10000 nodeSelector: {} @@ -60,6 +71,8 @@ commandArgs: [] env: {} + + kms: {} # example: # sops: diff --git a/src/operator/git-repository.test.ts b/src/operator/git-repository.test.ts index a0992d52b6..62eac2bb6e 100644 --- a/src/operator/git-repository.test.ts +++ b/src/operator/git-repository.test.ts @@ -51,6 +51,7 @@ describe('GitRepository', () => { branch: 'main', username: 'testuser', email: 'test@example.com', + gitOpTimeoutMs: 10000, } const simpleGit = require('simple-git') @@ -368,6 +369,7 @@ describe('GitRepository', () => { branch: 'feature-branch', username: 'testuser', email: 'test@example.com', + gitOpTimeoutMs: 10000, }) mockGit.fetch.mockResolvedValue(undefined) diff --git a/src/operator/git-repository.ts b/src/operator/git-repository.ts index da8b8070da..cc27a659d7 100644 --- a/src/operator/git-repository.ts +++ b/src/operator/git-repository.ts @@ -16,6 +16,7 @@ export interface GitRepositoryConfig { branch: string username?: string email: string + gitOpTimeoutMs: number } export class GitRepository { @@ -35,7 +36,10 @@ export class GitRepository { this.branch = config.branch this.username = config.username ?? 'otomi-admin' this.email = config.email - this.git = simpleGit(this.repoPath) + this.git = simpleGit({ + baseDir: this.repoPath, + timeout: { block: config.gitOpTimeoutMs }, + }) this._config = { repoUrl: config.repoUrl, authenticatedUrl: config.authenticatedUrl, diff --git a/src/operator/main.ts b/src/operator/main.ts index c9cb0e0082..f746a4d243 100644 --- a/src/operator/main.ts +++ b/src/operator/main.ts @@ -2,6 +2,7 @@ import * as dotenv from 'dotenv' import fs from 'fs' import process from 'node:process' import path from 'path' +import { retryInstallStep } from '../cmd/install' import { terminal } from '../common/debug' import { env } from '../common/envalid' import { getStoredGitRepoConfig } from '../common/git-config' @@ -11,7 +12,6 @@ import { GitRepository } from './git-repository' import { Installer } from './installer' import { getErrorMessage } from './utils' import { operatorEnv } from './validators' -import { retryInstallStep } from '../cmd/install' dotenv.config() @@ -27,6 +27,7 @@ async function loadConfig(aplOps: AplOperations): Promise { const gitRepository = new GitRepository({ ...gitConfig, repoPath: env.ENV_DIR, + gitOpTimeoutMs: operatorEnv.GIT_OP_TIMEOUT_MS, }) return { diff --git a/src/operator/validators.ts b/src/operator/validators.ts index 09ac7dd5c4..482b262cc1 100644 --- a/src/operator/validators.ts +++ b/src/operator/validators.ts @@ -12,8 +12,9 @@ export const operatorEnv = cleanEnv(process.env, { desc: 'Path to the gitops manifests global', default: 'env/manifests/global', }), - POLL_INTERVAL_MS: num({ desc: 'Interval in which the operator polls Git', default: 1000 }), + POLL_INTERVAL_MS: num({ desc: 'Interval in which the operator polls Git', default: 15000 }), RECONCILE_INTERVAL_MS: num({ desc: 'Interval in which the operator reconciles the cluster in', default: 300_000 }), + GIT_OP_TIMEOUT_MS: num({ desc: 'Timeout in milliseconds for a single git operation', default: 10000 }), INSTALL_RETRIES: num({ desc: 'Number of installation retry attempts', default: 1000 }), INSTALL_MAX_TIMEOUT_MS: num({ desc: 'Maximum timeout for installation retries in milliseconds', default: 10000 }), })