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

WC-1308 Reduce force-deletes unless explicitly confirmed #3426

Conversation

matthewdavidrodgers
Copy link
Contributor

@matthewdavidrodgers matthewdavidrodgers commented Jun 9, 2023

Changes the default ?force param to the delete API call to be false.

Also uses the /scripts/{scriptName}/references and /tails/by-consumer/{scriptName} endpoints to determine what resources depend on the current script. We check for other scripts that use this one as outbound worker (for dynamic dispatch), as a tail worker, as a service binding, or use a durable object implemented by this script. If any other resources rely on this worker, we require another step of confirmation, describing the dependencies, and only then do we allow doing a force delete.

for WC-1308

Author has included the following, where applicable:

Reviewer is to perform the following, as applicable:

  • Checked for inclusion of relevant tests
  • Checked for inclusion of a relevant changeset
  • Checked for creation of associated docs updates
  • Manually pulled down the changes and spot-tested

@changeset-bot
Copy link

changeset-bot bot commented Jun 9, 2023

🦋 Changeset detected

Latest commit: a71815c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wrangler Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@matthewdavidrodgers
Copy link
Contributor Author

Definitely open to any suggestions on copy here - see the included test for an example

@github-actions
Copy link
Contributor

github-actions bot commented Jun 9, 2023

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/5467339575/npm-package-wrangler-3426

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/3426/npm-package-wrangler-3426

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/5467339575/npm-package-wrangler-3426 dev path/to/script.js
Additional artifacts:
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/5467339575/npm-package-cloudflare-pages-shared-3426

Note that these links will no longer work once the GitHub Actions artifact expires.

@codecov
Copy link

codecov bot commented Jun 9, 2023

Codecov Report

Merging #3426 (a71815c) into main (12930ae) will increase coverage by 0.14%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3426      +/-   ##
==========================================
+ Coverage   75.09%   75.24%   +0.14%     
==========================================
  Files         190      190              
  Lines       11110    11160      +50     
  Branches     2919     2944      +25     
==========================================
+ Hits         8343     8397      +54     
+ Misses       2767     2763       -4     
Impacted Files Coverage Δ
packages/wrangler/src/delete.ts 100.00% <100.00%> (ø)

... and 3 files with indirect coverage changes

@matthewdavidrodgers matthewdavidrodgers marked this pull request as ready for review June 21, 2023 16:49
@matthewdavidrodgers matthewdavidrodgers requested review from a team as code owners June 21, 2023 16:49
.changeset/twelve-pumpkins-crash.md Outdated Show resolved Hide resolved
packages/wrangler/src/delete.ts Outdated Show resolved Hide resolved
packages/wrangler/src/delete.ts Outdated Show resolved Hide resolved
packages/wrangler/src/delete.ts Outdated Show resolved Hide resolved
packages/wrangler/src/delete.ts Outdated Show resolved Hide resolved
packages/wrangler/src/delete.ts Outdated Show resolved Hide resolved
penalosa
penalosa previously approved these changes Jun 28, 2023
@penalosa penalosa self-requested a review June 28, 2023 17:43
@penalosa
Copy link
Contributor

Actually, looking at this again—the delete command should take a --force flag to override the checking behaviour

@lrapoport-cf
Copy link
Contributor

Actually, looking at this again—the delete command should take a --force flag to override the checking behaviour

@penalosa should merge be blocked on this? if so, can you update your approval :)

@penalosa penalosa dismissed their stale review June 29, 2023 00:04

Force flag

Copy link
Contributor

@penalosa penalosa left a comment

Choose a reason for hiding this comment

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

This should have a --force flag

Copy link
Contributor

@penalosa penalosa left a comment

Choose a reason for hiding this comment

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

Looks good to me. Let's have another person in @cloudflare/wrangler take a pass before merging though

Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

Nice PR! Really clean and understandable code.

Can you confirm that the new requests are to stable public APIs? So that Wrangler won't get broken by them being changed or removed.

I think it would be good to only ask about deleting if there is no --force flag, and also can we move the new types into the delete.ts file.

Otherwise LGTM!

Changes the default ?force param to the delete API call to be false.

Also uses the /scripts/{scriptName}/references and
/tails/by-consumer/{scriptName} endpoints to determine what resources
depend on the current script. We check for other scripts that use this
one as outbound worker (for dynamic dispatch), as a tail worker, as a
service binding, or use a durable object implemented by this script.
If any other resources rely on this worker, we require another step of
confirmation, describing the dependencies, and only then do we allow
doing a force delete.
Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

❤️

@petebacondarwin
Copy link
Contributor

Um last thought... is this a breaking change for users that previously expected their deletions to be forced through, even if that is bad for them?

@matthewdavidrodgers
Copy link
Contributor Author

Um last thought... is this a breaking change for users that previously expected their deletions to be forced through, even if that is bad for them?

erm, I don't know. I suppose you could classify it as a breaking change, albeit not a very impactful one

@petebacondarwin
Copy link
Contributor

OK so I think the opinion is that this does not deserve a major versio bump.
Looks good to me. Let's :shipit:

@matthewdavidrodgers matthewdavidrodgers merged commit 5a74cb5 into cloudflare:main Jul 6, 2023
12 checks passed
@github-actions github-actions bot mentioned this pull request Jul 6, 2023
lrapoport-cf pushed a commit that referenced this pull request Aug 11, 2023
Changes the default ?force param to the delete API call to be false.

Also uses the /scripts/{scriptName}/references and
/tails/by-consumer/{scriptName} endpoints to determine what resources
depend on the current script. We check for other scripts that use this
one as outbound worker (for dynamic dispatch), as a tail worker, as a
service binding, or use a durable object implemented by this script.
If any other resources rely on this worker, we require another step of
confirmation, describing the dependencies, and only then do we allow
doing a force delete.
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