Skip to content

Add gradual deployments documentation the Cf-Worker-Version-Key header.#13554

Merged
irvinebroque merged 5 commits intogradual-deploymentsfrom
jphillips/worker-version-key
Mar 29, 2024
Merged

Add gradual deployments documentation the Cf-Worker-Version-Key header.#13554
irvinebroque merged 5 commits intogradual-deploymentsfrom
jphillips/worker-version-key

Conversation

@jp4a50
Copy link
Copy Markdown
Contributor

@jp4a50 jp4a50 commented Mar 20, 2024

No description provided.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Mar 20, 2024

Deploying cloudflare-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2a63e3b
Status: ✅  Deploy successful!
Preview URL: https://5e7727a7.cloudflare-docs-7ou.pages.dev
Branch Preview URL: https://jphillips-worker-version-key.cloudflare-docs-7ou.pages.dev

View logs

@github-actions
Copy link
Copy Markdown
Contributor

@jp4a50 jp4a50 force-pushed the jphillips/worker-version-key branch from f794976 to a1a7e87 Compare March 20, 2024 21:29
```
You should see 10 responses. Responses will reflect the content returned by the versions in your deployment. Responses will vary depending on the percentages configured in step #6.

## Version keys
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think content should live here but we should add link to here from https://developers.cloudflare.com/workers/runtime-apis/headers/ so that if someone sees this, they look at headers docs in runtime APIs and can find it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah we probably should add something there.

We don't appear to actually have any prior art in terms of headers that can be set by users that are interpreted by the runtime, so I'll probably have to create a new section.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Having thought about it, since the section directly linked is runtime-specific (and it's arguably an implementation detail that this header is handled by the runtime) and the page it links to specifically discusses headers added by Cloudflare, I don't think there's an obviously place to slot this. Unless you feel strongly, I'll stick with just the docs here for now.

You can set the `Cf-Worker-Version-Key` header both when making an external request from the Internet to your Worker, as well as when making a subrequest from one Worker to another Worker using a [service binding](/workers/runtime-apis/bindings/service-bindings/).
### Extracting version keys from URLs

If the unique identifier that you want to provide to `Cf-Worker-Version-Key` is in the URL of the incoming request, you can configure a [Ruleset Engine](/ruleset-engine/) rule on your zone to extract this key from the path or querystring, and use its value to set `Cf-Worker-Verison-Key`. This allows you to ensure version affinity, while avoiding having to modify the external client that makes the request.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe example rule here that does basic "grab ID from URL and pop into header"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure.

I think the most likely use case will be setting the header equal to a cookie's value so probably would make most sense to show that.

I'll copy the format used in request header modification examples.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Uh oh. It looks like this won't work right now.

I tested the ruleset engine header transformation stuff before I landed on a name for the header. It turns out ruleset engine won't let you set any headers beginning with Cf- :(

I'll have to remove the rulset engine section for now...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added an example that extracts the header from the URL as you originally suggested since rules engine limitations make it more complicated than it should be to extract it from a cookie (I'm pushing them to make it easier).

Co-authored-by: Tanushree <87711021+tanushreesharma-cf@users.noreply.github.com>
@jp4a50 jp4a50 changed the title Add documentation for the Cf-Worker-Version-Key header. Add documentation for Durable Objects gradual deployments and the Cf-Worker-Version-Key header. Mar 21, 2024
@jp4a50 jp4a50 changed the title Add documentation for Durable Objects gradual deployments and the Cf-Worker-Version-Key header. Add gradual deployments documentation for Durable Objects and the Cf-Worker-Version-Key header. Mar 21, 2024
@jp4a50 jp4a50 force-pushed the jphillips/worker-version-key branch from cad0adc to a9de2e4 Compare March 21, 2024 17:58
@jp4a50
Copy link
Copy Markdown
Contributor Author

jp4a50 commented Mar 21, 2024

We're postponing documentation for the version key header.

I've opened a dedicated PR for gradual rollouts docs here: #13564

@jp4a50 jp4a50 closed this Mar 21, 2024
@irvinebroque
Copy link
Copy Markdown
Contributor

Reopening so that we don't forget to do this with rename

@irvinebroque irvinebroque reopened this Mar 27, 2024
@jp4a50
Copy link
Copy Markdown
Contributor Author

jp4a50 commented Mar 27, 2024

I'll pick it back up now.

@jp4a50 jp4a50 changed the title Add gradual deployments documentation for Durable Objects and the Cf-Worker-Version-Key header. Add gradual deployments documentation the Cf-Worker-Version-Key header. Mar 28, 2024
@jp4a50 jp4a50 force-pushed the jphillips/worker-version-key branch from b28425b to 2a63e3b Compare March 28, 2024 21:43
@jp4a50 jp4a50 requested a review from deadlypants1973 as a code owner March 28, 2024 21:43
@irvinebroque irvinebroque merged commit 92f7748 into gradual-deployments Mar 29, 2024
@irvinebroque irvinebroque deleted the jphillips/worker-version-key branch March 29, 2024 00:20
tanushree-sharma added a commit that referenced this pull request Mar 29, 2024
* wip-deployments-update

* first pass at docs

* Apply suggestions from code review

Co-authored-by: Brendan Irvine-Broque <birvine-broque@cloudflare.com>

* wrangler commands & feedback

* Apply suggestions from code review

Co-authored-by: Jon Phillips <jonap2811@gmail.com>

* Apply suggestions from code review

Co-authored-by: Kate Tungusova <70746074+deadlypants1973@users.noreply.github.com>

* ESM limitation, wrangler updates

* Apply suggestions from code review

Co-authored-by: Kate Tungusova <70746074+deadlypants1973@users.noreply.github.com>

* Document gradual deployment benefit of ESM format

Link to gradual deployments docs from "Migrate to ESM" page

* [Workers] Remove note about D1 limitations with rollbacks (#13579)

* wrangler commands and edits

* Apply suggestions from code review

Co-authored-by: Kate Tungusova <70746074+deadlypants1973@users.noreply.github.com>
Co-authored-by: Brendan Irvine-Broque <birvine-broque@cloudflare.com>

* Apply suggestions from code review

PCX review

* PCX edits

* edits

* redirects

* Add gradual deployments documentation the `Cf-Worker-Version-Key` header. (#13554)

* Add documentation for the `Cf-Worker-Version-Key` header.

* Apply suggestions from code review

* Update content/workers/configuration/versions-and-deployments/gradual-deployments.md

* Apply suggestions from code review

Co-authored-by: Tanushree <87711021+tanushreesharma-cf@users.noreply.github.com>

* Add example of using a request header modification rule to set
Cloudflare-Workers-Version-Key.

---------

Co-authored-by: Brendan Irvine-Broque <birvine-broque@cloudflare.com>
Co-authored-by: Tanushree <87711021+tanushreesharma-cf@users.noreply.github.com>

* fixes

* keywords, broken link fixes

* redirect fix

---------

Co-authored-by: Brendan Irvine-Broque <birvine-broque@cloudflare.com>
Co-authored-by: Jon Phillips <jonap2811@gmail.com>
Co-authored-by: Kate Tungusova <70746074+deadlypants1973@users.noreply.github.com>
Co-authored-by: aaronlisman <83968625+aaronlisman@users.noreply.github.com>
Co-authored-by: Kate Tungusova <ktungusova@cloudflare.com>
cmsparks pushed a commit that referenced this pull request Apr 1, 2024
* wip-deployments-update

* first pass at docs

* Apply suggestions from code review

Co-authored-by: Brendan Irvine-Broque <birvine-broque@cloudflare.com>

* wrangler commands & feedback

* Apply suggestions from code review

Co-authored-by: Jon Phillips <jonap2811@gmail.com>

* Apply suggestions from code review

Co-authored-by: Kate Tungusova <70746074+deadlypants1973@users.noreply.github.com>

* ESM limitation, wrangler updates

* Apply suggestions from code review

Co-authored-by: Kate Tungusova <70746074+deadlypants1973@users.noreply.github.com>

* Document gradual deployment benefit of ESM format

Link to gradual deployments docs from "Migrate to ESM" page

* [Workers] Remove note about D1 limitations with rollbacks (#13579)

* wrangler commands and edits

* Apply suggestions from code review

Co-authored-by: Kate Tungusova <70746074+deadlypants1973@users.noreply.github.com>
Co-authored-by: Brendan Irvine-Broque <birvine-broque@cloudflare.com>

* Apply suggestions from code review

PCX review

* PCX edits

* edits

* redirects

* Add gradual deployments documentation the `Cf-Worker-Version-Key` header. (#13554)

* Add documentation for the `Cf-Worker-Version-Key` header.

* Apply suggestions from code review

* Update content/workers/configuration/versions-and-deployments/gradual-deployments.md

* Apply suggestions from code review

Co-authored-by: Tanushree <87711021+tanushreesharma-cf@users.noreply.github.com>

* Add example of using a request header modification rule to set
Cloudflare-Workers-Version-Key.

---------

Co-authored-by: Brendan Irvine-Broque <birvine-broque@cloudflare.com>
Co-authored-by: Tanushree <87711021+tanushreesharma-cf@users.noreply.github.com>

* fixes

* keywords, broken link fixes

* redirect fix

---------

Co-authored-by: Brendan Irvine-Broque <birvine-broque@cloudflare.com>
Co-authored-by: Jon Phillips <jonap2811@gmail.com>
Co-authored-by: Kate Tungusova <70746074+deadlypants1973@users.noreply.github.com>
Co-authored-by: aaronlisman <83968625+aaronlisman@users.noreply.github.com>
Co-authored-by: Kate Tungusova <ktungusova@cloudflare.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product:workers Related to Workers product size/s

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants