Skip to content

Commit fc40211

Browse files
mads-hartmannroboquat
authored andcommitted
Ensure install is actually non-blocking
1 parent d299486 commit fc40211

File tree

2 files changed

+58
-40
lines changed

2 files changed

+58
-40
lines changed

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

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,19 @@ export async function deployToPreviewEnvironment(werft: Werft, jobConfig: JobCon
161161
// success rate or installing monitoring satellite, but we can at least count and debug errors.
162162
// In the future we can consider not closing spans when closing phases, or restructuring our phases
163163
// based on parallelism boundaries
164+
const monitoringSatelliteInstaller = new MonitoringSatelliteInstaller({
165+
kubeconfigPath: PREVIEW_K3S_KUBECONFIG_PATH,
166+
branch: jobConfig.observability.branch,
167+
satelliteNamespace: deploymentConfig.namespace,
168+
clusterName: deploymentConfig.namespace,
169+
nodeExporterPort: 9100,
170+
previewDomain: deploymentConfig.domain,
171+
stackdriverServiceAccount: STACKDRIVER_SERVICEACCOUNT,
172+
withVM: withVM,
173+
werft: werft
174+
});
164175
const sliceID = "observability"
165-
installMonitoring(werft, PREVIEW_K3S_KUBECONFIG_PATH, deploymentConfig.namespace, 9100, deploymentConfig.domain, STACKDRIVER_SERVICEACCOUNT, withVM, jobConfig.observability.branch)
176+
monitoringSatelliteInstaller.install()
166177
.then(() => {
167178
werft.log(sliceID, "Succeeded installing monitoring satellite")
168179
})
@@ -485,7 +496,18 @@ async function deployToDevWithHelm(werft: Werft, jobConfig: JobConfig, deploymen
485496
werft.log(`observability`, "Installing monitoring-satellite...")
486497
if (deploymentConfig.withObservability) {
487498
try {
488-
await installMonitoring(werft, CORE_DEV_KUBECONFIG_PATH, namespace, nodeExporterPort, monitoringDomain, STACKDRIVER_SERVICEACCOUNT, false, jobConfig.observability.branch);
499+
const installMonitoringSatellite = new MonitoringSatelliteInstaller({
500+
kubeconfigPath: CORE_DEV_KUBECONFIG_PATH,
501+
branch: jobConfig.observability.branch,
502+
satelliteNamespace: namespace,
503+
clusterName: namespace,
504+
nodeExporterPort: nodeExporterPort,
505+
previewDomain: domain,
506+
stackdriverServiceAccount: STACKDRIVER_SERVICEACCOUNT,
507+
withVM: false,
508+
werft: werft
509+
});
510+
await installMonitoringSatellite.install()
489511
} catch (err) {
490512
if (!jobConfig.mainBuild) {
491513
werft.fail('observability', err);
@@ -794,21 +816,6 @@ async function installMetaCertificates(werft: Werft, branch: string, withVM: boo
794816
await installCertificate(werft, metaInstallCertParams, { ...metaEnv(), slice: slice });
795817
}
796818

797-
async function installMonitoring(werft: Werft, kubeconfig: string, namespace: string, nodeExporterPort: number, domain: string, stackdriverServiceAccount: any, withVM: boolean, observabilityBranch: string) {
798-
const installMonitoringSatellite = new MonitoringSatelliteInstaller({
799-
kubeconfigPath: kubeconfig,
800-
branch: observabilityBranch,
801-
satelliteNamespace: namespace,
802-
clusterName: namespace,
803-
nodeExporterPort: nodeExporterPort,
804-
previewDomain: domain,
805-
stackdriverServiceAccount: stackdriverServiceAccount,
806-
withVM: withVM,
807-
werft: werft
808-
});
809-
installMonitoringSatellite.install()
810-
}
811-
812819
// returns the static IP address
813820
function getCoreDevIngressIP(): string {
814821
return "104.199.27.246";

.werft/observability/monitoring-satellite.ts

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const sliceName = "observability";
2222
export class MonitoringSatelliteInstaller {
2323
constructor(private readonly options: MonitoringSatelliteInstallerOptions) {}
2424

25-
public install() {
25+
public async install() {
2626
const {
2727
werft,
2828
branch,
@@ -89,50 +89,61 @@ export class MonitoringSatelliteInstaller {
8989
this.postProcessManifests();
9090
}
9191

92-
// The correct kubectl context should already be configured prior to this step
93-
// Only checks node-exporter readiness for harvester
94-
this.ensureCorrectInstallationOrder();
92+
this.ensureCorrectInstallationOrder()
93+
this.deployGitpodServiceMonitors();
94+
await this.waitForReadiness()
9595
}
9696

9797
private ensureCorrectInstallationOrder() {
9898
const { werft, kubeconfigPath } = this.options;
9999

100100
werft.log(sliceName, "installing monitoring-satellite");
101101
exec(`cd observability && hack/deploy-satellite.sh --kubeconfig ${kubeconfigPath}`, { slice: sliceName });
102-
103-
this.deployGitpodServiceMonitors();
104-
this.checkReadiness();
105102
}
106103

107-
private checkReadiness() {
104+
private async waitForReadiness() {
108105
const { kubeconfigPath, satelliteNamespace } = this.options;
109106

107+
const checks: Promise<any>[] = [];
110108
// For some reason prometheus' statefulset always take quite some time to get created
111109
// Therefore we wait a couple of seconds
112-
exec(
113-
`sleep 30 && kubectl --kubeconfig ${kubeconfigPath} rollout status -n ${satelliteNamespace} statefulset prometheus-k8s`,
114-
{ slice: sliceName },
110+
checks.push(
111+
exec(
112+
`sleep 30 && kubectl --kubeconfig ${kubeconfigPath} rollout status -n ${satelliteNamespace} statefulset prometheus-k8s`,
113+
{ slice: sliceName, async: true },
114+
),
115115
);
116-
exec(`kubectl --kubeconfig ${kubeconfigPath} rollout status -n ${satelliteNamespace} deployment grafana`, {
117-
slice: sliceName,
118-
});
119-
exec(
120-
`kubectl --kubeconfig ${kubeconfigPath} rollout status -n ${satelliteNamespace} deployment kube-state-metrics`,
121-
{ slice: sliceName },
116+
checks.push(
117+
exec(`kubectl --kubeconfig ${kubeconfigPath} rollout status -n ${satelliteNamespace} deployment grafana`, {
118+
slice: sliceName,
119+
async: true,
120+
}),
122121
);
123-
exec(
124-
`kubectl --kubeconfig ${kubeconfigPath} rollout status -n ${satelliteNamespace} deployment otel-collector`,
125-
{ slice: sliceName },
122+
checks.push(
123+
exec(
124+
`kubectl --kubeconfig ${kubeconfigPath} rollout status -n ${satelliteNamespace} deployment kube-state-metrics`,
125+
{ slice: sliceName, async: true },
126+
),
127+
);
128+
checks.push(
129+
exec(
130+
`kubectl --kubeconfig ${kubeconfigPath} rollout status -n ${satelliteNamespace} deployment otel-collector`,
131+
{ slice: sliceName, async: true },
132+
),
126133
);
127134

128135
// core-dev is just too unstable for node-exporter
129136
// we don't guarantee that it will run at all
130137
if (this.options.withVM) {
131-
exec(
132-
`kubectl --kubeconfig ${kubeconfigPath} rollout status -n ${satelliteNamespace} daemonset node-exporter`,
133-
{ slice: sliceName },
138+
checks.push(
139+
exec(
140+
`kubectl --kubeconfig ${kubeconfigPath} rollout status -n ${satelliteNamespace} daemonset node-exporter`,
141+
{ slice: sliceName, async: true },
142+
),
134143
);
135144
}
145+
146+
await Promise.all(checks);
136147
}
137148

138149
private deployGitpodServiceMonitors() {

0 commit comments

Comments
 (0)