Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions chart/apl/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion chart/apl/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions charts/apl-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions charts/apl-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}

Expand All @@ -60,6 +71,8 @@ commandArgs: []

env: {}



kms: {}
# example:
# sops:
Expand Down
2 changes: 2 additions & 0 deletions src/operator/git-repository.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ describe('GitRepository', () => {
branch: 'main',
username: 'testuser',
email: 'test@example.com',
gitOpTimeoutMs: 10000,
}

const simpleGit = require('simple-git')
Expand Down Expand Up @@ -368,6 +369,7 @@ describe('GitRepository', () => {
branch: 'feature-branch',
username: 'testuser',
email: 'test@example.com',
gitOpTimeoutMs: 10000,
})

mockGit.fetch.mockResolvedValue(undefined)
Expand Down
6 changes: 5 additions & 1 deletion src/operator/git-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface GitRepositoryConfig {
branch: string
username?: string
email: string
gitOpTimeoutMs: number
}

export class GitRepository {
Expand All @@ -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 },
})
Comment thread
Copilot marked this conversation as resolved.
this._config = {
repoUrl: config.repoUrl,
authenticatedUrl: config.authenticatedUrl,
Expand Down
3 changes: 2 additions & 1 deletion src/operator/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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()

Expand All @@ -27,6 +27,7 @@ async function loadConfig(aplOps: AplOperations): Promise<AplOperatorConfig> {
const gitRepository = new GitRepository({
...gitConfig,
repoPath: env.ENV_DIR,
gitOpTimeoutMs: operatorEnv.GIT_OP_TIMEOUT_MS,
})

return {
Expand Down
3 changes: 2 additions & 1 deletion src/operator/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }),
})
Loading