Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a19a9aa
chore: upgrade Gitea to 1.25.2
merll Nov 25, 2025
4a15bbc
fix: added post-install password validity reset
merll Nov 27, 2025
2b72aa8
Merge branch 'main' into APL-1266
merll Nov 27, 2025
88f302b
Merge branch 'main' into APL-1266
svcAPLBot Nov 27, 2025
5f54b30
Merge branch 'main' into APL-1266
svcAPLBot Nov 27, 2025
d882d8b
Merge branch 'main' into APL-1266
svcAPLBot Nov 27, 2025
8081fe2
feat: log output
merll Nov 27, 2025
3aaeeac
Merge branch 'main' into APL-1266
svcAPLBot Dec 1, 2025
18168e5
Merge branch 'main' into APL-1266
svcAPLBot Dec 1, 2025
6eac09a
Merge branch 'main' into APL-1266
svcAPLBot Dec 1, 2025
b3b29c5
Merge branch 'main' into APL-1266
svcAPLBot Dec 1, 2025
6534218
Merge branch 'main' into APL-1266
svcAPLBot Dec 1, 2025
dca96b6
Merge branch 'main' into APL-1266
svcAPLBot Dec 1, 2025
7c757ff
Merge branch 'main' into APL-1266
svcAPLBot Dec 1, 2025
f5f3a50
Merge branch 'main' into APL-1266
svcAPLBot Dec 1, 2025
23f102e
chore: move upgrade to following release
merll Dec 1, 2025
237e99b
Merge branch 'main' into APL-1266
svcAPLBot Dec 1, 2025
4f0c5fb
Merge branch 'main' into APL-1266
svcAPLBot Dec 1, 2025
21f30f7
Merge branch 'main' into APL-1266
svcAPLBot Dec 1, 2025
773b8eb
Merge branch 'main' into APL-1266
svcAPLBot Dec 2, 2025
4a27f74
Merge branch 'main' into APL-1266
svcAPLBot Dec 2, 2025
74a86a2
Merge branch 'main' into APL-1266
svcAPLBot Dec 2, 2025
cbc2380
Merge branch 'main' into APL-1266
svcAPLBot Dec 2, 2025
9c8fef1
Merge branch 'main' into APL-1266
svcAPLBot Dec 2, 2025
0e270b8
Merge branch 'main' into APL-1266
svcAPLBot Dec 3, 2025
b533783
Merge branch 'main' into APL-1266
svcAPLBot Dec 3, 2025
51a3ad5
Merge branch 'main' into APL-1266
svcAPLBot Dec 4, 2025
ed4f47c
Merge branch 'main' into APL-1266
svcAPLBot Dec 4, 2025
0b2c45c
Merge branch 'main' into APL-1266
svcAPLBot Dec 5, 2025
0b11f6c
Merge branch 'main' into APL-1266
svcAPLBot Dec 5, 2025
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
2 changes: 1 addition & 1 deletion charts/gitea/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ annotations:
- kind: changed
description: update alpine/helm docker tag to v3.19.0 (#954)
apiVersion: v2
appVersion: 1.24.7
appVersion: 1.25.2
dependencies:
- condition: postgresql.enabled
name: postgresql
Expand Down
40 changes: 40 additions & 0 deletions src/common/k8s.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
KubeConfig,
PatchStrategy,
setHeaderOptions,
V1Deployment,
V1Pod,
V1PodList,
V1ResourceRequirements,
Expand Down Expand Up @@ -169,6 +170,45 @@ describe('StatefulSet tests', () => {
jest.clearAllMocks()
})

describe('getPodsOfDeployment', () => {
it('should return pods matching the Deployment label selector', async () => {
const mockDeployment = {
spec: {
selector: {
matchLabels: { app: 'my-app' },
},
},
}

const mockPodList: V1PodList = {
items: [{ metadata: { name: 'pod-1' } }, { metadata: { name: 'pod-2' } }],
} as V1PodList

mockAppsApi.readNamespacedDeployment.mockResolvedValue(mockDeployment as any)
mockCoreApi.listNamespacedPod.mockResolvedValue(mockPodList as any)

const pods = await k8s.getPodsOfDeployment(mockAppsApi, mockCoreApi, 'my-deploy', 'my-namespace')
expect(mockAppsApi.readNamespacedDeployment).toHaveBeenCalledWith({
name: 'my-deploy',
namespace: 'my-namespace',
})
expect(mockCoreApi.listNamespacedPod).toHaveBeenCalledWith({
labelSelector: 'app=my-app',
namespace: 'my-namespace',
})
expect(pods).toEqual(mockPodList)
})

it('should throw an error if matchLabels is missing', async () => {
const mockDeployment: V1Deployment = {} as V1Deployment
mockAppsApi.readNamespacedDeployment.mockResolvedValue(mockDeployment as any)

await expect(k8s.getPodsOfDeployment(mockAppsApi, mockCoreApi, 'my-deploy', 'my-namespace')).rejects.toThrow(
'Deployment my-deploy does not have matchLabels',
)
})
})

describe('getPodsOfStatefulSet', () => {
it('should return pods matching the StatefulSet label selector', async () => {
const mockStatefulSet = {
Expand Down
22 changes: 22 additions & 0 deletions src/common/k8s.ts
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,28 @@ export async function createUpdateConfigMap(
}
}

export async function getPodsOfDeployment(
appsApi: AppsV1Api,
coreApi: CoreV1Api,
deploymentName: string,
namespace: string,
) {
const deployment = await appsApi.readNamespacedDeployment({ name: deploymentName, namespace })

if (!deployment.spec?.selector?.matchLabels) {
throw new Error(`Deployment ${deploymentName} does not have matchLabels`)
}

const labelSelector = Object.entries(deployment.spec.selector.matchLabels)
.map(([key, value]) => `${key}=${value}`)
.join(',')

return await coreApi.listNamespacedPod({
namespace,
labelSelector,
})
}

export async function getPodsOfStatefulSet(
appsApi: AppsV1Api,
statefulSetName: string,
Expand Down
12 changes: 11 additions & 1 deletion src/common/runtime-upgrades/runtime-upgrades.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { updateDbCollation } from './cloudnative-pg'
import { removeOldMinioResources } from './remove-old-minio-resources'
import { detectAndRestartOutdatedIstioSidecars } from './restart-istio-sidecars'
import { upgradeKnativeServing } from './upgrade-knative-serving-cr'
import { detachApplicationFromApplicationSet, pruneArgoCDImageUpdater } from './v4.13.0'
import { detachApplicationFromApplicationSet, pruneArgoCDImageUpdater, resetGiteaPasswordValidity } from './v4.13.0'
import { removeHttpBinApplication } from './remove-httpbin-application'

export interface RuntimeUpgradeContext {
Expand Down Expand Up @@ -151,4 +151,14 @@ export const runtimeUpgrades: RuntimeUpgrades = [
await removeHttpBinApplication()
},
},
{
version: '4.14.0',
applications: {
'gitea-gitea': {
post: async (context: RuntimeUpgradeContext) => {
await resetGiteaPasswordValidity(context)
},
},
},
},
]
21 changes: 20 additions & 1 deletion src/common/runtime-upgrades/v4.13.0.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApiException } from '@kubernetes/client-node'
import { ARGOCD_APP_PARAMS, ObjectMetadataCollection } from '../constants'
import { getArgoCdApp, k8s, setArgoCdAppSync } from '../k8s'
import { exec, getArgoCdApp, getK8sSecret, getPodsOfDeployment, k8s, setArgoCdAppSync } from '../k8s'
import { RuntimeUpgradeContext } from './runtime-upgrades'

async function scaleDeployment(context: RuntimeUpgradeContext, namespace: string, name: string, replicas: number) {
Expand Down Expand Up @@ -135,3 +135,22 @@ export async function detachApplicationFromApplicationSet(context: RuntimeUpgrad
await setArgoCdAppSync('argocd-argocd', true, customApi)
d.log('Cleanup complete: ApplicationSets removed, Applications retained.')
}

export async function resetGiteaPasswordValidity(context: RuntimeUpgradeContext) {
context.debug.info('Resetting status of Gitea admin credentials')
const giteaPods = await getPodsOfDeployment(k8s.app(), k8s.core(), 'gitea', 'gitea')
const [firstPod] = giteaPods.items
// In case Gitea pods happened to be restarting in the meantime, it will likely fix the issue by itself
if (firstPod) {
const giteaCredentialsSecret = await getK8sSecret('gitea-credentials', 'apl-operator')
const userName = giteaCredentialsSecret?.GITEA_USERNAME ?? 'otomi-admin'
const resetCmd = ['gitea', 'admin', 'user', 'must-change-password', '--unset', userName as string]
const { stdout, stderr } = await exec(
firstPod.metadata!.namespace as string,
firstPod.metadata!.name as string,
'gitea',
resetCmd,
)
context.debug.info(stderr, stdout)
}
}
Loading