@@ -11,11 +11,14 @@ import {
1111 CLUSTER_NAME ,
1212 clusterProdLike ,
1313 commandScriptPath ,
14+ createVolumeSnapshot ,
1415 ExactNamespace ,
1516 GCP_PROJECT ,
1617 GrafanaKeys ,
1718 HELM_MAX_HISTORY_SIZE ,
1819 infraAffinityAndTolerations ,
20+ infraPremiumStorageClassName ,
21+ infraStandardStorageClassName ,
1922 isMainNet ,
2023 loadTesterConfig ,
2124 ObservabilityReleaseName ,
@@ -32,6 +35,7 @@ import { local } from '@pulumi/command';
3235import { getSecretVersionOutput } from '@pulumi/gcp/secretmanager/getSecretVersion' ;
3336import { Input } from '@pulumi/pulumi' ;
3437
38+ import { hyperdiskSupportConfig } from '../../common/src/config/hyperdiskSupportConfig' ;
3539import {
3640 clusterIsResetPeriodically ,
3741 enableAlertEmailToSupportTeam ,
@@ -91,9 +95,9 @@ const grafanaExternalUrl = `https://grafana.${CLUSTER_HOSTNAME}`;
9195const alertManagerExternalUrl = `https://alertmanager.${ CLUSTER_HOSTNAME } ` ;
9296const prometheusExternalUrl = `https://prometheus.${ CLUSTER_HOSTNAME } ` ;
9397const shouldIgnoreNoDataOrDataSourceError = clusterIsResetPeriodically ;
98+ const namespaceName = 'observability' ;
9499
95100export function configureObservability ( dependsOn : pulumi . Resource [ ] = [ ] ) : pulumi . Resource {
96- const namespaceName = 'observability' ;
97101 const namespace = new k8s . core . v1 . Namespace (
98102 namespaceName ,
99103 {
@@ -116,6 +120,7 @@ export function configureObservability(dependsOn: pulumi.Resource[] = []): pulum
116120 const prometheusStackCrdVersion = '0.85.0' ;
117121 const postgres = installPostgres ( { ns : namespace , logicalName : namespaceName } ) ;
118122 const adminPassword = grafanaKeysFromSecret ( ) . adminPassword ;
123+ const migrationSnapshots = getVolumeSnapshotsForHyperdiskMigration ( ) ;
119124 const prometheusStack = new k8s . helm . v3 . Release (
120125 'observability-metrics' ,
121126 {
@@ -205,13 +210,14 @@ export function configureObservability(dependsOn: pulumi.Resource[] = []): pulum
205210 storage : {
206211 volumeClaimTemplate : {
207212 spec : {
208- storageClassName : 'standard-rwo' ,
213+ storageClassName : infraStandardStorageClassName ,
209214 accessModes : [ 'ReadWriteOnce' ] ,
210215 resources : {
211216 requests : {
212217 storage : '5Gi' ,
213218 } ,
214219 } ,
220+ ...( migrationSnapshots . alertManager ? migrationSnapshots . alertManager : { } ) ,
215221 } ,
216222 } ,
217223 } ,
@@ -266,13 +272,14 @@ export function configureObservability(dependsOn: pulumi.Resource[] = []): pulum
266272 storageSpec : {
267273 volumeClaimTemplate : {
268274 spec : {
269- storageClassName : 'premium-rwo' ,
275+ storageClassName : infraPremiumStorageClassName ,
270276 accessModes : [ 'ReadWriteOnce' ] ,
271277 resources : {
272278 requests : {
273279 storage : infraConfig . prometheus . storageSize ,
274280 } ,
275281 } ,
282+ ...( migrationSnapshots . prometheus ? migrationSnapshots . prometheus : { } ) ,
276283 } ,
277284 } ,
278285 } ,
@@ -398,7 +405,7 @@ export function configureObservability(dependsOn: pulumi.Resource[] = []): pulum
398405 type : 'Recreate' ,
399406 } ,
400407 persistence : {
401- enabled : true ,
408+ enabled : ! hyperdiskSupportConfig . hyperdiskSupport . migratingInfra ,
402409 type : 'pvc' ,
403410 accessModes : [ 'ReadWriteOnce' ] ,
404411 size : '5Gi' ,
@@ -1065,3 +1072,30 @@ function installPostgres(namespace: ExactNamespace): SplicePostgres {
10651072 true // useInfraAffinityAndTolerations
10661073 ) ;
10671074}
1075+
1076+ function getVolumeSnapshotsForHyperdiskMigration ( ) {
1077+ if ( hyperdiskSupportConfig . hyperdiskSupport . migratingInfra ) {
1078+ const { dataSource : prometheusDataSource } = createVolumeSnapshot ( {
1079+ resourceName : `prometheus-hd-migration-snapshot` ,
1080+ snapshotName : `prometheus-migration-snapshot` ,
1081+ namespace : namespaceName ,
1082+ pvcName : `prometheus-prometheus-prometheus-db-prometheus-prometheus-prometheus-0` ,
1083+ } ) ;
1084+ const { dataSource : alertManagerDataSource } = createVolumeSnapshot ( {
1085+ resourceName : `alertmanager-hd-migration-snapshot` ,
1086+ snapshotName : `alertmanager-migration-snapshot` ,
1087+ namespace : namespaceName ,
1088+ pvcName : `alertmanager-prometheus-alertmanager-db-alertmanager-prometheus-alertmanager-0` ,
1089+ } ) ;
1090+ return {
1091+ prometheus : {
1092+ dataSource : prometheusDataSource ,
1093+ } ,
1094+ alertManager : {
1095+ dataSource : alertManagerDataSource ,
1096+ } ,
1097+ } ;
1098+ } else {
1099+ return { } ;
1100+ }
1101+ }
0 commit comments