Skip to content

Commit

Permalink
refactor: Update ingestor replica count based on configuration
Browse files Browse the repository at this point in the history
This commit updates the ingestor replica count in the HelmChart/Public/oneuptime/templates/ingestor.yaml file based on the configuration. If the `$.Values.deployment.ingestor.replicaCount` value is provided, it sets the replicas to that value. Otherwise, it falls back to `$.Values.deployment.replicaCount`. This change ensures that the ingestor replica count is correctly configured, improving the scalability and performance of the application.
  • Loading branch information
simlarsen committed Jul 5, 2024
1 parent de7d06e commit c617e49
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
4 changes: 4 additions & 0 deletions HelmChart/Public/oneuptime/templates/ingestor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ spec:
selector:
matchLabels:
app: {{ printf "%s-%s" $.Release.Name "ingestor" }}
{{- if $.Values.deployment.ingestor.replicaCount }}
replicas: {{ $.Values.deployment.ingestor.replicaCount }}
{{- else }}
replicas: {{ $.Values.deployment.replicaCount }}
{{- end }}
template:
metadata:
labels:
Expand Down
2 changes: 2 additions & 0 deletions HelmChart/Public/oneuptime/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ fluentdHost:

deployment:
replicaCount: 1
ingestor:
replicaCount:

metalLb:
enabled: false
Expand Down
40 changes: 25 additions & 15 deletions Ingestor/API/Monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ router.post(

// update the lastMonitoredAt field of the monitors

const updatePromises: Array<Promise<void>> = [];

for (const monitorProbe of monitorProbes) {
if (!monitorProbe.monitor) {
continue;
Expand All @@ -293,18 +295,22 @@ router.post(
logger.error(err);
}

await MonitorProbeService.updateOneById({
id: monitorProbe.id!,
data: {
lastPingAt: OneUptimeDate.getCurrentDate(),
nextPingAt: nextPing,
},
props: {
isRoot: true,
},
});
updatePromises.push(
MonitorProbeService.updateOneById({
id: monitorProbe.id!,
data: {
lastPingAt: OneUptimeDate.getCurrentDate(),
nextPingAt: nextPing,
},
props: {
isRoot: true,
},
}),
);
}

await Promise.all(updatePromises);

// if (mutex) {
// try {
// await Semaphore.release(mutex);
Expand All @@ -326,15 +332,19 @@ router.post(

// check if the monitor needs secrets to be filled.

const monitorsWithSecretPopulated: Array<Monitor> = [];
let monitorsWithSecretPopulated: Array<Monitor> = [];
const monitorWithSecretsPopulatePromises: Array<Promise<Monitor>> = [];

for (const monitor of monitors) {
const monitorWithSecrets: Monitor =
await MonitorUtil.populateSecrets(monitor);

monitorsWithSecretPopulated.push(monitorWithSecrets);
monitorWithSecretsPopulatePromises.push(
MonitorUtil.populateSecrets(monitor),
);
}

monitorsWithSecretPopulated = await Promise.all(
monitorWithSecretsPopulatePromises,
);

logger.debug("Populated secrets");
logger.debug(monitorsWithSecretPopulated);

Expand Down

0 comments on commit c617e49

Please sign in to comment.