-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix prometheus-operator test to wait for the CRD to be ready before use
- Loading branch information
Showing
6 changed files
with
189 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import * as k8sClient from "@kubernetes/client-node"; | ||
|
||
// Wait for the CRD to be established. | ||
// Use the k8s JS client (https://github.com/kubernetes-client/javascript) | ||
// to retrieve resource created by the operator as a workaround for: | ||
// https://github.com/pulumi/pulumi-kubernetes/issues/1056 | ||
export async function checkCrdStatus(client: k8sClient.ApiextensionsV1Api): Promise<boolean> { | ||
for (let i = 0; i < 20; i++){ | ||
try { | ||
const crd = await client.readCustomResourceDefinition("servicemonitors.monitoring.coreos.com"); | ||
let conditions = crd?.body?.status?.conditions; | ||
if (conditions) { | ||
for (let c of conditions) { | ||
if (c.type == "Established" && c.status == "True") { | ||
console.log("ServiceMonitor CRD is ready"); | ||
return true; | ||
} | ||
} | ||
} | ||
break; | ||
} catch(e) { | ||
console.log(`Waiting for ServiceMonitor CRD to be ready (${i+1})`) | ||
await new Promise(resolve => setTimeout(resolve, 3 * 1000)); | ||
} | ||
} | ||
return false; | ||
} |