Skip to content

Commit 4c30889

Browse files
committed
Merge branch 'APL-11' of https://github.com/linode/apl-core into APL-11
2 parents bbd232d + aaafea6 commit 4c30889

File tree

6 files changed

+31
-42
lines changed

6 files changed

+31
-42
lines changed

src/common/k8s.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,11 @@ describe('StatefulSet tests', () => {
160160
),
161161
).resolves.not.toThrow()
162162

163-
expect(debug).toHaveBeenNthCalledWith(1, 'sts/argocd-application-controller pod has not desired resources')
164163
expect(debug).toHaveBeenNthCalledWith(
165-
2,
164+
1,
166165
'sts/argocd-application-controller has been patched with resources: {"requests":{"cpu":"500m","memory":"1Gi"},"limits":{"cpu":"1","memory":"2Gi"}}',
167166
)
168-
expect(debug).toHaveBeenNthCalledWith(3, 'sts/argocd-application-controller pods restarted')
167+
expect(debug).toHaveBeenNthCalledWith(2, 'sts/argocd-application-controller pods restarted')
169168
})
170169

171170
it('should log an error if no pods are found', async () => {
@@ -218,7 +217,7 @@ describe('StatefulSet tests', () => {
218217
mockDebugger,
219218
)
220219

221-
expect(debug).toBeCalledTimes(0)
220+
expect(debug).toBeCalledTimes(1)
222221
})
223222

224223
it('should log an error if an exception occurs', async () => {

src/common/k8s.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { AnyAaaaRecord, AnyARecord } from 'dns'
55
import { resolveAny } from 'dns/promises'
66
import { access, mkdir, writeFile } from 'fs/promises'
77
import { Agent } from 'https'
8-
import { isEmpty, map, mapValues } from 'lodash'
8+
import { isEmpty, isEqual, map, mapValues } from 'lodash'
99
import fetch, { RequestInit } from 'node-fetch'
1010
import { dirname, join } from 'path'
1111
import { parse, stringify } from 'yaml'
@@ -371,15 +371,23 @@ export async function patchContainerResourcesOfSts(
371371
for (const pod of pods.items) {
372372
const actualResources = pod.spec?.containers?.find((container) => container.name === containerName)?.resources
373373

374-
if (actualResources != desiredResources) {
375-
d.info(`sts/argocd-application-controller pod has not desired resources`)
374+
if (
375+
isEqual(actualResources?.limits, desiredResources?.limits) &&
376+
isEqual(actualResources?.requests, desiredResources?.requests)
377+
) {
378+
d.info(
379+
`sts/argocd-application-controller pod has desired resources: ${JSON.stringify(
380+
desiredResources,
381+
)} and actual resources: ${JSON.stringify(actualResources)}`,
382+
)
383+
return
384+
}
376385

377-
await patchStatefulSetResources(statefulSetName, containerName, namespace, desiredResources, appsApi, d)
378-
d.info(`sts/argocd-application-controller has been patched with resources: ${JSON.stringify(desiredResources)}`)
386+
await patchStatefulSetResources(statefulSetName, containerName, namespace, desiredResources, appsApi, d)
387+
d.info(`sts/argocd-application-controller has been patched with resources: ${JSON.stringify(desiredResources)}`)
379388

380-
await deleteStatefulSetPods(statefulSetName, namespace, appsApi, coreApi, d)
381-
d.info(`sts/argocd-application-controller pods restarted`)
382-
}
389+
await deleteStatefulSetPods(statefulSetName, namespace, appsApi, coreApi, d)
390+
d.info(`sts/argocd-application-controller pods restarted`)
383391
}
384392
} catch (error) {
385393
d.error(`Error patching StatefulSet ${statefulSetName}:`, error)

tests/bootstrap/input.yaml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ teamConfig:
3131
trigger: false
3232
mode:
3333
docker:
34-
repoUrl: https://github.com/redkubes/nodejs-helloworld
34+
repoUrl: https://github.com/linode/apl-nodejs-helloworld
3535
revision: HEAD
36-
path: ./Docker
36+
path: ./Dockerfile
3737
type: docker
3838
- name: demo-java-maven
3939
tag: v0.0.1
@@ -44,15 +44,6 @@ teamConfig:
4444
revision: HEAD
4545
path: apps/java-maven
4646
type: buildpacks
47-
- name: demo-java-trigger
48-
tag: v_0_0_1
49-
trigger: true
50-
mode:
51-
docker:
52-
repoUrl: https://github.com/buildpacks/samples
53-
revision: HEAD
54-
path: ./Docker
55-
type: docker
5647
services:
5748
- headers:
5849
response:
@@ -81,7 +72,7 @@ teamConfig:
8172
type: public
8273
workloads:
8374
- name: nodejs-helloworld
84-
url: https://github.com/redkubes/nodejs-helloworld.git
75+
url: https://github.com/linode/apl-nodejs-helloworld.git
8576
path: ./
8677
revision: HEAD
8778
- name: httpbin

tests/fixtures/env/teams/builds.demo.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ teamConfig:
88
docker:
99
repoUrl: https://github.com/buildpacks/samples
1010
revision: HEAD
11-
path: ./Docker
11+
path: ./Dockerfile
1212
type: docker
1313
externalRepo: false
1414
scanSource: true

tests/integration/minimal-with-team.yaml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ teamConfig:
3030
trigger: false
3131
mode:
3232
docker:
33-
repoUrl: https://github.com/redkubes/nodejs-helloworld
33+
repoUrl: https://github.com/linode/apl-nodejs-helloworld
3434
revision: HEAD
35-
path: ./Docker
35+
path: ./Dockerfile
3636
type: docker
3737
- name: demo-java-maven
3838
tag: v0.0.1
@@ -43,15 +43,6 @@ teamConfig:
4343
revision: HEAD
4444
path: apps/java-maven
4545
type: buildpacks
46-
- name: demo-java-trigger
47-
tag: v_0_0_1
48-
trigger: true
49-
mode:
50-
docker:
51-
repoUrl: https://github.com/buildpacks/samples
52-
revision: HEAD
53-
path: ./Docker
54-
type: docker
5546
services:
5647
- headers:
5748
response:
@@ -80,7 +71,7 @@ teamConfig:
8071
type: public
8172
workloads:
8273
- name: nodejs-helloworld
83-
url: https://github.com/redkubes/nodejs-helloworld.git
74+
url: https://github.com/linode/apl-nodejs-helloworld.git
8475
path: ./
8576
revision: HEAD
8677
- name: httpbin
@@ -101,7 +92,7 @@ teamConfig:
10192
services: []
10293
workloads:
10394
- name: nodejs-helloworld
104-
url: https://github.com/redkubes/nodejs-helloworld.git
95+
url: https://github.com/linode/apl-nodejs-helloworld.git
10596
path: ./
10697
revision: HEAD
10798
files:

tests/integration/upgrade.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ teamConfig:
6161
tag: v0.0.1
6262
mode:
6363
docker:
64-
repoUrl: https://github.com/redkubes/nodejs-helloworld
64+
repoUrl: https://github.com/linode/apl-nodejs-helloworld
6565
revision: HEAD
66-
path: ./Docker
66+
path: ./Dockerfile
6767
type: docker
6868
- name: demo-java-maven
6969
tag: v0.0.1
@@ -110,7 +110,7 @@ teamConfig:
110110
type: public
111111
workloads:
112112
- name: nodejs-helloworld
113-
url: https://github.com/redkubes/nodejs-helloworld.git
113+
url: https://github.com/linode/apl-nodejs-helloworld.git
114114
path: /
115115
revision: HEAD
116116
- name: httpbin
@@ -131,7 +131,7 @@ teamConfig:
131131
services: []
132132
workloads:
133133
- name: nodejs-helloworld
134-
url: https://github.com/redkubes/nodejs-helloworld.git
134+
url: https://github.com/linode/apl-nodejs-helloworld.git
135135
path: /
136136
revision: HEAD
137137
files:

0 commit comments

Comments
 (0)