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

DOP-5042: Search-manifest Netlify Integration Environments #38

Merged
merged 42 commits into from
Jan 3, 2025

Conversation

anabellabuckvar
Copy link
Collaborator

@anabellabuckvar anabellabuckvar commented Nov 15, 2024

TICKET

DOP-5042
Search-manifest Netlify Integration: Environments

NOTES

This PR cleans up the search-manifest extension by updating hardcoded variables to be environment-dependent, using shared code from the libs/utils package, and generally refactoring.

Upon deployment of any repo with /netlify-test-deploy in Slack, a manifest will be generated for that repo and uploaded to the dotcomstg S3 bucket and dotcomstg Atlas db for search manifests. The dotcomstg S3 bucket is docs-search-indexes-test/search-indexes/preprd/
The dotcomstg Atlas collection is search-staging.documents under the Search cluster.

Copy link

netlify bot commented Nov 15, 2024

Deploy Preview for redoc-ext-test failed. Why did it fail? →

Name Link
🔨 Latest commit 6da0faa
🔍 Latest deploy log https://app.netlify.com/sites/redoc-ext-test/deploys/6776bf2247b1ad0008c4a23e

Copy link

netlify bot commented Nov 15, 2024

Deploy Preview for persistence-module-ext canceled.

Name Link
🔨 Latest commit 6da0faa
🔍 Latest deploy log https://app.netlify.com/sites/persistence-module-ext/deploys/6776bf220815e20008ba7983

Copy link

netlify bot commented Nov 15, 2024

Deploy Preview for git-changed-file-extension canceled.

Name Link
🔨 Latest commit 6da0faa
🔍 Latest deploy log https://app.netlify.com/sites/git-changed-file-extension/deploys/6776bf22114efb0007568d79

Copy link

netlify bot commented Nov 15, 2024

Deploy Preview for populate-data-extension canceled.

Name Link
🔨 Latest commit 6da0faa
🔍 Latest deploy log https://app.netlify.com/sites/populate-data-extension/deploys/6776bf22aa0cb90008c46685

Copy link

netlify bot commented Nov 15, 2024

Deploy Preview for site-links-display failed. Why did it fail? →

Name Link
🔨 Latest commit 6da0faa
🔍 Latest deploy log https://app.netlify.com/sites/site-links-display/deploys/6776bf22d6d4bc0008a4d967

Copy link

netlify bot commented Nov 15, 2024

Deploy Preview for search-manifest-integration failed. Why did it fail? →

Name Link
🔨 Latest commit e98dd30
🔍 Latest deploy log https://app.netlify.com/sites/search-manifest-integration/deploys/6765b9e0b03391000847af86

Copy link

netlify bot commented Nov 15, 2024

Deploy Preview for search-manifest-extension ready!

Name Link
🔨 Latest commit 6da0faa
🔍 Latest deploy log https://app.netlify.com/sites/search-manifest-extension/deploys/6776bf22e41dee0008c99489
😎 Deploy Preview https://deploy-preview-38--search-manifest-extension.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Nov 15, 2024

Deploy Preview for snooty-cache-extension canceled.

Name Link
🔨 Latest commit 6da0faa
🔍 Latest deploy log https://app.netlify.com/sites/snooty-cache-extension/deploys/6776bf228b3c7e0008a254d0

Copy link

netlify bot commented Nov 15, 2024

Deploy Preview for test-monorepo-redoc failed. Why did it fail? →

Name Link
🔨 Latest commit ff86c1e
🔍 Latest deploy log https://app.netlify.com/sites/test-monorepo-redoc/deploys/6764a3b266ad16000872e36a

Copy link

netlify bot commented Nov 15, 2024

Deploy Preview for redirects-and-publish-extension canceled.

Name Link
🔨 Latest commit 6da0faa
🔍 Latest deploy log https://app.netlify.com/sites/redirects-and-publish-extension/deploys/6776bf222d89f400089583d8

Copy link

netlify bot commented Dec 10, 2024

Deploy Preview for slack-deploy-extension canceled.

Name Link
🔨 Latest commit 6da0faa
🔍 Latest deploy log https://app.netlify.com/sites/slack-deploy-extension/deploys/6776bf22f6e236000815f700

@@ -83,7 +89,9 @@ export const generateAndUploadManifests = async ({
AWS_S3_SECRET_ACCESS_KEY: dbEnvVars.AWS_S3_SECRET_ACCESS_KEY,
});

console.log(`S3 upload status: ${JSON.stringify(s3Status)}`);
console.log(
`S3 upload status: ${JSON.stringify(s3Status.$metadata.httpStatusCode)}`,
Copy link
Collaborator

@branberry branberry Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: I'm assuming we don't need the JSON.stringify when logging the httpStatusCode


for (const entry of mappedEntries) {
// Read and decode each entry
const decoded = BSON.deserialize(readFileSync(`documents/${entry}`));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use the async version of reading files whenever we can. The one case where you really need to use a sync function is with existsSync. Otherwise, async version of readFile is preferable. This would also you allow you to do a Promise.all(mappedEntries.map(...)) instead of the for loop.

searchProperty: string,
connectionInfo: SearchClusterConnectionInfo,
) => {
const documentsColl = await getDocumentsCollection({ ...connectionInfo });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await getDocumentsCollection({ ...connectionInfo }); is equivalent to await getDocumentsCollection(connectionInfo);

`Error removing stale property ${searchProperty} in database ${connectionInfo.databaseName}, collection ${connectionInfo.collectionName}: ${e}`,
);
} finally {
closeSearchDb();
Copy link
Collaborator

@branberry branberry Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we need an await here

@anabellabuckvar anabellabuckvar changed the title Dop 5042 b DOP-5042: Search-manifest Netlify Integration Environments Dec 20, 2024
const mappedEntries = entries.filter((fileName) => {
return (
fileName.includes('.bson') &&
!fileName.includes('images') &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might want to add a forward slash at the end images/ so that we don't accidentally exclude .bson files that might have the word images or includes in them

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thank you!!

Copy link
Collaborator

@seungpark seungpark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few comments below! logically looks good but i left some comments on clean ups and order of operations

libs/util/src/s3Connection/types.ts Outdated Show resolved Hide resolved
extensions/search-manifest/src/generateManifest/index.ts Outdated Show resolved Hide resolved
extensions/search-manifest/src/generateManifest/index.ts Outdated Show resolved Hide resolved
? 'docs-search-indexes-test/preprd'
: 'docs-search-indexes-test/prd',
prefix: 'search-indexes/',
// TODO: make into constants?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, i think the bucketName docs-search-indexes-test can also be a const FWIW. we upload to a single search bucket and separate envs by path (can leave as a comment!)

extensions/search-manifest/src/generateAndUpload.ts Outdated Show resolved Hide resolved
const status = await documentsColl?.deleteMany(query);
return status;
try {
const status = await documentsColl?.deleteMany(query);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using optional chaining, I think we should throw an error in the getDocumentsCollection function if we don't have a documentsColl object. If we don't have that, then this code doesn't work, and I think it makes sense to have that error occur where it happens.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just removed the optional chaining so an error will be thrown if we try to run deleteMany() on a nonexistent collection

Copy link
Collaborator

@seungpark seungpark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comments below of removing some unused definitions. but otherwise looks good!

Copy link
Collaborator

@seungpark seungpark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this LGTM!

@anabellabuckvar anabellabuckvar merged commit eefb1a8 into main Jan 3, 2025
29 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants