Skip to content
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

feat: support using GCS for backup uploader #1130

Merged
merged 76 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
81d89c4
Add test
JeffreyDallas Dec 16, 2024
ca46661
Save
JeffreyDallas Dec 16, 2024
cb79a05
Save
JeffreyDallas Dec 18, 2024
2e84977
change prefix
JeffreyDallas Dec 19, 2024
5ce7874
save
JeffreyDallas Dec 19, 2024
105cfbe
save
JeffreyDallas Dec 19, 2024
16ac154
Merge commit '861c579e353be7d452ff52e12c152123f5a84aef' into 00711-D-…
JeffreyDallas Dec 19, 2024
43ceb61
update
JeffreyDallas Dec 19, 2024
05174b9
save
JeffreyDallas Dec 19, 2024
30b9b94
update bucket name
JeffreyDallas Dec 19, 2024
e878555
fix id token
JeffreyDallas Dec 19, 2024
a87fc71
save
JeffreyDallas Dec 19, 2024
d13b2b6
save
JeffreyDallas Dec 19, 2024
ae8ddd2
update service account
JeffreyDallas Dec 23, 2024
defd504
save
JeffreyDallas Dec 23, 2024
0a7eccc
add install solo
JeffreyDallas Dec 23, 2024
517b91a
save
JeffreyDallas Dec 23, 2024
083b2aa
add dump info
JeffreyDallas Dec 23, 2024
a87f48f
save
JeffreyDallas Dec 23, 2024
17676be
save
JeffreyDallas Dec 23, 2024
849efc5
debug
JeffreyDallas Dec 23, 2024
93981cd
typo
JeffreyDallas Dec 23, 2024
6ad1d53
add test
JeffreyDallas Dec 23, 2024
c385c9f
save
JeffreyDallas Dec 23, 2024
9a899af
save
JeffreyDallas Dec 23, 2024
0548825
setup helm
JeffreyDallas Dec 23, 2024
6443e75
save
JeffreyDallas Dec 23, 2024
63c9f37
save
JeffreyDallas Dec 23, 2024
1a9ebb5
stop debug
JeffreyDallas Dec 23, 2024
d6b27e8
Merge commit '1b9b7e67eac69aedec695e50d9a93377e381c530' into 00711-D-…
JeffreyDallas Dec 23, 2024
1dc7ad0
Merge branch 'main' into 00711-D-google-storage
JeffreyDallas Dec 30, 2024
f8b8cdf
save
JeffreyDallas Jan 2, 2025
b4b9295
fix env
JeffreyDallas Jan 2, 2025
9ea8cb5
save
JeffreyDallas Jan 2, 2025
2515917
fix unit test
JeffreyDallas Jan 2, 2025
08635f9
Merge commit 'aa4b3d32ce44a993a0de0ebfcd8753a1b8c359f7' into 00711-D-…
JeffreyDallas Jan 2, 2025
b76b404
fix unit test, remove labels
JeffreyDallas Jan 2, 2025
818ab21
save
JeffreyDallas Jan 3, 2025
f501176
Update src/commands/flags.ts
JeffreyDallas Jan 3, 2025
700d771
Update src/commands/flags.ts
JeffreyDallas Jan 3, 2025
66c6b45
Add enum for storage type
JeffreyDallas Jan 3, 2025
ce97963
save
JeffreyDallas Jan 3, 2025
ebb7ec8
add flags to mirror deploy
JeffreyDallas Jan 3, 2025
8e5dcb1
remove log
JeffreyDallas Jan 3, 2025
960b993
fix unit test
JeffreyDallas Jan 3, 2025
4e0f3c6
Merge commit '6e73f5798098766b9cf31cfd5995767a33565ad5' into 00711-D-…
JeffreyDallas Jan 6, 2025
d18254c
update flag comment
JeffreyDallas Jan 6, 2025
fad4e1e
reuse secret name
JeffreyDallas Jan 6, 2025
158849e
Update src/commands/network.ts
JeffreyDallas Jan 6, 2025
460a6b7
Update src/commands/network.ts
JeffreyDallas Jan 6, 2025
18588ed
add matrix for workflow
JeffreyDallas Jan 6, 2025
63694d9
Merge branch '00711-D-google-storage' of https://github.com/hashgraph…
JeffreyDallas Jan 6, 2025
cecdec9
update
JeffreyDallas Jan 6, 2025
ae45773
revert meaning
JeffreyDallas Jan 6, 2025
1076232
Update src/commands/network.ts
jeromy-cannon Jan 7, 2025
fcc4fd5
bump solo-charts version to pick up gcs/s3 changes in charts
jeromy-cannon Jan 7, 2025
45f0969
fix jobname
JeffreyDallas Jan 7, 2025
f29bdf6
Merge commit '5b9d937cd5db4d7ed63bbe695671a4857e6abda6' into 00711-D-…
JeffreyDallas Jan 7, 2025
1ad3d00
add backupBucket flag
JeffreyDallas Jan 7, 2025
c6fb3a7
save
JeffreyDallas Jan 8, 2025
278e769
save
JeffreyDallas Jan 8, 2025
c9eae0c
Removed cat on `save-secret-file` step
rbarkerSL Jan 8, 2025
6a5f65f
add env vraible
JeffreyDallas Jan 8, 2025
4552018
Merge branch '01101-D-backup-uploader' of https://github.com/hashgrap…
JeffreyDallas Jan 8, 2025
0b27e2f
Merge commit '1cd0e281c2ab90652471ebe1bdf66b4e5a667792' into 01101-D-…
JeffreyDallas Jan 8, 2025
0b5be36
Save
JeffreyDallas Jan 8, 2025
a72de88
save
JeffreyDallas Jan 8, 2025
f7e6177
switch to use secret to save credentials
JeffreyDallas Jan 8, 2025
ac7717d
Merge branch 'main' into 01101-D-backup-uploader
JeffreyDallas Jan 9, 2025
ec0fdb2
save
JeffreyDallas Jan 9, 2025
29f3b0e
save
JeffreyDallas Jan 9, 2025
48d1a0d
sace
JeffreyDallas Jan 9, 2025
6eca938
update chart version
JeffreyDallas Jan 9, 2025
759cd04
Merge commit 'ed6527b1ad9dda474967c6682d45e8de455343b3' into 01101-D-…
JeffreyDallas Jan 9, 2025
35fa101
Add test logic to check backup uploader logs
JeffreyDallas Jan 9, 2025
21beef7
Save
JeffreyDallas Jan 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/flow-gcs-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ jobs:
export BUCKET_NAME=${{ steps.jobs.outputs.job_id }}-solo-streams
gcloud storage buckets create gs://${BUCKET_NAME} --project=${{ vars.GCP_S3_PROJECT_ID }}
echo "BUCKET_NAME=${BUCKET_NAME}" >> $GITHUB_ENV

