mirror of
https://github.com/filecoin-project/slate.git
synced 2024-09-11 22:07:08 +03:00
scripts: recreate-bucket-bug scaffolding
This commit is contained in:
parent
51987e9112
commit
e7e2cc9ecf
@ -172,7 +172,7 @@ export const getBucketAPIFromUserToken = async ({
|
||||
const token = user.data.tokens.api;
|
||||
const name = Strings.isEmpty(bucketName) ? BUCKET_NAME : bucketName;
|
||||
const identity = await PrivateKey.fromString(token);
|
||||
const buckets = await Buckets.withKeyInfo(TEXTILE_KEY_INFO);
|
||||
let buckets = await Buckets.withKeyInfo(TEXTILE_KEY_INFO);
|
||||
|
||||
await buckets.getToken(identity);
|
||||
|
||||
|
94
scripts/recreate-bucket-bug.js
Normal file
94
scripts/recreate-bucket-bug.js
Normal file
@ -0,0 +1,94 @@
|
||||
import * as Environment from "~/node_common/environment";
|
||||
import * as Utilities from "~/node_common/utilities";
|
||||
import * as Social from "~/node_common/social";
|
||||
|
||||
import configs from "~/knexfile";
|
||||
import knex from "knex";
|
||||
|
||||
import { PrivateKey } from "@textile/hub";
|
||||
import { exec } from "child_process";
|
||||
|
||||
const envConfig = configs["development"];
|
||||
const db = knex(envConfig);
|
||||
|
||||
// NOTE(jim):
|
||||
// This script will reproduce the bucket bricking bug
|
||||
// We will trigger it by trying to upload a file thats too big.
|
||||
console.log(`RUNNING: recreate-bucket-bug.js`);
|
||||
|
||||
const TEXTILE_KEY_INFO = {
|
||||
key: Environment.TEXTILE_HUB_KEY,
|
||||
secret: Environment.TEXTILE_HUB_SECRET,
|
||||
};
|
||||
|
||||
const run = async () => {
|
||||
const identity = await PrivateKey.fromRandom();
|
||||
const api = identity.toString();
|
||||
|
||||
const user = {
|
||||
username: "SCRIPT_USER",
|
||||
data: {
|
||||
tokens: {
|
||||
api,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
console.log({ api });
|
||||
|
||||
let { buckets, bucketKey } = await Utilities.getBucketAPIFromUserToken({
|
||||
user,
|
||||
bucketName: "delete-this-bucket",
|
||||
});
|
||||
|
||||
// NOTE(jim): Verify this new bucket exists.
|
||||
let list = null;
|
||||
try {
|
||||
list = await buckets.list();
|
||||
console.log({ list });
|
||||
} catch (e) {
|
||||
console.log(e.message);
|
||||
Social.sendTextileSlackMessage({
|
||||
file: "recreate-bucket-bug.js",
|
||||
user,
|
||||
message: e.message,
|
||||
code: e.code,
|
||||
functionName: `buckets.list`,
|
||||
});
|
||||
}
|
||||
|
||||
// NOTE(jim): Remove the bucket from Textile.
|
||||
let bucketRemoval;
|
||||
try {
|
||||
bucketRemoval = await buckets.remove(list[0].key);
|
||||
} catch (e) {
|
||||
console.log(e.message);
|
||||
Social.sendTextileSlackMessage({
|
||||
file: "recreate-bucket-bug.js",
|
||||
user,
|
||||
message: e.message,
|
||||
code: e.code,
|
||||
functionName: `buckets.removePath`,
|
||||
});
|
||||
}
|
||||
|
||||
// NOTE(jim): Verify we cleaned up user data.
|
||||
try {
|
||||
list = await buckets.list();
|
||||
console.log({ emptyList: list });
|
||||
} catch (e) {
|
||||
console.log(e.message);
|
||||
Social.sendTextileSlackMessage({
|
||||
file: "recreate-bucket-bug.js",
|
||||
user,
|
||||
message: e.message,
|
||||
code: e.code,
|
||||
functionName: `buckets.list`,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
run();
|
||||
|
||||
console.log(`FINISHED: recreate-bucket-bug.js`);
|
||||
console.log(` CTRL +C to return to terminal.`);
|
Loading…
Reference in New Issue
Block a user