@leverege/build-tools 2.57.3 → 2.58.0-pedro.1

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.
Files changed (36) hide show
  1. package/package.json +7 -4
  2. package/src/Docker.mjs +15 -4
  3. package/src/circleate.sh +9 -2
  4. package/src/helm-charts/api-server/values-local.yaml +1 -1
  5. package/src/helm-charts/authz-server/values-local.yaml +1 -1
  6. package/src/helm-charts/db-curator/values-local.yaml +1 -1
  7. package/src/helm-charts/emailer/values-local.yaml +1 -1
  8. package/src/helm-charts/fota-server/values-local.yaml +4 -1
  9. package/src/helm-charts/message-processor/values-local.yaml +4 -1
  10. package/src/helm-charts/messenger/values-local.yaml +1 -1
  11. package/src/helm-charts/prom-operator/helmup.plugin +1 -1
  12. package/src/helm-charts/prom-operator/prometheus-stack.yaml.ovh +16 -9
  13. package/src/helm-charts/prom-operator/rules/cnpg-rules.yaml +125 -0
  14. package/src/helm-charts/prom-operator/rules/{elasticsearch-rules.yaml.ovh → elasticsearch-rules.yaml} +0 -10
  15. package/src/helm-charts/prom-operator/rules/{gcp-rules.yaml.ovh → gcp-rules.yaml} +0 -3
  16. package/src/helm-charts/prom-operator/rules/{kubernetes-rules.yaml.ovh → kubernetes-rules.yaml} +0 -3
  17. package/src/helm-charts/prom-operator/rules/{leverege-rules.yaml.ovh → leverege-rules.yaml} +0 -1
  18. package/src/helm-charts/prom-operator/rules/{postgres-rules.yaml.ovh → postgres-rules.yaml} +0 -18
  19. package/src/helm-charts/prom-operator/rules/{redis-rules.yaml.ovh → redis-rules.yaml} +0 -9
  20. package/src/helm-charts/prom-operator/rules/{traefik-rules.yaml.ovh → traefik-rules.yaml} +0 -1
  21. package/src/helm-charts/prom-operator/rules/{velero-rules.yaml.ovh → velero-rules.yaml} +0 -2
  22. package/src/helm-charts/prom-operator/stackdriver-exporter.yaml.ovh +1 -1
  23. package/src/helm-charts/prom-operator/update-crd.sh +15 -0
  24. package/src/helm-charts/redis/helmup.plugin +1 -1
  25. package/src/helm-charts/resource-server/values-local.yaml +1 -1
  26. package/src/helm-charts/scheduler/values-local.yaml +1 -1
  27. package/src/helm-charts/transponder-bq/values-local.yaml +1 -1
  28. package/src/helm-charts/transponder-dh/values-local.yaml +1 -1
  29. package/src/helm-charts/transponder-rt/values-local.yaml +1 -1
  30. package/src/helm-charts/transponder-tsdb/values-local.yaml +1 -1
  31. package/src/helm-charts/vin-decoder-server/values-local.yaml +7 -0
  32. package/src/overwhelm.mjs +48 -36
  33. package/src/pkgck.sh +11 -2
  34. package/src/push-model-registry.mjs +145 -0
  35. package/src/helm-charts/prom-operator/rules/gitignore +0 -1
  36. /package/src/helm-charts/prom-operator/rules/{prometheus-rules.yaml.ovh → prometheus-rules.yaml} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.57.3",
3
+ "version": "2.58.0-pedro.1",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -48,6 +48,7 @@
48
48
  "pkglint": "src/pkglint.sh",
49
49
  "prune-git": "src/prune-git.sh",
50
50
  "pull-git": "src/pull-git.sh",
51
+ "push-model-to-registry": "src/push-model-to-registry.mjs",
51
52
  "push-my-chart": "src/push-my-chart.mjs",
52
53
  "refresh-npm-token": "src/refresh-npm-token.mjs",
53
54
  "refresh-py-idx": "src/refresh-py-idx.sh",
@@ -59,6 +60,7 @@
59
60
  "license": "SEE LICENSE IN LICENSE.md",
60
61
  "dependencies": {
61
62
  "@google-cloud/artifact-registry": "^3.5.0",
63
+ "@google-cloud/storage": "^7.14.0",
62
64
  "ansi-colors": "^4.1.3",
63
65
  "chalk": "^5.3.0",
64
66
  "command-line-args": "^6.0.1",
@@ -66,6 +68,7 @@
66
68
  "deepmerge": "^4.3.1",
67
69
  "enquirer": "^2.4.1",
68
70
  "execa": "^9.5.1",
71
+ "fast-crc32c": "^2.0.0",
69
72
  "glob": "^11.0.0",
70
73
  "handlebars": "^4.7.8",
71
74
  "inquirer": "^12.1.0",
@@ -78,10 +81,10 @@
78
81
  "readline-sync": "^1.4.10",
79
82
  "semver": "^7.6.3",
80
83
  "simple-git": "^3.27.0",
81
- "zx": "^8.2.2"
84
+ "zx": "^8.2.4"
82
85
  },
83
86
  "devDependencies": {
84
87
  "@leverege/eslint-config-leverege": "^5.0.1",
85
- "npm": "^10.9.0"
88
+ "npm": "^10.9.1"
86
89
  }