export BACKUP_BUCKET_NAME=${{ steps.jobs.outputs.job_id }}-solo-backups
gcloud storage buckets create gs://${BACKUP_BUCKET_NAME} --project=${{ vars.GCP_S3_PROJECT_ID }}
echo "BACKUP_BUCKET_NAME=${BACKUP_BUCKET_NAME}" >> $GITHUB_ENV

- name: Setup Node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
Expand Down Expand Up @@ -99,15 +103,18 @@ jobs:
- name: Compile Project
run: npm run build

- name: Run GCS Test Script for type ${{ matrix.channel }}
- name: Run GCS Test Script for type ${{ matrix.storageType }}
env:
GCS_ACCESS_KEY: ${{ secrets.GCP_S3_ACCESS_KEY }}
GCS_SECRET_KEY: ${{ secrets.GCP_S3_SECRET_KEY }}
BUCKET_NAME: ${{ env.BUCKET_NAME }}
BACKUP_BUCKET_NAME: ${{ env.BACKUP_BUCKET_NAME }}
STORAGE_TYPE: ${{ matrix.storageType }}
GCP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.GCP_SERVICE_ACCOUNT_TOKEN }}
run: |
.github/workflows/script/gcs_test.sh

- name: Delete Bucket after Test
run: |
gcloud storage rm --recursive gs://${BUCKET_NAME} --project=${{ vars.GCP_S3_PROJECT_ID }}
gcloud storage rm --recursive gs://${BACKUP_BUCKET_NAME} --project=${{ vars.GCP_S3_PROJECT_ID }}
28 changes: 27 additions & 1 deletion .github/workflows/script/gcs_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,25 @@ else
streamBucket=${BUCKET_NAME}
fi

if [ -z "${BACKUP_BUCKET_NAME}" ]; then
streamBackupBucket="solo-ci-backups"
else
streamBackupBucket=${BACKUP_BUCKET_NAME}
fi

if [ -z "${STORAGE_TYPE}" ]; then
storageType="gcs_and_minio"
else
storageType=${STORAGE_TYPE}
fi

if [ -z "${GCP_SERVICE_ACCOUNT_TOKEN}" ]; then
echo "GCP_SERVICE_ACCOUNT_TOKEN is not set. Exiting..."
exit 1
fi

echo "${GCP_SERVICE_ACCOUNT_TOKEN}" > gcp_service_account.json
JeffreyDallas marked this conversation as resolved.
Show resolved Hide resolved

echo "Using bucket name: ${streamBucket}"
echo "Test storage type: ${storageType}"

Expand All @@ -41,7 +54,9 @@ npm run solo-test -- node keys --gossip-keys --tls-keys -i node1
npm run solo-test -- network deploy -i node1 -n "${SOLO_NAMESPACE}" \
--storage-endpoint "https://storage.googleapis.com" \
--storage-access-key "${GCS_ACCESS_KEY}" --storage-secrets "${GCS_SECRET_KEY}" \
--storage-type "${storageType}" --storage-bucket "${streamBucket}"
--storage-type "${storageType}" --storage-bucket "${streamBucket}" \
--backup-bucket "${streamBackupBucket}" \
--google-credential gcp_service_account.json

npm run solo-test -- node setup -i node1 -n "${SOLO_NAMESPACE}"
npm run solo-test -- node start -i node1 -n "${SOLO_NAMESPACE}"
Expand All @@ -58,3 +73,14 @@ cd ..; create_test_account ; cd -
node examples/create-topic.js

npm run solo-test -- node stop -i node1 -n "${SOLO_NAMESPACE}"

# manually call script "backup.sh" from container backup-uploader since it only runs every 5 minutes
kubectl exec network-node1-0 -c backup-uploader -n solo-e2e -- /backup.sh > /dev/null 2>&1

