@flowfuse/driver-kubernetes 2.28.0 → 2.28.1-28ae527-202603191414.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +9 -3
- package/kubernetes.js +60 -17
- package/package.json +1 -1
|
@@ -8,6 +8,10 @@ on:
|
|
|
8
8
|
branches:
|
|
9
9
|
- main
|
|
10
10
|
|
|
11
|
+
concurrency:
|
|
12
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
13
|
+
cancel-in-progress: true
|
|
14
|
+
|
|
11
15
|
jobs:
|
|
12
16
|
build:
|
|
13
17
|
uses: 'flowfuse/github-actions-workflows/.github/workflows/build_node_package.yml@v0.52.0'
|
|
@@ -32,10 +36,12 @@ jobs:
|
|
|
32
36
|
steps:
|
|
33
37
|
- name: Generate a token
|
|
34
38
|
id: generate_token
|
|
35
|
-
uses:
|
|
39
|
+
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
|
|
36
40
|
with:
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
app-id: ${{ secrets.GH_BOT_APP_ID }}
|
|
42
|
+
private-key: ${{ secrets.GH_BOT_APP_KEY }}
|
|
43
|
+
owner: ${{ github.repository_owner }}
|
|
44
|
+
repositories: helm
|
|
39
45
|
- name: Trigger flowfuse container build
|
|
40
46
|
uses: benc-uk/workflow-dispatch@7a027648b88c2413826b6ddd6c76114894dc5ec4 # v1.3.1
|
|
41
47
|
with:
|
package/kubernetes.js
CHANGED
|
@@ -732,6 +732,24 @@ const waitForInstanceRunning = async (endpoint) => {
|
|
|
732
732
|
})
|
|
733
733
|
}
|
|
734
734
|
|
|
735
|
+
// functions to wrap k8s api functions in retry logic
|
|
736
|
+
const retry = (api, func, args, delay, times) => {
|
|
737
|
+
return func.apply(api, args).catch(err => {
|
|
738
|
+
if (times > 0 && err.response && err.response.statusCode === 429) {
|
|
739
|
+
return new Promise(resolve => {
|
|
740
|
+
setTimeout(() => { resolve(retry(api, func, args, delay * 2, times - 1)) }, delay)
|
|
741
|
+
})
|
|
742
|
+
}
|
|
743
|
+
return Promise.reject(err)
|
|
744
|
+
})
|
|
745
|
+
}
|
|
746
|
+
const wrapClient = (api, funcs) => {
|
|
747
|
+
for (const f of funcs) {
|
|
748
|
+
const originalFunc = api[f.name]
|
|
749
|
+
api[f.name] = function () { return retry(api, originalFunc, arguments, this._k8sRetries, this._k8sDelay) }
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
|
|
735
753
|
module.exports = {
|
|
736
754
|
/**
|
|
737
755
|
* Initialises this driver
|
|
@@ -780,6 +798,25 @@ module.exports = {
|
|
|
780
798
|
this._k8sAppApi = kc.makeApiClient(k8s.AppsV1Api)
|
|
781
799
|
this._k8sNetApi = kc.makeApiClient(k8s.NetworkingV1Api)
|
|
782
800
|
|
|
801
|
+
// add retry logic to these functions
|
|
802
|
+
wrapClient(this._k8sApi, [
|
|
803
|
+
this._k8sApi.createNamespacedPersistentVolumeClaim,
|
|
804
|
+
this._k8sApi.createNamespacedService,
|
|
805
|
+
this._k8sApi.createNamespacedPod,
|
|
806
|
+
this._k8sApi.deleteNamespacedPod,
|
|
807
|
+
this._k8sApi.deleteNamespacedSecret,
|
|
808
|
+
this._k8sApi.deleteNamespacedService,
|
|
809
|
+
this._k8sApi.deleteNamespacedPersistentVolumeClaim
|
|
810
|
+
])
|
|
811
|
+
wrapClient(this._k8sAppApi, [
|
|
812
|
+
this._k8sAppApi.createNamespacedDeployment,
|
|
813
|
+
this._k8sAppApi.deleteNamespacedDeployment
|
|
814
|
+
])
|
|
815
|
+
wrapClient(this._k8sNetApi, [
|
|
816
|
+
this._k8sNetApi.createNamespacedIngress,
|
|
817
|
+
this._k8sNetApi.deleteNamespacedIngress
|
|
818
|
+
])
|
|
819
|
+
|
|
783
820
|
// Get a list of all projects - with the absolute minimum of fields returned
|
|
784
821
|
const projects = await app.db.models.Project.findAll({
|
|
785
822
|
attributes: [
|
|
@@ -974,17 +1011,20 @@ module.exports = {
|
|
|
974
1011
|
}
|
|
975
1012
|
|
|
976
1013
|
if (this._customHostname?.enabled) {
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
} catch (err) {
|
|
980
|
-
this._app.log.error(`[k8s] Instance ${project.id} - error deleting custom ingress: ${err.toString()} ${err.stack}`)
|
|
981
|
-
}
|
|
982
|
-
|
|
983
|
-
if (this._customHostname?.certManagerIssuer) {
|
|
1014
|
+
const customHostname = await project.getSetting('customHostname')
|
|
1015
|
+
if (customHostname) {
|
|
984
1016
|
try {
|
|
985
|
-
await this.
|
|
1017
|
+
await this._k8sNetApi.deleteNamespacedIngress({ name: `${project.safeName}-custom`, namespace: this._namespace })
|
|
986
1018
|
} catch (err) {
|
|
987
|
-
this._app.log.error(`[k8s] Instance ${project.id} - error deleting custom
|
|
1019
|
+
this._app.log.error(`[k8s] Instance ${project.id} - error deleting custom ingress: ${err.toString()} ${err.stack}`)
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
if (this._customHostname?.certManagerIssuer) {
|
|
1023
|
+
try {
|
|
1024
|
+
await this._k8sApi.deleteNamespacedSecret({ name: `${project.safeName}-custom`, namespace: this._namespace })
|
|
1025
|
+
} catch (err) {
|
|
1026
|
+
this._app.log.error(`[k8s] Instance ${project.id} - error deleting custom tls secret: ${err.toString()} ${err.stack}`)
|
|
1027
|
+
}
|
|
988
1028
|
}
|
|
989
1029
|
}
|
|
990
1030
|
}
|
|
@@ -1116,16 +1156,19 @@ module.exports = {
|
|
|
1116
1156
|
}
|
|
1117
1157
|
}
|
|
1118
1158
|
if (this._customHostname?.enabled) {
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
} catch (err) {
|
|
1122
|
-
this._app.log.error(`[k8s] Instance ${project.id} - error deleting custom ingress: ${err.toString()}`)
|
|
1123
|
-
}
|
|
1124
|
-
if (this._customHostname?.certManagerIssuer || this._customHostname?.certManagerAnnotations) {
|
|
1159
|
+
const customHostname = await project.getSetting('customHostname')
|
|
1160
|
+
if (customHostname) {
|
|
1125
1161
|
try {
|
|
1126
|
-
await this.
|
|
1162
|
+
await this._k8sNetApi.deleteNamespacedIngress({ name: `${project.safeName}-custom`, namespace: this._namespace })
|
|
1127
1163
|
} catch (err) {
|
|
1128
|
-
this._app.log.error(`[k8s] Instance ${project.id} - error deleting custom
|
|
1164
|
+
this._app.log.error(`[k8s] Instance ${project.id} - error deleting custom ingress: ${err.toString()}`)
|
|
1165
|
+
}
|
|
1166
|
+
if (this._customHostname?.certManagerIssuer || this._customHostname?.certManagerAnnotations) {
|
|
1167
|
+
try {
|
|
1168
|
+
await this._k8sApi.deleteNamespacedSecret({ name: `${project.safeName}-custom`, namespace: this._namespace })
|
|
1169
|
+
} catch (err) {
|
|
1170
|
+
this._app.log.error(`[k8s] Instance ${project.id} - error deleting custom tls secret: ${err.toString()}`)
|
|
1171
|
+
}
|
|
1129
1172
|
}
|
|
1130
1173
|
}
|
|
1131
1174
|
}
|