-
Notifications
You must be signed in to change notification settings - Fork 59
add support for migrating cometbft pvcs to hyperdisk #3658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,66 @@ | ||
| # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| suite: "cometbft pvc" | ||
| templates: | ||
| - pvc.yaml | ||
| release: | ||
| # Set for testing labels | ||
| name: global-domain-3 | ||
| set: | ||
| node: | ||
| identifier: "global-domain-3-cometbft" | ||
| tests: | ||
| - it: "deploys a PVC" | ||
| template: pvc.yaml | ||
| documentSelector: | ||
| path: kind | ||
| value: PersistentVolumeClaim | ||
| asserts: | ||
| - equal: | ||
| path: metadata.name | ||
| value: global-domain-3-cometbft-cometbft-data | ||
| - equal: | ||
| path: metadata.annotations["helm.sh/resource-policy"] | ||
| value: keep | ||
| - it: "uses custom pvcName in PVC when set" | ||
| template: pvc.yaml | ||
| set: | ||
| db: | ||
| pvcName: "custom-pvc-name" | ||
| documentSelector: | ||
| path: kind | ||
| value: PersistentVolumeClaim | ||
| asserts: | ||
| - equal: | ||
| path: metadata.name | ||
| value: custom-pvc-name | ||
| - it: "does not include dataSource in PVC when not set" | ||
| template: pvc.yaml | ||
| documentSelector: | ||
| path: kind | ||
| value: PersistentVolumeClaim | ||
| asserts: | ||
| - isNull: | ||
| path: spec.dataSource | ||
| - it: "includes dataSource in PVC when set" | ||
| template: pvc.yaml | ||
| set: | ||
| db: | ||
| dataSource: | ||
| kind: VolumeSnapshot | ||
| name: my-snapshot | ||
| apiGroup: snapshot.storage.k8s.io | ||
| documentSelector: | ||
| path: kind | ||
| value: PersistentVolumeClaim | ||
| asserts: | ||
| - equal: | ||
| path: spec.dataSource.kind | ||
| value: VolumeSnapshot | ||
| - equal: | ||
| path: spec.dataSource.name | ||
| value: my-snapshot | ||
| - equal: | ||
| path: spec.dataSource.apiGroup | ||
| value: snapshot.storage.k8s.io |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,29 +1,30 @@ | ||
| // Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| import * as gcp from '@pulumi/gcp'; | ||
| import * as k8s from '@pulumi/kubernetes'; | ||
| import * as _ from 'lodash'; | ||
| import { | ||
| activeVersion, | ||
| appsAffinityAndTolerations, | ||
| CLUSTER_BASENAME, | ||
| CLUSTER_HOSTNAME, | ||
| clusterSmallDisk, | ||
| config, | ||
| DomainMigrationIndex, | ||
| ExactNamespace, | ||
| GCP_ZONE, | ||
| InstalledHelmChart, | ||
| installSpliceHelmChart, | ||
| isDevNet, | ||
| loadYamlFromFile, | ||
| nonHyperdiskAppsAffinityAndTolerations, | ||
| SPLICE_ROOT, | ||
| SpliceCustomResourceOptions, | ||
| standardStorageClassName, | ||
| svCometBftKeysFromSecret, | ||
| withAddedDependencies, | ||
| } from '@lfdecentralizedtrust/splice-pulumi-common'; | ||
| import { CnChartVersion } from '@lfdecentralizedtrust/splice-pulumi-common/src/artifacts'; | ||
| import { jsonStringify, Output, Resource } from '@pulumi/pulumi'; | ||
| import { hyperdiskSupportConfig } from '@lfdecentralizedtrust/splice-pulumi-common/src/config/hyperdiskSupportConfig'; | ||
| import { CustomResource } from '@pulumi/kubernetes/apiextensions'; | ||
| import { jsonStringify, Output } from '@pulumi/pulumi'; | ||
|
|
||
| import { svsConfig } from '../config'; | ||
| import { SingleSvConfiguration } from '../singleSvConfig'; | ||
|
|
@@ -104,6 +105,41 @@ export function installCometBftNode( | |
| ? undefined | ||
| : installCometBftKeysSecret(xns, nodeConfig.validator.keyAddress, migrationId); | ||
|
|
||
| let hyperdiskDbValues = {}; | ||
| if (hyperdiskSupportConfig.hyperdiskSupport.enabled) { | ||
| hyperdiskDbValues = { | ||
| pvcName: `cometbft-migration-${migrationId}-hd-pvc`, | ||
| volumeStorageClass: standardStorageClassName, | ||
| }; | ||
| if (hyperdiskSupportConfig.hyperdiskSupport.migrating) { | ||
| const pvcSnapshot = new CustomResource( | ||
| `cometbft-${xns.logicalName}-migration-${migrationId}-snapshot`, | ||
| { | ||
| apiVersion: 'snapshot.storage.k8s.io/v1', | ||
| kind: 'VolumeSnapshot', | ||
| metadata: { | ||
| name: `cometbft-migration-${migrationId}-pd-snapshot`, | ||
| namespace: xns.logicalName, | ||
| }, | ||
| spec: { | ||
| volumeSnapshotClassName: 'dev-vsc', | ||
| source: { | ||
| persistentVolumeClaimName: `global-domain-${migrationId}-cometbft-cometbft-data`, | ||
| }, | ||
| }, | ||
| } | ||
| ); | ||
| hyperdiskDbValues = { | ||
| ...hyperdiskDbValues, | ||
| dataSource: { | ||
| kind: 'VolumeSnapshot', | ||
| name: pvcSnapshot.metadata.name, | ||
| apiGroup: 'snapshot.storage.k8s.io', | ||
| }, | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| const cometbftChartValues = _.mergeWith(cometBftValues, { | ||
| sv1: nodeConfigs.sv1, | ||
| istioVirtualService: { | ||
|
|
@@ -138,67 +174,12 @@ export function installCometBftNode( | |
| }, | ||
| db: { | ||
| volumeSize: clusterSmallDisk ? '240Gi' : svsConfig?.cometbft?.volumeSize, | ||
| ...hyperdiskDbValues, | ||
| }, | ||
| extraLogLevelFlags: svConfiguration.logging?.cometbftExtraLogLevelFlags, | ||
| serviceAccountName: imagePullServiceAccountName, | ||
| resources: svConfiguration.cometbft?.resources, | ||
| }); | ||
| const svIdentifier = nodeConfigs.selfSvNodeName; | ||
| const svIdentifierWithMigration = `${svIdentifier}-m${migrationId}`; | ||
| let volumeDependecies: Resource[] = []; | ||
| if (svConfiguration?.cometbft?.snapshotName) { | ||
| const volumeSize = cometbftChartValues.db.volumeSize; | ||
| const diskSnapshot = gcp.compute.getSnapshot({ | ||
| name: svConfiguration.cometbft.snapshotName, | ||
| }); | ||
|
|
||
| if (!GCP_ZONE) { | ||
| throw new Error('Zone is required to create a disk'); | ||
| } | ||
| const restoredDisk = new gcp.compute.Disk( | ||
| `${svIdentifierWithMigration}-cometbft-restored-data`, | ||
| { | ||
| name: `${svIdentifierWithMigration}-cometbft-restored-disk`, | ||
| // eslint-disable-next-line promise/prefer-await-to-then | ||
| size: diskSnapshot.then(snapshot => snapshot.diskSizeGb), | ||
| // eslint-disable-next-line promise/prefer-await-to-then | ||
| snapshot: diskSnapshot.then(snapshot => snapshot.selfLink), | ||
| type: 'pd-ssd', | ||
| zone: GCP_ZONE, | ||
| }, | ||
| opts | ||
| ); | ||
|
|
||
| // create the underlying persistent volume that will be used by cometbft from the state of an existing PV | ||
| volumeDependecies = [ | ||
| new k8s.core.v1.PersistentVolume( | ||
| `${svIdentifier}-cometbft-data`, | ||
| { | ||
| metadata: { | ||
| name: `${svIdentifier}-cometbft-data-pv`, | ||
| }, | ||
| spec: { | ||
| capacity: { | ||
| storage: volumeSize, | ||
| }, | ||
| volumeMode: 'Filesystem', | ||
| accessModes: ['ReadWriteOnce'], | ||
| persistentVolumeReclaimPolicy: 'Delete', | ||
| storageClassName: cometbftChartValues.db.volumeStorageClass, | ||
| claimRef: { | ||
| name: `global-domain-${migrationId}-cometbft-cometbft-data`, | ||
| namespace: xns.ns.metadata.name, | ||
| }, | ||
| csi: { | ||
| driver: 'pd.csi.storage.gke.io', | ||
| volumeHandle: restoredDisk.id, | ||
| }, | ||
| }, | ||
| }, | ||
| opts | ||
| ), | ||
| ]; | ||
| } | ||
|
Comment on lines
-146
to
-201
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is just dead code we use for the cluster migration |
||
| const protectCometBft = svsConfig?.cometbft?.protected ?? false; | ||
| const release = installSpliceHelmChart( | ||
| xns, | ||
|
|
@@ -208,13 +189,13 @@ export function installCometBftNode( | |
| version, | ||
| // support old runbook names, can be removed once the runbooks are all reset and latest release is >= 0.2.x | ||
| { | ||
| ...withAddedDependencies(opts, volumeDependecies.concat(keysSecret ? [keysSecret] : [])), | ||
| ...withAddedDependencies(opts, keysSecret ? [keysSecret] : []), | ||
| aliases: [{ name: `global-domain-${migrationId}-cometbft`, parent: undefined }], | ||
| ignoreChanges: ['name'], | ||
| protect: disableProtection ? false : protectCometBft, | ||
| }, | ||
| true, | ||
| nonHyperdiskAppsAffinityAndTolerations | ||
| appsAffinityAndTolerations | ||
| ); | ||
| return { rpcServiceName: `${nodeConfig.identifier}-cometbft-rpc`, release }; | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once again I bow before your bravery to change YAML without a test...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(looks fairly reasonable to me... but doesn't it always?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested manually but also added tests for everything now