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

Bradley/r2 event notification get #6652

Merged
merged 3 commits into from
Sep 11, 2024

Conversation

bthwaites
Copy link
Contributor

@bthwaites bthwaites commented Sep 9, 2024

What this PR solves / how to test

  • Updates the expected R2 Event Notification GET payload from the Cloudflare API.
  • Updates the R2 action types that are included in the object-delete event type.
  • Updates the format of the table of rules that is displayed after running wrangler r2 bucket notification get

Note: The change to the GET payload is not backwards compatible. Users will need to update to the latest version of wrangler to continue using Event Notifications after the GA launch. Backwards compatibility is added here for the case that we need to revert the API changes.

Fixes #[insert GH or internal issue number(s)].
Internal issues: R2-2379 and R2-2380

Author has addressed the following

  • Tests
    • TODO (before merge)
    • Included
    • Not necessary because:
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required / Maybe required
    • Not required because: there are no e2e tests for event notifications
  • Changeset (Changeset guidelines)
    • TODO (before merge)
    • Included
    • Not necessary because:
  • Public documentation

@bthwaites bthwaites requested a review from a team as a code owner September 9, 2024 14:10
Copy link

changeset-bot bot commented Sep 9, 2024

🦋 Changeset detected

Latest commit: fc10687

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

This PR includes changesets to release 2 packages
Name Type
wrangler Minor
@cloudflare/vitest-pool-workers Patch

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

Copy link
Contributor

github-actions bot commented Sep 9, 2024

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/10817376489/npm-package-wrangler-6652

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

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

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10817376489/npm-package-wrangler-6652 dev path/to/script.js
Additional artifacts:
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10817376489/npm-package-create-cloudflare-6652 --no-auto-update
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10817376489/npm-package-cloudflare-kv-asset-handler-6652
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10817376489/npm-package-miniflare-6652
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10817376489/npm-package-cloudflare-pages-shared-6652
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10817376489/npm-package-cloudflare-vitest-pool-workers-6652
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10817376489/npm-package-cloudflare-workers-editor-shared-6652
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10817376489/npm-package-cloudflare-workers-shared-6652

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


wrangler@3.76.0 includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20240821.2
workerd 1.20240909.0 1.20240909.0
workerd --version 1.20240909.0 2024-09-09

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

@bthwaites bthwaites force-pushed the bradley/r2-event-notification-get branch 6 times, most recently from 90040d3 to db05894 Compare September 10, 2024 00:54
@@ -0,0 +1,5 @@
---
"wrangler": major
Copy link
Contributor

@RamIdeas RamIdeas Sep 11, 2024

Choose a reason for hiding this comment

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

If the event notification feature is currently not GA, this can be a minor/patch bump

This PR cannot be merged while this is a major bump

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems this subcommand is not marked as experimental in the subhelp output:

$ npx wrangler r2 bucket --help             
wrangler r2 bucket

Manage R2 buckets

COMMANDS
  wrangler r2 bucket create <name>  Create a new R2 bucket
  wrangler r2 bucket update         Update bucket state
  wrangler r2 bucket list           List R2 buckets
  wrangler r2 bucket delete <name>  Delete an R2 bucket
  wrangler r2 bucket sippy          Manage Sippy incremental migration on an R2 bucket
  wrangler r2 bucket notification   Manage event notifications for an R2 bucket

GLOBAL FLAGS
  -j, --experimental-json-config  Experimental: support wrangler.json  [boolean]
  -c, --config                    Path to .toml configuration file  [string]
  -e, --env                       Environment to use for operations and .env files  [string]
  -h, --help                      Show help  [boolean]
  -v, --version                   Show version number  [boolean]

Can you add ${chalk.hex(betaCmdColor)("[open beta]")} to the end of the subcommand description please?

Comment on lines 67 to 65
"┌────────────┬────────┬─────────────────────────────────────┐
│ queue_name │ prefix │ suffix │ event_type │
├────────────┼────────┼─────────────────────────────────────┤
│ my-queue-1 │ /p1 │ s1/ │ object-create,object-delete
├────────────┼────────┼─────────────────────────────────────┤
│ my-queue-1 │ │ │ object-delete
├────────────┼────────┼─────────────────────────────────────┤
│ my-queue-2 │ //1 │ 2// │ object-delete
└────────────┴────────┴─────────────────────────────────────┘"
"┌──────────────────────────────────────┬──────────────────────────┬────────────┬────────┬────────┬───────────────────────────────────┐
rule_id │ created_at │ queue_name │ prefix │ suffix │ event_type
├──────────────────────────────────────┼──────────────────────────┼────────────┼────────┼────────┼───────────────────────────────────┤
68746106-12f8-4bba-a57b-adaf37fe11ca │ │ my-queue-1 │ /p1 │ s1/ │ PutObject,CopyObject,DeleteObject
├──────────────────────────────────────┼──────────────────────────┼────────────┼────────┼────────┼───────────────────────────────────┤
5aa280bb-39d7-48ed-8c21-405fcd078192 │ │ my-queue-1 │ │ │ DeleteObject
├──────────────────────────────────────┼──────────────────────────┼────────────┼────────┼────────┼───────────────────────────────────┤
c4725929-3799-477a-a8d9-2d300f957e51 │ 2024-09-05T01:02:03.000Z │ my-queue-2 │ //1 │ 2// │ LifecycleDeletion
└──────────────────────────────────────┴──────────────────────────┴────────────┴────────┴────────┴───────────────────────────────────┘"
Copy link
Contributor

Choose a reason for hiding this comment

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

This table is getting quite wide. Would it make sense to switch to a labelled list? (like deployments list)

Easily done with the formatLabelledValues util

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I like this suggestion, I'll check it out.

resp[args.bucket],
getQueueById
);
const tableOutput = await tableFromNotificationGetResponse(config, resp);
logger.table(tableOutput);
Copy link
Contributor

@RamIdeas RamIdeas Sep 11, 2024

Choose a reason for hiding this comment

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

To render as a labelled list instead:

Suggested change
logger.table(tableOutput);
logger.log(tableOutput.map((x) => formatLabelledValues(x)).join("\n\n"));

@bthwaites bthwaites force-pushed the bradley/r2-event-notification-get branch from db05894 to 1513dc6 Compare September 11, 2024 17:11
@bthwaites bthwaites force-pushed the bradley/r2-event-notification-get branch from 1513dc6 to fc10687 Compare September 11, 2024 18:20
@RamIdeas RamIdeas merged commit 648cfdd into cloudflare:main Sep 11, 2024
18 checks passed
andyjessop added a commit that referenced this pull request Sep 13, 2024
* main:
  Add pipeline binding to wrangler.toml (#6674)
  Fix Pages duplicating hash in redirects (#6680)
  Bradley/r2 event notification get (#6652)
  feat(wrangler): Add support for placement hints (#6625)
  fix(wrangler): Validate `routes` for Workers with assets (#6621)
  chore(deps): bump the workerd-and-workers-types group across 1 directory with 2 updates (#6673)
  chore(workers-shared): Configure GitHub Actions to deploy Asset Worker (#6542)
  feat: experimental workers assets can be ignored by adding a .assetsignore file (#6640)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants