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

Update cleanupResources workflow to check for deletionProtection #279

Merged
merged 8 commits into from
Aug 30, 2024

Conversation

aulorbe
Copy link
Contributor

@aulorbe aulorbe commented Aug 30, 2024

Problem

Currently, the cleanupResources script fails to delete some indexes that spin up during our integration test suite because some of these indexes have deletionProtection enabled.

Solution

Check for deletionProtection being enabled; if it is, set it to disabled.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Infrastructure change (CI configs, etc)
  • Non-code change (docs, etc)
  • None of the above: (explain here)

Test Plan

CI passes


for (const collection of collectionList.collections) {
console.log(`Deleting collection ${collection.name}`);
await p.deleteCollection(collection.name);
if (collectionList.collections) {
Copy link
Contributor Author

@aulorbe aulorbe Aug 30, 2024

Choose a reason for hiding this comment

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

Just added a quick check for undefined, since my IDE was throwing errors because collectionList.collections could be undefined.

.eslintrc.json Outdated
@@ -24,6 +24,7 @@
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-inferrable-types": "off",
"import/no-cycle": "error"
"import/no-cycle": "error",
"@typescript-eslint/no-var-requires": "off"
Copy link
Contributor Author

@aulorbe aulorbe Aug 30, 2024

Choose a reason for hiding this comment

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

Long story w/this one, but essentially I added this because:

  • Our eslint config is set up to expect es6 modules (which use import for imports) on the line "sourceType": "module" .
  • Our tsconfig file, though, tells the compiler to use CJS syntax (which uses require for imports)
  • So, linting complains about the require statements in our utils/ files without the addition of this rule to our eslint config

Copy link
Contributor Author

@aulorbe aulorbe Aug 30, 2024

Choose a reason for hiding this comment

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

Deeper dive:

Q: Why doesn't my IDE complain about the files in dirs such as src/ using import instead of require, if tsconfig says we're supposed to be writing CJS?

  • This is because we also have the line "esModuleInterop": true in our tsconfig file. This allows us to use ESM syntax (import) in our Typescript files, even though the underlying module system is CJS.

Q: Why don't you just change the imports in the utils/ files to use import (ESM) instead of require (CJS) then?

Screenshot 2024-08-30 at 11 40 55 AM
  • This is because we run the files in utils/ with the node command, and node does not understand typescript or es6 (ESM) module syntax. By default, node expects CJS syntax.

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting, thanks for doing a deep dive on this. I see the IDE issues as well, but since we specifically lint src/ I think that's why this isn't generally an issue in CI and whatever.

I'd personally prefer something more specific more specific than disabling for the whole repo. I think we should probably look at cleaning some of these utility files up a bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

[ignore this -- made a ticket to address in a separate PR: https://app.asana.com/0/1203260648987893/1208186698556902/f]

for (const index of response.indexes) {
console.log(`Deleting index ${index.name}`);
await p.deleteIndex(index.name);
if (response.indexes) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(Same here wrt undefined)

@@ -1,4 +1,7 @@
var dotenv = require('dotenv');
const dotenv = require('dotenv');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since this item doesn't change, I switched it to const on my IDE's advice :)

@aulorbe aulorbe requested a review from austin-denoble August 30, 2024 18:51
Copy link
Contributor

@austin-denoble austin-denoble left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for cleaning this up!

@aulorbe aulorbe merged commit eec04fb into main Aug 30, 2024
29 checks passed
@aulorbe aulorbe deleted the Audrey/add-deletion-protection-check branch August 30, 2024 23:30
aulorbe added a commit that referenced this pull request Sep 11, 2024
## Problem

Currently, the `cleanupResources` script
[fails](https://github.com/pinecone-io/pinecone-ts-client/actions/runs/10623637432/job/29452705669?pr=278)
to delete some indexes that spin up during our integration test suite
because some of these indexes have `deletionProtection` `enabled`.

## Solution

Check for `deletionProtection` being `enabled`; if it is, set it to
`disabled`.

## Type of Change

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update
- [ ] Infrastructure change (CI configs, etc)
- [ ] Non-code change (docs, etc)
- [ ] None of the above: (explain here)

## Test Plan

CI passes

---
- To see the specific tasks where the Asana app for GitHub is being
used, see below:
  - https://app.asana.com/0/0/1208192096733434
  - https://app.asana.com/0/0/1208186698556887
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.

2 participants