# retrieve logs and check if it include the message type "error"
# example : {"level":"error","msg":"Updated modification time ......}
kubectl logs network-node1-0 -c backup-uploader -n solo-e2e > backup-uploader.log
if grep -q \""error\"" backup-uploader.log; then
echo "Backup uploader logs contain error message"
exit 1
fi
1 change: 0 additions & 1 deletion docs/content/User/SDK.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
First, please follow solo repository README to install solo and Docker Desktop.
You also need to install the Taskfile tool following the instructions [here](https://taskfile.dev/installation/).


Then we start with launching a local Solo network with the following commands:

```bash
Expand Down
24 changes: 24 additions & 0 deletions src/commands/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1675,6 +1675,28 @@ export class Flags {
prompt: undefined,
};

static readonly backupBucket: CommandFlag = {
constName: 'backupBucket',
name: 'backup-bucket',
definition: {
defaultValue: '',
describe: 'name of bucket for backing up state files',
type: 'string',
},
prompt: undefined,
};

static readonly googleCredential: CommandFlag = {
constName: 'googleCredential',
name: 'google-credential',
definition: {
defaultValue: '',
describe: 'path of google credential file in json format',
type: 'string',
},
prompt: undefined,
};

static readonly loadBalancerEnabled: CommandFlag = {
constName: 'loadBalancerEnabled',
name: 'load-balancer',
Expand Down Expand Up @@ -1769,6 +1791,8 @@ export class Flags {
Flags.storageSecrets,
Flags.storageEndpoint,
Flags.storageBucket,
Flags.backupBucket,
Flags.googleCredential,
Flags.tlsClusterIssuerType,
Flags.tlsPrivateKey,
Flags.tlsPublicKey,
Expand Down
29 changes: 29 additions & 0 deletions src/commands/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
storageSecrets: string;
storageEndpoint: string;
storageBucket: string;
backupBucket: string;
googleCredential: string;
}

export class NetworkCommand extends BaseCommand {
Expand Down Expand Up @@ -144,6 +146,8 @@
flags.storageSecrets,
flags.storageEndpoint,
flags.storageBucket,
flags.backupBucket,
flags.googleCredential,
];
}

Expand Down Expand Up @@ -207,6 +211,23 @@
`failed to create Kubernetes secret for storage credentials of type '${config.storageType}'`,
);
}
// generate backup uploader secret
if (config.googleCredential) {
const backupData = {};
const googleCredential = fs.readFileSync(config.googleCredential, 'utf8');

Check warning on line 217 in src/commands/network.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/commands/network.ts#L217

The application dynamically constructs file or path information.
backupData['saJson'] = Base64.encode(googleCredential);
const isBackupSecretCreated = await this.k8.createSecret(
constants.BACKUP_SECRET_NAME,
namespace,
'Opaque',
backupData,
undefined,
true,
);
if (!isBackupSecretCreated) {
throw new SoloError(`failed to create Kubernetes secret for backup uploader of type '${config.storageType}'`);
}
}
} catch (e: Error | any) {
const errorMessage = 'failed to create Kubernetes storage secret ';
this.logger.error(errorMessage, e);
Expand All @@ -231,6 +252,8 @@
storageSecrets: string;
storageEndpoint: string;
storageBucket: string;
backupBucket: string;
googleCredential: string;
loadBalancerEnabled: boolean;
}) {
let valuesArg = config.chartDirectory
Expand Down Expand Up @@ -279,6 +302,12 @@
valuesArg += ` --set cloud.buckets.streamBucket=${config.storageBucket}`;
valuesArg += ` --set minio-server.tenant.buckets[0].name=${config.storageBucket}`;
}

if (config.backupBucket) {
valuesArg += ' --set defaults.sidecars.backupUploader.enabled=true';
valuesArg += ` --set defaults.sidecars.backupUploader.config.backupBucket=${config.backupBucket}`;
}

const profileName = this.configManager.getFlag<string>(flags.profileName) as string;
this.profileValuesFile = await this.profileManager.prepareValuesForSoloChart(profileName);
if (this.profileValuesFile) {
Expand Down
1 change: 1 addition & 0 deletions src/core/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ export const IGNORED_NODE_ACCOUNT_ID = '0.0.0';

export const UPLOADER_SECRET_NAME = 'uploader-mirror-secrets';
export const MINIO_SECRET_NAME = 'minio-secrets';
export const BACKUP_SECRET_NAME = 'backup-uploader-secrets';

export const enum StorageType {
MINIO_ONLY = 'minio_only',
Expand Down
1 change: 1 addition & 0 deletions test/e2e/commands/network.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ describe('NetworkCommand', () => {
flags.storageAccessKey.constName,
flags.storageSecrets.constName,
flags.storageEndpoint.constName,
flags.googleCredential.constName,
]);
} catch (e) {
networkCmd.logger.showUserError(e);
Expand Down
1 change: 1 addition & 0 deletions test/test_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ export function e2eTestSuite(
flags.storageAccessKey.constName,
flags.storageSecrets.constName,
flags.storageEndpoint.constName,
flags.googleCredential.constName,
]);
}).timeout(Duration.ofMinutes(5).toMillis());

Expand Down
2 changes: 1 addition & 1 deletion version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/

export const HELM_VERSION = 'v3.14.2';
export const SOLO_CHART_VERSION = '0.41.0';
export const SOLO_CHART_VERSION = '0.42.0';
export const HEDERA_PLATFORM_VERSION = 'v0.58.1';
export const MIRROR_NODE_VERSION = '0.118.1';
export const HEDERA_EXPLORER_VERSION = '0.2.1';
Expand Down
Loading