87
- }
90
+ }
package/src/Docker.mjs CHANGED
@@ -23,6 +23,7 @@ const dockerfileTemplate = `
23
23
  # The FROM directive sets the Base Image for subsequent instructions
24
24
  FROM node:{{nodeimage}} as intermediate
25
25
  ENV NODE_ENV production
26
+ ENV NPM_CONFIG_USERCONFIG /usr/src/app/.npmrc
26
27
 
27
28
  RUN mkdir -p /usr/src/app
28
29
  WORKDIR /usr/src/app
@@ -36,7 +37,7 @@ ENV GRPC_VERBOSITY ERROR
36
37
  # --------------------------------------------------------------
37
38
 
38
39
  # Install packages to install private repos with ssh keys
39
- COPY ./.npmrc /usr/src/app/.npmrc
40
+ COPY ./.npmrc \${NPM_CONFIG_USERCONFIG}
40
41
  RUN apk --no-cache add openssh-client && \
41
42
  apk --update add --no-cache --virtual build-dep g++ gcc libgcc \\
42
43
  libstdc++ linux-headers make {{apkadds}} && \
@@ -44,16 +45,22 @@ RUN apk --no-cache add openssh-client && \
44
45
 
45
46
  {{preInstallPluginfile}}
46
47
 
47
- # Removed --ignore-scripts from npm ci because it was causing issues with python native build
48
+ # Use SKIP_PREPARE to disable hook-and-release from running
48
49
  ENV SKIP_PREPARE=true
50
+
51
+ # Do the clean install and remove the npm token and ssh keys from the image
49
52
  RUN npm ci --only=production --no-optional {{npmlogging}} && \
50
- rm -f /usr/src/app/.npmrc /root/.ssh/*
53
+ rm -f \${NPM_CONFIG_USERCONFIG} /root/.ssh/*
51
54
 
52
55
  # --------------------------------------------------------------
53
- # On to the real build now, the thing before was just an intermediate container
56
+ # Docker Final Stage
54
57
  # --------------------------------------------------------------
55
58
 
56
59
  FROM node:{{nodeimage}}
60
+ ENV NPM_CONFIG_USERCONFIG /usr/src/app/.npmrc
61
+
62
+ # Copy .npmrc for private registry access for access to any @leverege packages
63
+ COPY ./.npmrc \${NPM_CONFIG_USERCONFIG}
57
64
 
58
65
  # Install tini for PID 1 and replace shell with bash so we can source files
59
66
  RUN apk update && \
@@ -63,8 +70,12 @@ RUN apk update && \
63
70
  mkdir -p /usr/src/app /tmp/levlog && \
64
71
  chown node:node /usr/src/app
65
72
 
73
+ # Pull in the Dockerfile.plugin file here
66
74
  {{pluginfile}}
67
75
 
76
+ # Eliminate the sensitive info from the final stage image
77
+ RUN rm -f \${NPM_CONFIG_USERCONFIG}
78
+
68
79
  ENTRYPOINT [ "/sbin/tini", "--" ]
69
80
  WORKDIR /usr/src/app
70
81
 
package/src/circleate.sh CHANGED
@@ -11,6 +11,7 @@ fi
11
11
 
12
12
  repo_type=$1
13
13
  CIRCLE_NODE_IMG="cimg/node:lts"
14
+ DOC_CREATOR_ENDPOINT="https://doc-creator.leverege.com/buildDocs/$(basename $npm_package_name)"
14
15
 
15
16
  check_circle_config(){
16
17
  if [ -d "./.circleci" ];
@@ -87,7 +88,7 @@ jobs:
87
88
  at: ~/project
88
89
  - run:
89
90
  name: Check for vulnerabilities
90
- command: npm audit --production --audit-level=moderate
91
+ command: npm audit --omit=dev --audit-level=moderate
91
92
 
92
93
  license-check:
93
94
  docker:
@@ -131,6 +132,9 @@ jobs:
131
132
  - store_artifacts:
132
133
  path: docs
133
134
  prefix: docs
135
+ - run:
136
+ name: Initiate document creation
137
+ command: curl -X GET "$DOC_CREATOR_ENDPOINT"
134
138
 
135
139
  coverage:
136
140
  # coverage runs tests, generates coverage, and saves docs
@@ -303,7 +307,7 @@ jobs:
303
307
  at: ~/project
304
308
  - run:
305
309
  name: Check for vulnerabilities
306
- command: npm audit --production --audit-level=moderate
310
+ command: npm audit --omit=dev --audit-level=moderate
307
311
 
308
312
  license-check:
309
313
  docker:
@@ -347,6 +351,9 @@ jobs:
347
351
  - store_artifacts:
348
352
  path: docs
349
353
  prefix: docs
354
+ - run:
355
+ name: Initiate document creation
356
+ command: curl -X GET "$DOC_CREATOR_ENDPOINT"
350
357
 
351
358
  coverage:
352
359
  # coverage runs tests, generates coverage, and saves docs
@@ -5,7 +5,7 @@
5
5
  # - node tools/UpdateESMappingV2.js
6
6
  #
7
7
  image:
8
- tag: # v5.16.0
8
+ tag: # v5.17.5
9
9
 
10
10
  config:
11
11
  LOG_CONFIG: '{"type":"pino","level":"warn"}'
@@ -4,7 +4,7 @@
4
4
  # - npm run sequelizeRunMigrations
5
5
  #
6
6
  image:
7
- tag: # v2.2.0
7
+ tag: # v2.4.0
8
8
 
9
9
  config:
10
10
  LOG_CONFIG: '{"type":"pino","level":"warn"}'
@@ -1,5 +1,5 @@
1
1
  image:
2
- tag: # v4.3.0
2
+ tag: # v4.4.2
3
3
 
4
4
  config:
5
5
  LOG_CONFIG: '{"type":"pino","level":"warn"}'
@@ -1,5 +1,5 @@
1
1
  image:
2
- tag: # v3.5.1
2
+ tag: # v3.7.0
3
3
 
4
4
  config:
5
5
  LOG_CONFIG: '{"type":"pino","level":"warn"}'
@@ -1,5 +1,5 @@
1
1
  image:
2
- tag: # v1.2.2
2
+ tag: # v2.1.0
3
3
 
4
4
  config:
5
5
  LOG_CONFIG: '{"type":"pino","level":"warn"}'
@@ -9,3 +9,6 @@ config:
9
9
 
10
10
  # CNPG override
11
11
  # SQL_HOST: "cnpg-db-psql-stack-rw.cnpg-operands" # vs postgres-postgresql
12
+
13
+ serviceMonitor:
14
+ enabled: false
@@ -1,5 +1,8 @@
1
1
  image:
2
- tag: # v4.0.0
2
+ tag: # v4.2.0
3
3
 
4
4
  config:
5
5
  LOG_CONFIG: '{"type":"pino","level":"warn"}'
6
+
7
+ serviceMonitor:
8
+ enabled: false
@@ -1,5 +1,5 @@
1
1
  image:
2
- tag: # v2.11.1
2
+ tag: # v2.14.0
3
3
 
4
4
  config:
5
5
  LOG_CONFIG: '{"type":"pino","level":"warn"}'
@@ -4,7 +4,7 @@ showInstalling "The Prometheus Operator and Components"
4
4
  addHelmRepo prometheus-community https://prometheus-community.github.io/helm-charts
5
5
 
6
6
  showInstalling "The Prometheus Operator (kube-prometheus-stack)"
7
- [ -z "$PROMETHEUS_STACK_CHART_VERSION" ] && PROMETHEUS_STACK_CHART_VERSION="65"
7
+ [ -z "$PROMETHEUS_STACK_CHART_VERSION" ] && PROMETHEUS_STACK_CHART_VERSION="66"
8
8
 
9
9
  NS="--namespace prometheus"
10
10
 
@@ -33,6 +33,8 @@ defaultRules:
33
33
 
34
34
  prometheus:
35
35
  prometheusSpec:
36
+ # image:
37
+ # tag: "v3.0.0"
36
38
  podMonitorSelectorNilUsesHelmValues: false
37
39
  ruleSelectorNilUsesHelmValues: false
38
40
  serviceMonitorSelectorNilUsesHelmValues: false
@@ -55,6 +57,11 @@ grafana:
55
57
  # -- the grafana admin password
56
58
  adminPassword: leverege-monitoring
57
59
  defaultDashboardsEnabled: false
60
+ persistence:
61
+ enabled: true
62
+ size: 10Gi
63
+ accessModes:
64
+ - ReadWriteOnce
58
65
  sidecar:
59
66
  dashboards:
60
67
  enabled: true
@@ -68,7 +75,7 @@ grafana:
68
75
  entryPoints:
69
76
  - websecure
70
77
  routes:
71
- - match: Host(`OVH:<PROJECT_NAME>-promop.OVH:<HOST>.com`)
78
+ - match: Host(`${PROJECT_NAME}-promop.${HOST}.com`)
72
79
  kind: Rule
73
80
  services:
74
81
  - name: prometheus-stack-grafana
@@ -98,10 +105,10 @@ alertmanager:
98
105
  receivers:
99
106
  - name: slack
100
107
  slack_configs:
101
- - channel: "OVH:<SLACK_CHANNEL>"
102
- api_url: "OVH:<SLACK_HOOK_URL>"
103
- username: "OVH:<PROJECT_NAME>"
104
- fallback: "OVH:<PROJECT_NAME> - {{ .CommonAnnotations.summary }}"
108
+ - channel: "${SLACK_CHANNEL}"
109
+ api_url: "${SLACK_HOOK_URL}"
110
+ username: "${PROJECT_NAME}"
111
+ fallback: "${PROJECT_NAME} - {{ .CommonAnnotations.summary }}"
105
112
  title: "{{ range .Alerts }}{{ .Annotations.summary }}\n{{ end }}"
106
113
  title_link: "https://bitbucket.org/leverege/sre-playbook/src/master/"
107
114
  send_resolved: true
@@ -114,9 +121,9 @@ alertmanager:
114
121
  - name: slack-watchdog
115
122
  slack_configs:
116
123
  - channel: "#dead-mans-snitch_notifications"
117
- api_url: "OVH:<SLACK_HOOK_URL>"
118
- username: "OVH:<PROJECT_NAME>"
119
- fallback: "OVH:<PROJECT_NAME> - {{ .CommonAnnotations.summary }}"
124
+ api_url: "${SLACK_HOOK_URL}"
125
+ username: "${PROJECT_NAME}"
126
+ fallback: "${PROJECT_NAME} - {{ .CommonAnnotations.summary }}"
120
127
  title: "Watchdog Alert - Dead Man's Snitch"
121
128
  # text: "This is a periodic test alert to confirm the alert pipeline is functional."
122
129
  text: |-
@@ -127,7 +134,7 @@ alertmanager:
127
134
  {{ end }}
128
135
  - name: opsgenie
129
136
  opsgenie_configs:
130
- - api_key: "OVH:<OPSGENIE_APIKEY>"
137
+ - api_key: "${OPSGENIE_APIKEY}"
131
138
  priority: "{{ .CommonLabels.priority }}"
132
139
  tags: "{{ range .Alerts }}{{ .Labels.severity }},{{ end }}"
133
140
  description: |-
@@ -0,0 +1,125 @@
1
+ apiVersion: monitoring.coreos.com/v1
2
+ kind: PrometheusRule
3
+ metadata:
4
+ name: cnpg-default-alerts
5
+ spec:
6
+ groups:
7
+ - name: cnpg-default.rules
8
+ rules:
9
+ - alert: LongRunningTransaction
10
+ annotations:
11
+ description: Pod {{ $labels.pod }} is taking more than 5 minutes (300 seconds) for a query.
12
+ summary: A query is taking longer than 5 minutes.
13
+ expr: |-
14
+ cnpg_backends_max_tx_duration_seconds > 300
15
+ for: 1m
16
+ labels:
17
+ severity: warning
18
+ - alert: BackendsWaiting
19
+ annotations:
20
+ description: Pod {{ $labels.pod }} has been waiting for longer than 5 minutes
21
+ summary: If a backend is waiting for longer than 5 minutes
22
+ expr: |-
23
+ cnpg_backends_waiting_total > 300
24
+ for: 1m
25
+ labels:
26
+ severity: warning
27
+ - alert: PGDatabaseXidAge
28
+ annotations:
29
+ description: Over 150,000,000 transactions from frozen xid on pod {{ $labels.pod }}
30
+ summary: Number of transactions from the frozen XID to the current one
31
+ expr: |-
32
+ cnpg_pg_database_xid_age > 300000000
33
+ for: 1m
34
+ labels:
35
+ severity: warning
36
+ - alert: PGReplication
37
+ annotations:
38
+ description: Standby is lagging behind by over 300 seconds (5 minutes)
39
+ summary: The standby is lagging behind the primary
40
+ expr: |-
41
+ cnpg_pg_replication_lag > 300
42
+ for: 1m
43
+ labels:
44
+ severity: warning
45
+ - alert: LastFailedArchiveTime
46
+ annotations:
47
+ description: Archiving failed for {{ $labels.pod }}
48
+ summary: Checks the last time archiving failed. Will be < 0 when it has not failed.
49
+ expr: |-
50
+ (cnpg_pg_stat_archiver_last_failed_time - cnpg_pg_stat_archiver_last_archived_time) > 1
51
+ for: 1m
52
+ labels:
53
+ severity: warning
54
+ - alert: DatabaseDeadlockConflicts
55
+ annotations:
56
+ description: There are over 10 deadlock conflicts in {{ $labels.pod }}
57
+ summary: Checks the number of database conflicts
58
+ expr: |-
59
+ cnpg_pg_stat_database_deadlocks > 10
60
+ for: 1m
61
+ labels:
62
+ severity: warning
63
+ - alert: ReplicaFailingReplication
64
+ annotations:
65
+ description: Replica {{ $labels.pod }} is failing to replicate
66
+ summary: Checks if the replica is failing to replicate
67
+ expr: |-
68
+ cnpg_pg_replication_in_recovery > cnpg_pg_replication_is_wal_receiver_up
69
+ for: 1m
70
+ labels:
71
+ severity: warning
72
+ #
73
+ # folding in rules based on non-cnpg postgres metrics
74
+ #
75
+ - alert: PostgresqlDown
76
+ expr: cnpg_collector_up == 0
77
+ for: 0m
78
+ labels:
79
+ severity: critical
80
+ annotations:
81
+ summary: Postgresql down (instance {{ $labels.instance }})
82
+ description: "Postgresql instance is down\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
83
+
84
+ - alert: PostgresqlRestarted
85
+ expr: time() - cnpg_pg_postmaster_start_time < 60
86
+ for: 0m
87
+ labels:
88
+ severity: critical
89
+ annotations:
90
+ summary: Postgresql restarted (instance {{ $labels.instance }})
91
+ description: "Postgresql restarted\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
92
+
93
+ - alert: PostgresqlHighRollbackRate
94
+ expr: sum by (namespace,datname) ((rate(cnpg_pg_stat_database_xact_rollback{datname!~"template.*|postgres",datid!="0"}[3m])) / ((rate(cnpg_pg_stat_database_xact_rollback{datname!~"template.*|postgres",datid!="0"}[3m])) + (rate(cnpg_pg_stat_database_xact_commit{datname!~"template.*|postgres",datid!="0"}[3m])))) > 0.02
95
+ for: 0m
96
+ labels:
97
+ severity: warning
98
+ annotations:
99
+ summary: Postgresql high rollback rate (instance {{ $labels.instance }})
100
+ description: "Ratio of transactions being aborted compared to committed is > 2 %\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
101
+
102
+ # - alert: PostgresqlCommitRateLow
103
+ # expr: rate(pg_stat_database_xact_commit[1m]) < 10
104
+ # for: 2m
105
+ # labels:
106
+ # severity: critical
107
+ # annotations:
108
+ # summary: Postgresql commit rate low (instance {{ $labels.instance }})
109
+ # description: "Postgresql seems to be processing very few transactions\n VALUE = {{ $value }}\n LABELS = {{ $labels }}" - alert: PostgresqlCommitRateLow
110
+ # expr: rate(cnpg_pg_stat_database_xact_commit[1m]) < 10
111
+ # for: 2m
112
+ # labels:
113
+ # severity: critical
114
+ # annotations:
115
+ # summary: Postgresql commit rate low (instance {{ $labels.instance }})
116
+ # description: "Postgresql seems to be processing very few transactions\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
117
+
118
+ # - alert: PostgresqlUnusedReplicationSlot
119
+ # expr: cnpg_pg_replication_slots_active == 0
120
+ # for: 1m
121
+ # labels:
122
+ # severity: warning
123
+ # annotations:
124
+ # summary: Postgresql unused replication slot (instance {{ $labels.instance }})
125
+ # description: "Unused Replication Slots\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
@@ -17,7 +17,6 @@ spec:
17
17
  annotations:
18
18
  summary: "Elasticsearch Heap Usage Too High (instance {{ $labels.instance }})"
19
19
  description: "The heap usage is over 90% for 5m (currently at {{ $value }}% )"
20
- dashboard: "OVH:<MONITORING>/elasticsearch"
21
20
 
22
21
  - alert: ElasticsearchHeapUsageWarning
23
22
  expr: (elasticsearch_jvm_memory_used_bytes{area="heap"} / elasticsearch_jvm_memory_max_bytes{area="heap"}) * 100 > 80
@@ -27,7 +26,6 @@ spec:
27
26
  annotations:
28
27
  summary: "Elasticsearch Heap Usage warning (instance {{ $labels.instance }})"
29
28
  description: "The heap usage is over 80% for 5m (currently at {{ $value }}% )"
30
- dashboard: "OVH:<MONITORING>/elasticsearch"
31
29
 
32
30
  - alert: ElasticsearchDiskSpaceLow
33
31
  expr: elasticsearch_filesystem_data_available_bytes / elasticsearch_filesystem_data_size_bytes * 100 < 20
@@ -37,7 +35,6 @@ spec:
37
35
  annotations:
38
36
  summary: "Elasticsearch disk space low (instance {{ $labels.instance }})"
39
37
  description: "The disk usage is over 80% (currently at {{ $value }}% )"
40
- dashboard: "OVH:<MONITORING>/elasticsearch"
41
38
 
42
39
  - alert: ElasticsearchDiskOutOfSpace
43
40
  expr: elasticsearch_filesystem_data_available_bytes / elasticsearch_filesystem_data_size_bytes * 100 < 10
@@ -48,7 +45,6 @@ spec:
48
45
  annotations:
49
46
  summary: "Elasticsearch disk out of space (instance {{ $labels.instance }})"
50
47
  description: "The disk usage is over 90% (currently at {{ $value }}% )"
51
- dashboard: "OVH:<MONITORING>/elasticsearch"
52
48
 
53
49
  - alert: ElasticsearchClusterRed
54
50
  expr: elasticsearch_cluster_health_status{color="red"} == 1
@@ -58,7 +54,6 @@ spec:
58
54
  annotations:
59
55
  summary: "Elasticsearch Cluster Red (instance {{ $labels.instance }})"
60
56
  description: "Elastic Cluster is in an unhealthy state"
61
- dashboard: "OVH:<MONITORING>/elasticsearch"
62
57
 
63
58
  - alert: ElasticsearchClusterYellow
64
59
  expr: elasticsearch_cluster_health_status{color="yellow"} == 1
@@ -68,7 +63,6 @@ spec:
68
63
  annotations:
69
64
  summary: "Elasticsearch Cluster Yellow (instance {{ $labels.instance }})"
70
65
  description: "Elastic Cluster is in an unhealthy state"
71
- dashboard: "OVH:<MONITORING>/elasticsearch"
72
66
 
73
67
  - alert: ElasticsearchRelocationShards
74
68
  expr: elasticsearch_cluster_health_relocating_shards > 0
@@ -78,7 +72,6 @@ spec:
78
72
  annotations:
79
73
  summary: "Elasticsearch relocation shards (instance {{ $labels.instance }})"
80
74
  description: "Number of relocation shards for 20 min is {{ $value }}"
81
- dashboard: "OVH:<MONITORING>/elasticsearch"
82
75
 
83
76
  - alert: ElasticsearchInitializingShards
84
77
  expr: elasticsearch_cluster_health_initializing_shards > 0
@@ -88,7 +81,6 @@ spec:
88
81
  annotations:
89
82
  summary: "Elasticsearch initializing shards (instance {{ $labels.instance }})"
90
83
  description: "Number of initializing shards for 10 min is {{ $value }}"
91
- dashboard: "OVH:<MONITORING>/elasticsearch"
92
84
 
93
85
  - alert: ElasticsearchUnassignedShards
94
86
  expr: elasticsearch_cluster_health_unassigned_shards > 0
@@ -98,7 +90,6 @@ spec:
98
90
  annotations:
99
91
  summary: "Elasticsearch unassigned shards (instance {{ $labels.instance }})"
100
92
  description: "Number of unassigned shards for 2 min is {{ $value }}"
101
- dashboard: "OVH:<MONITORING>/elasticsearch"
102
93
 
103
94
  - alert: ElasticsearchPendingTasks
104
95
  expr: elasticsearch_cluster_health_number_of_pending_tasks > 0
@@ -108,4 +99,3 @@ spec:
108
99
  annotations:
109
100
  summary: "Elasticsearch pending tasks (instance {{ $labels.instance }})"
110
101
  description: "Number of pending tasks for 10 min is {{ $value }}. Cluster is working slowly."
111
- dashboard: "OVH:<MONITORING>/elasticsearch"
@@ -25,7 +25,6 @@ spec:
25
25
  annotations:
26
26
  summary: "High Firebase load detected"
27
27
  description: "Firebase load is above 90% (current value is: {{ $value | humanize }}%)"
28
- dashboard: "OVH:<MONITORING>/firebase"
29
28
  - alert: PubSubUndeliveredMessages
30
29
  expr: sum(stackdriver_pubsub_subscription_pubsub_googleapis_com_subscription_num_undelivered_messages) by (subscription_id) > 1000
31
30
  for: 5m
@@ -35,7 +34,6 @@ spec:
35
34
  annotations:
36
35
  summary: "High Number of Undelivered Messages on PubSub"
37
36
  description: "Undelivered message count on topic {{$labels.subscription_id}} is greater than 1000"
38
- dashboard: "OVH:<MONITORING>/stackdriver"
39
37
  - alert: PubSubOldUnackedMessages
40
38
  expr: stackdriver_pubsub_subscription_pubsub_googleapis_com_subscription_oldest_unacked_message_age > 900
41
39
  for: 5m
@@ -44,4 +42,3 @@ spec:
44
42
  annotations:
45
43
  summary: "Old messages left unacked on PubSub"
46
44
  description: "Messages on {{$labels.subscription_id}} has been unacked for more than 15m"
47
- dashboard: "OVH:<MONITORING>/stackdriver"
@@ -58,7 +58,6 @@ spec:
58
58
  annotations:
59
59
  summary: "Kubernetes PVC Free Space < 10%"
60
60
  description: "PVC volume {{ $labels.persistentvolumeclaim }} is almost full - down to {{ $value | humanize }}% available"
61
- dashboard: "OVH:<MONITORING>/k8s-pvc/pvc-usage?var-volume={{ $labels.persistentvolumeclaim }}"
62
61
 
63
62
  # - alert: KubernetesVolumeFullInFourDays
64
63
  # expr: predict_linear(kubelet_volume_stats_available_bytes[6h], 4 * 24 * 3600) < 0
@@ -68,7 +67,6 @@ spec:
68
67
  # annotations:
69
68
  # summary: "Kubernetes Volume full in four days "
70
69
  # description: "{{ $labels.namespace }}/{{ $labels.persistentvolumeclaim }} is expected to fill up within four days. Currently {{ $value | humanize }}% is available."
71
- # dashboard: "OVH:<MONITORING>/pvc"
72
70
 
73
71
  - alert: KubernetesPersistentvolumeError
74
72
  expr: kube_persistentvolume_status_phase{phase=~"Failed|Pending",job="kube-state-metrics"} > 0
@@ -88,7 +86,6 @@ spec:
88
86
  annotations:
89
87
  summary: "Kubernetes HPA scale capability"
90
88
  description: "Kubernetes has scaled {{ $labels.hpa }} to max number of scaled pods."
91
- dashboard: "OVH:<MONITORING>/k8-deployment"
92
89
 
93
90
  - alert: KubernetesPodNotHealthy
94
91
  expr: kube_pod_status_phase{phase=~"Pending|Unknown|Failed"} == 1
@@ -17,4 +17,3 @@ spec:
17
17
  annotations:
18
18
  summary: Apps are restarting frequently
19
19
  description: "{{ $labels.app }} is in a crash loop"
20
- dashboard: "OVH:<MONITORING>/stackdriver"
@@ -17,7 +17,6 @@ spec:
17
17
  annotations:
18
18
  summary: "Postgresql down"
19
19
  description: "Postgresql instance is down: check {{ $labels.release }}"
20
- dashboard: "OVH:<MONITORING>/postgres"
21
20
 
22
21
  - alert: PostgresqlRestarted
23
22
  expr: time() - pg_postmaster_start_time_seconds < 60
@@ -27,7 +26,6 @@ spec:
27
26
  annotations:
28
27
  summary: "Postgresql restarted"
29
28
  description: "Postgresql restarted: check {{ $labels.release }}"
30
- dashboard: "OVH:<MONITORING>/postgres"
31
29
 
32
30
  - alert: PostgresqlExporterError
33
31
  expr: pg_exporter_last_scrape_error > 0
@@ -37,7 +35,6 @@ spec:
37
35
  annotations:
38
36
  summary: "Postgresql exporter error for {{ $labels.release }}"
39
37
  description: "Postgresql exporter is showing errors. Metrics may be outdated"
40
- dashboard: "OVH:<MONITORING>/postgres"
41
38
 
42
39
  - alert: PostgresqlReplicationLag
43
40
  expr: (pg_replication_lag > 10) and ON(instance) (pg_replication_is_replica == 1)
@@ -47,7 +44,6 @@ spec:
47
44
  annotations:
48
45
  summary: "Postgresql replication lag"
49
46
  description: "PostgreSQL replication lag is going up (> 10s): check {{ $labels.release }}"
50
- dashboard: "OVH:<MONITORING>/postgres"
51
47
 
52
48
  - alert: PostgresqlTableNotVacuumed
53
49
  expr: (pg_stat_user_tables_last_autovacuum > 0) and (time() - pg_stat_user_tables_last_autovacuum > 60 * 60 * 24)
@@ -57,7 +53,6 @@ spec:
57
53
  annotations:
58
54
  summary: "Postgresql table not vacuumed"
59
55
  description: "Table has not been vacuum for 24 hours: check {{ $labels.instance }}"
60
- dashboard: "OVH:<MONITORING>/postgres"
61
56
 
62
57
  - alert: PostgresqlTableNotAutoAnalyzed
63
58
  expr: (pg_stat_user_tables_last_autoanalyze > 0) and (time() - pg_stat_user_tables_last_autoanalyze > 60 * 60 * 24)
@@ -67,7 +62,6 @@ spec:
67
62
  annotations:
68
63
  summary: "Postgresql table not analyzed (instance {{ $labels.instance }})"
69
64
  description: "Table {{ $labels.relname }} has not been analyzed for 24 hours: check {{ $labels.release }} - {{ $labels.datname }}"
70
- dashboard: "OVH:<MONITORING>/postgres"
71
65
 
72
66
  - alert: PostgresqlDeadLocks
73
67
  expr: rate(pg_stat_database_deadlocks{datname!~"template.*|postgres"}[1m]) > 0
@@ -77,7 +71,6 @@ spec:
77
71
  annotations:
78
72
  summary: "Postgresql dead locks"
79
73
  description: "PostgreSQL has dead-locks: check {{ $labels.release }} - {{ $labels.datname }}"
80
- dashboard: "OVH:<MONITORING>/postgres"
81
74
 
82
75
  - alert: PostgresqlSlowQueries
83
76
  expr: pg_slow_queries > 0
@@ -87,7 +80,6 @@ spec:
87
80
  annotations:
88
81
  summary: "Postgresql slow queries"
89
82
  description: "PostgreSQL executing slow queries"
90
- dashboard: "OVH:<MONITORING>/postgres"
91
83
 
92
84
  - alert: PostgresqlHighRollbackRate
93
85
  expr: rate(pg_stat_database_xact_rollback{datname!~"template.*"}[3m]) / rate(pg_stat_database_xact_commit{datname!~"template.*"}[3m]) > 0.02
@@ -97,7 +89,6 @@ spec:
97
89
  annotations:
98
90
  summary: "Postgresql high rollback rate on {{ $labels.release }} - {{ $labels.datname }}"
99
91
  description: "Ratio of transactions being aborted compared to committed is > 2 %"
100
- dashboard: "OVH:<MONITORING>/postgres"
101
92
 
102
93
  - alert: PostgresqlCommitRateLow
103
94
  expr: rate(pg_stat_database_xact_commit[1m]) < 10
@@ -107,7 +98,6 @@ spec:
107
98
  annotations:
108
99
  summary: "Postgresql commit rate low on {{ $labels.release }} - {{ $labels.datname }}"
109
100
  description: "Postgres seems to be processing very few transactions"
110
- dashboard: "OVH:<MONITORING>/postgres"
111
101
 
112
102
  - alert: PostgresqlLowXidConsumption
113
103
  expr: rate(pg_txid_current[1m]) < 5
@@ -117,7 +107,6 @@ spec:
117
107
  annotations:
118
108
  summary: "Postgresql low XID consumption on {{ $labels.release }} - {{ $labels.datname }}"
119
109
  description: "Postgresql seems to be consuming transaction IDs very slowly"
120
- dashboard: "OVH:<MONITORING>/postgres"
121
110
 
122
111
  - alert: PostgresqllowXlogConsumption
123
112
  expr: rate(pg_xlog_position_bytes[1m]) < 100
@@ -127,7 +116,6 @@ spec:
127
116
  annotations:
128
117
  summary: "Postgresqllow XLOG consumption on {{ $labels.release }} - {{ $labels.datname }}"
129
118
  description: "Postgres seems to be consuming XLOG very slowly"
130
- dashboard: "OVH:<MONITORING>/postgres"
131
119
 
132
120
  - alert: PostgresqlWaleReplicationStopped
133
121
  expr: rate(pg_xlog_position_bytes[1m]) == 0
@@ -137,7 +125,6 @@ spec:
137
125
  annotations:
138
126
  summary: "Postgresql WAL-E replication stopped on {{ $labels.release }} - {{ $labels.datname }}"
139
127
  description: "WAL-E replication seems to be stopped"
140
- dashboard: "OVH:<MONITORING>/postgres"
141
128
 
142
129
  - alert: PostgresqlHighRateStatementTimeout
143
130
  expr: rate(postgresql_errors_total{type="statement_timeout"}[5m]) > 3
@@ -147,7 +134,6 @@ spec:
147
134
  annotations:
148
135
  summary: "Postgresql high rate statement timeout"
149
136
  description: "Postgres transactions showing high rate of statement timeouts on {{ $labels.release }} - {{ $labels.datname }}"
150
- dashboard: "OVH:<MONITORING>/postgres"
151
137
 
152
138
  - alert: PostgresqlHighRateDeadlock
153
139
  expr: rate(postgresql_errors_total{type="deadlock_detected"}[1m]) * 60 > 1
@@ -157,7 +143,6 @@ spec:
157
143
  annotations:
158
144
  summary: "Postgresql high rate deadlock"
159
145
  description: "Postgres detected deadlocks on {{ $labels.release }} - {{ $labels.datname }}"
160
- dashboard: "OVH:<MONITORING>/postgres"
161
146
 
162
147
  - alert: PostgresqlReplicationLabBytes
163
148
  expr: (pg_xlog_position_bytes and pg_replication_is_replica == 0) - on (environment) group_right(instance) (pg_xlog_position_bytes and pg_replication_is_replica == 1) > 1e+09
@@ -167,7 +152,6 @@ spec:
167
152
  annotations:
168
153
  summary: "Postgresql replication lab bytes"
169
154
  description: "Postgres Replication lag (in bytes) is high on {{ $labels.release }} - {{ $labels.datname }}"
170
- dashboard: "OVH:<MONITORING>/postgres"
171
155
 
172
156
  - alert: PostgresqlTooManyDeadTuples
173
157
  expr: ((pg_stat_user_tables_n_dead_tup > 10000) / (pg_stat_user_tables_n_live_tup + pg_stat_user_tables_n_dead_tup)) >= 0.1 unless ON(instance) (pg_replication_is_replica == 1)
@@ -177,7 +161,6 @@ spec:
177
161
  annotations:
178
162
  summary: "Postgresql too many dead tuples"
179
163
  description: "PostgreSQL dead tuples is too large ( {{ $value }} dead tuples) on {{ $labels.release }} - {{ $labels.datname }}"
180
- dashboard: "OVH:<MONITORING>/postgres"
181
164
 
182
165
  - alert: PostgresqlTooManyLocksAcquired
183
166
  expr: ((sum (pg_locks_count)) / (pg_settings_max_locks_per_transaction * pg_settings_max_connections)) > 0.20
@@ -187,4 +170,3 @@ spec:
187
170
  annotations:
188
171
  summary: "Postgresql too many locks acquired on {{ $labels.statefulset.kubernetes.io_pod_name }}"
189
172
  description: "Too many locks acquired on the database. If this alert happens frequently, we may need to increase the postgres setting max_locks_per_transaction."
190
- dashboard: "OVH:<MONITORING>/postgres"
@@ -16,7 +16,6 @@ spec:
16
16
  annotations:
17
17
  summary: "Redis down (instance {{ $labels.instance }})"
18
18
  description: "Redis instance is down"
19
- dashboard: "OVH:<MONITORING>/redis"
20
19
 
21
20
  - alert: RedisMissingMaster
22
21
  expr: count(redis_instance_info{role="master"}) == 0
@@ -26,7 +25,6 @@ spec:
26
25
  annotations:
27
26
  summary: "Redis missing master (instance {{ $labels.instance }})"
28
27
  description: "Redis cluster has no node marked as master."
29
- dashboard: "OVH:<MONITORING>/redis"
30
28
 
31
29
  - alert: RedisTooManyMasters
32
30
  expr: count(redis_instance_info{role="master"}) > 1
@@ -36,7 +34,6 @@ spec:
36
34
  annotations:
37
35
  summary: "Redis too many masters (instance {{ $labels.instance }})"
38
36
  description: "Redis cluster has too many nodes marked as master."
39
- dashboard: "OVH:<MONITORING>/redis"
40
37
 
41
38
  - alert: RedisDisconnectedSlaves
42
39
  expr: count without (instance, job) (redis_connected_slaves) - sum without (instance, job) (redis_connected_slaves) - 1 > 1
@@ -46,7 +43,6 @@ spec:
46
43
  annotations:
47
44
  summary: "Redis disconnected slaves (instance {{ $labels.instance }})"
48
45
  description: "Redis not replicating for all slaves. Consider reviewing the redis replication status."
49
- dashboard: "OVH:<MONITORING>/redis"
50
46
 
51
47
  - alert: RedisReplicationBroken
52
48
  expr: delta(redis_connected_slaves[1m]) < 0
@@ -56,7 +52,6 @@ spec:
56
52
  annotations:
57
53
  summary: "Redis replication broken (instance {{ $labels.instance }})"
58
54
  description: "Redis instance lost a slave"
59
- dashboard: "OVH:<MONITORING>/redis"
60
55
 
61
56
  - alert: RedisClusterFlapping
62
57
  expr: changes(redis_connected_slaves[5m]) > 2
@@ -66,7 +61,6 @@ spec:
66
61
  annotations:
67
62
  summary: "Redis cluster flapping (instance {{ $labels.instance }})"
68
63
  description: "Changes have been detected in Redis replica connection. This can occur when replica nodes lose connection to the master and reconnect (a.k.a flapping)."
69
- dashboard: "OVH:<MONITORING>/redis"
70
64
 
71
65
  - alert: RedisOutOfMemory
72
66
  expr: redis_memory_used_bytes / redis_total_system_memory_bytes * 100 > 90
@@ -76,7 +70,6 @@ spec:
76
70
  annotations:
77
71
  summary: "Redis out of memory (instance {{ $labels.instance }})"
78
72
  description: "Redis is running out of memory ( {{ $value }}% )"
79
- dashboard: "OVH:<MONITORING>/redis"
80
73
 
81
74
  - alert: RedisRejectedConnections
82
75
  expr: increase(redis_rejected_connections_total[1m]) > 0
@@ -86,5 +79,3 @@ spec:
86
79
  annotations:
87
80
  summary: "Redis rejected connections (instance {{ $labels.instance }})"
88
81
  description: "Some connections to Redis has been rejected. Please check {{ $labels.app }}"
89
- dashboard: "OVH:<MONITORING>/redis"
90
-
@@ -25,4 +25,3 @@ spec:
25
25
  # annotations:
26
26
  # summary: "Traefik high HTTP 4xx error rate on {{ $labels.service }}"
27
27
  # description: "Traefik backend 4xx error rate is above 10% (currently at {{ $value }}%)"
28
- # dashboard: "OVH:<MONITORING>/traefik"
@@ -16,7 +16,6 @@ spec:
16
16
  annotations:
17
17
  summary: "Velero schedule {{ $labels.schedule }} backup failed to execute properly"
18
18
  description: "It has been over 30 hours since the last successful backup"
19
- dashboard: "OVH:<MONITORING>/velero"
20
19
  - alert: NoVeleroBackups
21
20
  expr: velero_backup_success_total{schedule!=""} == 0
22
21
  for: 30h
@@ -25,4 +24,3 @@ spec:
25
24
  annotations:
26
25
  summary: "Velero has not made any backups yet"
27
26
  description: "No backups have successfully been made since velero was initialized (or restarted), go check it out ASAP"
28
- dashboard: "OVH:<MONITORING>/velero"
@@ -5,7 +5,7 @@
5
5
  fullnameOverride: "prometheus-stack-stackdriver-metrics"
6
6
 
7
7
  stackdriver:
8
- projectId: "OVH:<PROJECT_NAME>"
8
+ projectId: "${PROJECT_NAME}"
9
9
  metrics:
10
10
  typePrefixes: "pubsub.googleapis.com/subscription/oldest_unacked_message_age,pubsub.googleapis.com/subscription/num_undelivered_messages,pubsub.googleapis.com/subscription/pull_ack_request_count,pubsub.googleapis.com/subscription/streaming_pull_ack_request_count,pubsub.googleapis.com/topic/message_sizes,pubsub.googleapis.com/topic/send_request_count,firebasedatabase.googleapis.com/io/database_load,firebasedatabase.googleapis.com/network/sent_bytes_count,firebasedatabase.googleapis.com/network/active_connections"
11
11
 
@@ -0,0 +1,15 @@
1
+ #!/bin/bash
2
+
3
+ VERSION="v0.78.1"
4
+ CRDOPTS="--force-conflicts --server-side"
5
+
6
+ kubectl apply $CRDOPTS -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/$VERSION/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagerconfigs.yaml
7
+ kubectl apply $CRDOPTS -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/$VERSION/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagers.yaml
8
+ kubectl apply $CRDOPTS -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/$VERSION/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml
9
+ kubectl apply $CRDOPTS -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/$VERSION/example/prometheus-operator-crd/monitoring.coreos.com_probes.yaml
10
+ kubectl apply $CRDOPTS -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/$VERSION/example/prometheus-operator-crd/monitoring.coreos.com_prometheusagents.yaml
11
+ kubectl apply $CRDOPTS -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/$VERSION/example/prometheus-operator-crd/monitoring.coreos.com_prometheuses.yaml
12
+ kubectl apply $CRDOPTS -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/$VERSION/example/prometheus-operator-crd/monitoring.coreos.com_prometheusrules.yaml
13
+ kubectl apply $CRDOPTS -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/$VERSION/example/prometheus-operator-crd/monitoring.coreos.com_scrapeconfigs.yaml
14
+ kubectl apply $CRDOPTS -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/$VERSION/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml
15
+ kubectl apply $CRDOPTS -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/$VERSION/example/prometheus-operator-crd/monitoring.coreos.com_thanosrulers.yaml
@@ -4,7 +4,7 @@ showInstalling "Redis"
4
4
 
5
5
  OCI_CHART="oci://registry-1.docker.io/bitnamicharts/redis"
6
6
 
7
- [ -z "$REDIS_CHART_VERSION" ] && REDIS_CHART_VERSION="20.2.1"
7
+ [ -z "$REDIS_CHART_VERSION" ] && REDIS_CHART_VERSION="20.3.0"
8
8
 
9
9
  helm upgrade --install redis $OCI_CHART \
10
10
  --values redis/redis-local.yaml \
@@ -4,7 +4,7 @@
4
4
  # - npm run sequelizeRunMigrations
5
5
  #
6
6
  image:
7
- tag: # v1.5.1
7
+ tag: # v1.7.0
8
8
 
9
9
  config:
10
10
  LOG_CONFIG: '{"type":"pino","level":"warn"}'
@@ -1,5 +1,5 @@
1
1
  image:
2
- tag: # v3.1.2
2
+ tag: # v3.3.0
3
3
 
4
4
  config:
5
5
  LOG_CONFIG: '{"type":"pino","level":"warn"}'
@@ -1,7 +1,7 @@
1
1
  nameOverride: transponder-bq
2
2
 
3
3
  image:
4
- tag: # v5.2.4
4
+ tag: # v5.3.4
5
5
 
6
6
  config:
7
7
  TRANSPONDER_RUN_MODE: "bigQueryJson"
@@ -1,7 +1,7 @@
1
1
  nameOverride: transponder-dh
2
2
 
3
3
  image:
4
- tag: # v5.2.4
4
+ tag: # v5.3.4
5
5
 
6
6
  config:
7
7
  TRANSPONDER_RUN_MODE: "denseHistoryCombined"
@@ -1,7 +1,7 @@
1
1
  nameOverride: transponder-rt
2
2
 
3
3
  image:
4
- tag: # v5.2.4
4
+ tag: # v5.3.4
5
5
 
6
6
  config:
7
7
  TRANSPONDER_RUN_MODE: "rt"
@@ -7,7 +7,7 @@
7
7
  nameOverride: transponder-tsdb
8
8
 
9
9
  image:
10
- tag: # v5.2.4
10
+ tag: # v5.3.4
11
11
 
12
12
  config:
13
13
  TRANSPONDER_RUN_MODE: "timescale"
@@ -0,0 +1,7 @@
1
+ image:
2
+ tag: # v4.1.0
3
+
4
+ config:
5
+ LOG_CONFIG: '{"type":"pino","level":"warn"}'
6
+ PROJECT_ID: "set-in-values-local"
7
+ SYSTEM_ID: "set-in-values-local"
package/src/overwhelm.mjs CHANGED
@@ -15,20 +15,29 @@ import parse from 'parse-gitignore'
15
15
  import ask from 'readline-sync'
16
16
  import YAML from 'js-yaml'
17
17
 
18
- import { debug, disableDebug, err, errorExit, isString, log, shellCmd } from './Utils.mjs'
18
+ import {
19
+ debug,
20
+ disableDebug,
21
+ err,
22
+ errorExit,
23
+ isString,
24
+ log,
25
+ shellCmd,
26
+ } from './Utils.mjs'
19
27
 
20
28
  const optionsDefinitions = [
21
29
  /* eslint-disable no-multi-spaces */
22
- { name : 'context', alias : 'x', type : String, default : '' },
23
- { name : 'section', alias : 's', type : String, default : 'default' },
24
- { name : 'key', alias : 'k', type : String },
25
- { name : 'export', alias : 'e', type : Boolean, default : false },
26
- { name : 'continue', alias : 'c', type : Boolean, default : false },
27
- { name : 'checkctx', alias : 't', type : Boolean, default : false }, // checks overwhelm context
28
- { name : 'fetchctx', alias : 'f', type : Boolean, default : false }, // fetch and set k8s context
29
- { name : 'genvals', alias : 'g', type : Boolean, default : false }, // only generates values.yaml
30
- { name : 'matchk8s', alias : 'm', type : Boolean, default : false }, // checks k8s context
31
- { name : 'verbose', alias : 'v', type : Boolean, default : false },
30
+ { name : 'context', alias : 'x', type : String, default : '' },
31
+ { name : 'deprecated', alias : 'd', type : Boolean, default : false },
32
+ { name : 'section', alias : 's', type : String, default : 'default' },
33
+ { name : 'key', alias : 'k', type : String },
34
+ { name : 'export', alias : 'e', type : Boolean, default : false },
35
+ { name : 'continue', alias : 'c', type : Boolean, default : false },
36
+ { name : 'checkctx', alias : 't', type : Boolean, default : false }, // checks overwhelm context
37
+ { name : 'fetchctx', alias : 'f', type : Boolean, default : false }, // fetch and set k8s context
38
+ { name : 'genvals', alias : 'g', type : Boolean, default : false }, // only generates values.yaml
39
+ { name : 'matchk8s', alias : 'm', type : Boolean, default : false }, // checks k8s context
40
+ { name : 'verbose', alias : 'v', type : Boolean, default : false },
32
41
  /* eslint-enable no-multi-spaces */
33
42
  ]
34
43
  const args = cliArgs( optionsDefinitions )
@@ -36,6 +45,12 @@ const args = cliArgs( optionsDefinitions )
36
45
  // when using --key we only want the key contents w/o debug info
37
46
  if ( args.key ) { disableDebug() }
38
47
 
48
+ // define a deprecation warning function that depends on arg.deprecated
49
+ const deprecated = ( deprecation ) => {
50
+ if ( !args.deprecated ) { return }
51
+ log( `${chalk.yellow.bold( '***DEPRECATED:' )} ${deprecation}\n` )
52
+ }
53
+
39
54
  // See if we are in a monorepo, which changes some of the rules.
40
55
  const gitTop = await shellCmd( 'git rev-parse --show-toplevel' )
41
56
 
@@ -180,7 +195,7 @@ const yams = glob.sync( 'values-*.yaml' )
180
195
 
181
196
  // A function to apply the replacements to all of the matching yaml which
182
197
  // will error out if it runs into an unknown OVH<tag>.
183
- const doReplacements = ( yamls, replacements ) => {
198
+ const doReplacements = ( yamls, replacements, fileName = 'default-config.yaml' ) => {
184
199
  let replYaml = yamls
185
200
 
186
201
  // wrap special chars with quotes if needed, like "#---incident-alerts---"
@@ -188,10 +203,18 @@ const doReplacements = ( yamls, replacements ) => {
188
203
  return /[#$?*]/g.test( raw ) ? `"${raw}"` : raw
189
204
  }
190
205
 
191
- Object.keys( replacements ).forEach( ( repl ) => {
192
- const replaceThis = new RegExp( `OVH:<${repl}>`, 'g' ) // eslint-disable-line security/detect-non-literal-regexp
193
- const withThat = quoteSpecials( `${replacements[repl]}` )
194
- replYaml = replYaml.replace( replaceThis, withThat )
206
+ // process both ${VARIABLE} and deprecate OVH:<VARIABLES> styles
207
+ Object.keys( replacements ).forEach( ( key ) => {
208
+ // replace ${VARIABLE} syntax
209
+ const replaceVariable = new RegExp( `\\$\\{${key}\\}`, 'g' ) // eslint-disable-line security/detect-non-literal-regexp
210
+ replYaml = replYaml.replace( replaceVariable, quoteSpecials( `${replacements[key]}` ) )
211
+
212
+ // replace OVH:<VARIABLE> syntax and warn about deprecation
213
+ const replaceDeprecated = new RegExp( `OVH:<${key}>`, 'g' ) // eslint-disable-line security/detect-non-literal-regexp
214
+ if ( replYaml.match( replaceDeprecated ) ) {
215
+ deprecated( `OVH:<${key}> is deprecated. Please replace it with \${${key}} in ${fileName}` )
216
+ replYaml = replYaml.replace( replaceDeprecated, quoteSpecials( `${replacements[key]}` ) )
217
+ }
195
218
  } )
196
219
 
197
220
  // Verify all replaceables have been handled, or error out.
@@ -296,7 +319,6 @@ ahoy.forEach( ( dir ) => {
296
319
  const valuesLocal = `${dir}/values-local.yaml`
297
320
 
298
321
  if ( validValuesLocalConfig( valuesLocal ) ) {
299
- debug( { valuesLocal }, 'rendering values.yaml' )
300
322
  valuesOut += '\n# OVERWHELM => values-local.yaml\n\n'
301
323
  valuesOut += fs.readFileSync( valuesLocal, { encoding : 'utf-8' } )
302
324
  }
@@ -308,28 +330,17 @@ ahoy.forEach( ( dir ) => {
308
330
  const valuesAll = YAML.load( valuesOut ) || {}
309
331
  const valuesSvc = {
310
332
  service : {
311
- project_id : 'OVH:<PROJECT_ID>',
312
- project_name : 'OVH:<PROJECT_NAME>',
313
- host : 'OVH:<HOST>',
314
- ingress : 'OVH:<INGRESS>',
333
+ /* eslint-disable no-template-curly-in-string */
334
+ project_id : '${PROJECT_ID}',
335
+ project_name : '${PROJECT_NAME}',
336
+ host : '${HOST}',
337
+ ingress : '${INGRESS}',
338
+ /* eslint-enable no-template-curly-in-string */
315
339
  }
316
340
  }
317
341
  const valuesMerged = YAML.dump( deepmerge( valuesSvc, valuesAll ), { quotingType : '"' } )
318
342
 
319
- valuesOut = doReplacements( valuesMerged, over )
320
-
321
- // DEPRECATED once siren and manheim are platform 4.0
322
- // If we are going to override then we need to convert it to YAML and
323
- // do a deepmerge to combine the values.
324
- const valuesOverride = `${dir}/values-override.yaml`
325
-
326
- if ( fs.existsSync( valuesOverride ) ) {
327
- log( `===>Applying Overrides=> ${valuesOverride}` )
328
- const overrides = YAML.load( fs.readFileSync( valuesOverride, { encofind : 'utf-8' } ) )
329
- const allValues = YAML.load( valuesOut )
330
- valuesOut = YAML.dump( deepmerge( allValues, overrides ), { quotingType : '"' } )
331
- }
332
- // DEPRECATED
343
+ valuesOut = doReplacements( valuesMerged, over, valuesLocal )
333
344
 
334
345
  fs.writeFileSync( `${dir}/values.yaml`, valuesOut )
335
346
  }
@@ -338,8 +349,9 @@ ahoy.forEach( ( dir ) => {
338
349
  // we can also apply replaceables to all .ovh files in the project
339
350
  glob.sync( '**/*.ovh' ).forEach( ( cfgmap ) => {
340
351
  const target = cfgmap.replace( /.ovh$/, '' )
352
+ deprecated( `rename deprecated ${cfgmap} OVH file to ${target}` )
341
353
  let valuesOut = fs.readFileSync( cfgmap, { encoding : 'utf-8' } )
342
- valuesOut = doReplacements( valuesOut, over )
354
+ valuesOut = doReplacements( valuesOut, over, cfgmap )
343
355
  fs.writeFileSync( target, valuesOut )
344
356
  } )
345
357
 
package/src/pkgck.sh CHANGED
@@ -39,6 +39,14 @@ check_babel () {
39
39
  printf $C_stat
40
40
  }
41
41
 
42
+ check_har () {
43
+ local C_stat=$(bad)
44
+ local prep="`node -p \"require('./package.json').scripts.prepare\"`"
45
+ local isHar=`echo $prep | egrep -e "hook-and-release"`
46
+ [ ! -z "$isHar" ] && C_stat=$(good)
47
+ printf $C_stat
48
+ }
49
+
42
50
  check_circle () {
43
51
  local C_stat=$(bad)
44
52
  [ -f ".circleci/config.yml" ] && C_stat=$(good)
@@ -128,13 +136,14 @@ check_repo() {
128
136
  [ $? -ne 0 ] && needspush='!tags'
129
137
  fi
130
138
  local babel7=$(check_babel)
139
+ local hookar=$(check_har)
131
140
  local circle=$(check_circle)
132
141
  local eslint=$(check_eslint)
133
142
  local esmlib=$(check_ESM)
134
143
  local license=$(check_license)
135
144
  local scoped=$(check_scope)
136
- [ $(( $repos % 15)) -eq 0 ] && printf "\n%35s pkg git cln scop cir lic ESM bl7\n"
137
- printf "%32s: %-8s %-16s %s %8s %s %s %s %s %s\n" ${dir:0:32} $pkgver $(check_git_version $gitver $pkgver) $localmods $scoped $circle $license $esmlib $babel7 "$needspush"
145
+ [ $(( $repos % 15)) -eq 0 ] && printf "\n%35s pkg git cln scop cir lic ESM har\n"
146
+ printf "%32s: %-8s %-16s %s %8s %s %s %s %s %s\n" ${dir:0:32} $pkgver $(check_git_version $gitver $pkgver) $localmods $scoped $circle $license $esmlib $hookar "$needspush"
138
147
  let "repos++"
139
148
  cd - &> /dev/null
140
149
  }
@@ -0,0 +1,145 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from 'node:fs';
4
+ import path from 'node:path';
5
+ import chalk from 'chalk';
6
+ import inquirer from 'inquirer';
7
+ import {Storage} from '@google-cloud/storage';
8
+ import crc32c from 'fast-crc32c';
9
+
10
+ const storage = new Storage();
11
+
12
+ function getAllFiles(dirPath, arrayOfFiles = []) {
13
+ const files = fs.readdirSync(dirPath);
14
+
15
+ files.forEach(file => {
16
+ const filePath = path.join(dirPath, file);
17
+ if (fs.lstatSync(filePath).isDirectory()) {
18
+ arrayOfFiles = getAllFiles(filePath, arrayOfFiles);
19
+ } else {
20
+ arrayOfFiles.push(filePath);
21
+ }
22
+ });
23
+
24
+ return arrayOfFiles;
25
+ }
26
+
27
+ async function main() {
28
+ // Get git branch name
29
+ const branchName = fs.readFileSync('.git/HEAD', 'utf8').split('/').pop().trim();
30
+
31
+ const bucketName = `${branchName}-triton-model-registry`;
32
+
33
+ // Get all blobs in the bucket
34
+ let files = [];
35
+ try {
36
+ [files] = await storage.bucket(bucketName).getFiles();
37
+ } catch (error) {
38
+ if (error.code === 404) {
39
+ console.error(`Bucket ${bucketName} does not exist.`);
40
+ return;
41
+ } else {
42
+ throw error;
43
+ }
44
+ }
45
+
46
+ // Get all not hidden blobs in the current path in the filesystem
47
+ const localFiles = getAllFiles('./models').filter(file => !path.basename(file).startsWith('.'));
48
+
49
+ const filesToDelete = files.filter(file => !localFiles.find(localFile => localFile === file.name));
50
+
51
+ console.log(`${chalk.underline(filesToDelete.length + " file(s)")} in ${chalk.underline(bucketName)} without a ${chalk.underline("local")} counterpart`);
52
+ filesToDelete.forEach(file => console.log(chalk.red(file.name)));
53
+
54
+ if (filesToDelete.length > 0) console.log("");
55
+
56
+ const filesToAdd = [];
57
+ const filesToReplace = [];
58
+
59
+ const metadataPromises = localFiles.map(async file => {
60
+ const localFileChecksum = Buffer.from(crc32c.calculate(fs.readFileSync(file)).toString(16), 'hex').toString('base64');
61
+ const remoteFile = files.find(blob => blob.name === file);
62
+ if (remoteFile) {
63
+ const [metadata] = await remoteFile.getMetadata();
64
+ return { file, localFileChecksum, remoteFileChecksum: metadata.crc32c };
65
+ } else {
66
+ return { file, localFileChecksum, remoteFileChecksum: null };
67
+ }
68
+ });
69
+
70
+ const metadataResults = await Promise.all(metadataPromises);
71
+
72
+ metadataResults.forEach(({ file, localFileChecksum, remoteFileChecksum }) => {
73
+ if (remoteFileChecksum) {
74
+ if (localFileChecksum !== remoteFileChecksum) {
75
+ filesToReplace.push(file);
76
+ }
77
+ } else {
78
+ filesToAdd.push(file);
79
+ }
80
+ });
81
+
82
+ console.log(`${chalk.underline(filesToAdd.length + " file(s)")} to be added to ${chalk.underline(bucketName)}`);
83
+ filesToAdd.forEach(file => console.log(chalk.green(file)));
84
+
85
+ if (filesToAdd.length > 0) console.log("");
86
+
87
+ console.log(`${chalk.underline(filesToReplace.length + " file(s)")} to be replaced in ${chalk.underline(bucketName)}`);
88
+ filesToReplace.forEach(file => console.log(chalk.yellow(file)));
89
+
90
+ if (filesToReplace.length > 0) console.log("");
91
+
92
+ if (filesToDelete.length > 0) {
93
+ const {confirm} = await inquirer.prompt({
94
+ type: 'confirm',
95
+ name: 'confirm',
96
+ message: `Do you want to delete ${filesToDelete.length} file(s) from ${bucketName}?`,
97
+ });
98
+
99
+ if (!confirm) {
100
+ return;
101
+ }
102
+
103
+ // Remove all blobs that are not in the local filesystem
104
+ const deletePromises = filesToDelete.map(async file => {
105
+ console.log(`Deleting ${file.name} from ${bucketName}`);
106
+ return storage.bucket(bucketName).file(file.name).delete();
107
+ });
108
+
109
+ await Promise.all(deletePromises);
110
+ console.log("")
111
+ }
112
+
113
+ if (filesToAdd.length > 0 || filesToReplace.length > 0) {
114
+ const {confirm} = await inquirer.prompt({
115
+ type: 'confirm',
116
+ name: 'confirm',
117
+ message: `Do you want to upload ${filesToAdd.length + filesToReplace.length} file(s) to ${bucketName}?`,
118
+ });
119
+
120
+ if (!confirm) {
121
+ return;
122
+ }
123
+
124
+ // Upload all new files
125
+ const uploadPromises = filesToAdd.map(async file => {
126
+ console.log(`Uploading ${file} to ${bucketName}`);
127
+ return storage.bucket(bucketName).upload(file, {
128
+ destination: file,
129
+ });
130
+ });
131
+
132
+ // Replace all files with different checksums
133
+ const replacePromises = filesToReplace.map(async file => {
134
+ console.log(`Replacing ${file} in ${bucketName}`);
135
+ return storage.bucket(bucketName).upload(file, {
136
+ destination: file,
137
+ });
138
+ });
139
+
140
+ await Promise.all([...uploadPromises, ...replacePromises]);
141
+ console.log("")
142
+ }
143
+ }
144
+
145
+ main().catch(console.error);
@@ -1 +0,0 @@
1
- *.yaml