Skip to content

Commit 244b40f

Browse files
ArthurSensroboquat
authored andcommitted
werft/jobs/build: Add observability support to installer
Signed-off-by: ArthurSens <[email protected]>
1 parent aa52b3e commit 244b40f

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

.werft/jobs/build/deploy-to-preview-environment.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export async function deployToPreviewEnvironment(werft: Werft, jobConfig: JobCon
148148

149149
issueMetaCerts(werft, PROXY_SECRET_NAME, "default", domain, withVM)
150150
werft.done('certificate')
151-
installMonitoring(deploymentConfig.namespace, 9100, deploymentConfig.domain, STACKDRIVER_SERVICEACCOUNT, true, jobConfig.observability.branch);
151+
installMonitoring(deploymentConfig.namespace, 9100, deploymentConfig.domain, STACKDRIVER_SERVICEACCOUNT, withVM, jobConfig.observability.branch);
152152
werft.done('observability')
153153
}
154154

@@ -200,12 +200,14 @@ async function deployToDevWithInstaller(werft: Werft, jobConfig: JobConfig, depl
200200
werft.log(installerSlices.FIND_FREE_HOST_PORTS, "Find last ports");
201201
let wsdaemonPortMeta = findLastHostPort(namespace, 'ws-daemon', metaEnv({ slice: installerSlices.FIND_FREE_HOST_PORTS, silent: true }))
202202
let registryNodePortMeta = findLastHostPort(namespace, 'registry-facade', metaEnv({ slice: installerSlices.FIND_FREE_HOST_PORTS, silent: true }))
203+
let nodeExporterPort = findLastHostPort(namespace, 'node-exporter', metaEnv({ slice: installerSlices.FIND_FREE_HOST_PORTS, silent: true }))
203204

204-
if (isNaN(wsdaemonPortMeta) || isNaN(wsdaemonPortMeta)) {
205+
if (isNaN(wsdaemonPortMeta) || isNaN(wsdaemonPortMeta) || isNaN(nodeExporterPort)) {
205206
werft.log(installerSlices.FIND_FREE_HOST_PORTS, "Can't reuse, check for some free ports.");
206-
[wsdaemonPortMeta, registryNodePortMeta] = findFreeHostPorts([
207+
[wsdaemonPortMeta, registryNodePortMeta, nodeExporterPort] = findFreeHostPorts([
207208
{ start: 10000, end: 11000 },
208209
{ start: 30000, end: 31000 },
210+
{ start: 31001, end: 32000 },
209211
], metaEnv({ slice: installerSlices.FIND_FREE_HOST_PORTS, silent: true }));
210212
}
211213
werft.log(installerSlices.FIND_FREE_HOST_PORTS,
@@ -320,10 +322,22 @@ async function deployToDevWithInstaller(werft: Werft, jobConfig: JobConfig, depl
320322
exec(`yq w -i config.yaml analytics.writer ${deploymentConfig.analytics!}`, { slice: installerSlices.INSTALLER_RENDER });
321323
}
322324

323-
if (withObservability) {
325+
if (withVM || withObservability) {
324326
// TODO: there's likely more to do...
325327
const tracingEndpoint = exec(`yq r ./.werft/jobs/build/helm/values.tracing.yaml tracing.endpoint`, { slice: installerSlices.INSTALLER_RENDER }).stdout.trim();
326328
exec(`yq w -i config.yaml observability.tracing.endpoint ${tracingEndpoint}`, { slice: installerSlices.INSTALLER_RENDER });
329+
330+
// If the preview is running on Harvester, we've already deployed monitoring-satellite during 'VM' phase.
331+
// Therefore, we want to skip installing it here.
332+
if(!withVM) {
333+
try {
334+
installMonitoring(deploymentConfig.namespace, nodeExporterPort, monitoringDomain, STACKDRIVER_SERVICEACCOUNT, withVM, jobConfig.observability.branch);
335+
} catch (err) {
336+
werft.fail('observability', err)
337+
} finally {
338+
werft.done('observability')
339+
}
340+
}
327341
}
328342

329343
werft.log("authProviders", "copy authProviders from secret")

.werft/observability/monitoring-satellite.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,27 +74,33 @@ export async function installMonitoringSatellite(params: InstallMonitoringSatell
7474
}
7575

7676
// The correct kubectl context should already be configured prior to this step
77-
ensureCorrectInstallationOrder(params.satelliteNamespace)
77+
// Only checks node-exporter readiness for harvester
78+
ensureCorrectInstallationOrder(params.satelliteNamespace, params.withVM)
7879
}
7980

80-
async function ensureCorrectInstallationOrder(namespace: string){
81+
async function ensureCorrectInstallationOrder(namespace: string, checkNodeExporterStatus: boolean){
8182
const werft = getGlobalWerftInstance()
8283

8384
werft.log(sliceName, 'installing monitoring-satellite')
8485
exec('cd observability && hack/deploy-satellite.sh', {slice: sliceName})
8586

8687
deployGitpodServiceMonitors()
87-
checkReadiness(namespace)
88+
checkReadiness(namespace, checkNodeExporterStatus)
8889
}
8990

90-
async function checkReadiness(namespace: string) {
91+
async function checkReadiness(namespace: string, checkNodeExporterStatus: boolean) {
9192
// For some reason prometheus' statefulset always take quite some time to get created
9293
// Therefore we wait a couple of seconds
9394
exec(`sleep 30 && kubectl rollout status -n ${namespace} statefulset prometheus-k8s`, {slice: sliceName, async: true})
9495
exec(`kubectl rollout status -n ${namespace} deployment grafana`, {slice: sliceName, async: true})
9596
exec(`kubectl rollout status -n ${namespace} deployment kube-state-metrics`, {slice: sliceName, async: true})
9697
exec(`kubectl rollout status -n ${namespace} deployment otel-collector`, {slice: sliceName, async: true})
97-
exec(`kubectl rollout status -n ${namespace} daemonset node-exporter`, {slice: sliceName, async: true})
98+
99+
// core-dev is just too unstable for node-exporter
100+
// we don't guarantee that it will run at all
101+
if(checkNodeExporterStatus) {
102+
exec(`kubectl rollout status -n ${namespace} daemonset node-exporter`, {slice: sliceName, async: true})
103+
}
98104
}
99105

100106
async function deployGitpodServiceMonitors() {

0 commit comments

Comments
 (0)