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

Make Service environments the default #382

Closed
Electroid opened this issue Feb 3, 2022 · 14 comments
Closed

Make Service environments the default #382

Electroid opened this issue Feb 3, 2022 · 14 comments
Labels
blocked Blocked on other work enhancement New feature or request internal Requires support from the Cloudflare Platform

Comments

@Electroid
Copy link
Contributor

Previously, wrangler had implemented environments using the following algorithm:

function getUrl(name, environment) {
  return environment
    ? `/workers/scripts/${name}-${environment}`
    : `/workers/scripts/${name}`
}

Now, with the introduction of Services, we should change our implementation to be:

function getUrl(name, environment) {
  return `/workers/services/${name}/environments/${environment ?? "production"}`
}

There's also an additional question as to how to handle configurations that migrate from the "legacy" environments to the new Service environments. When a new script/environment is created, the API should return a 201 status code. When wrangler detects this, it should make an additional request to see if there is a "legacy" script. Here's an example:

// > PUT /workers/services/hello/environments/staging -> 200
// Since environment already exists, we're done.
// > PUT /workers/services/world/environments/dev -> 201
// Since environment is new, it's possible we could be replacing a "legacy" script. So check.

// > GET /workers/scripts/world-dev -> 404
// Since no "legacy" script exists, we're done.
// > PUT /workers/services/world/environments/dev -> 201
// Since environment is new, it's possible we could be replacing a "legacy" script. So check.

// > GET /workers/scripts/world-dev -> 200
// A "legacy" script exists, prompt the user about what's changed between wrangler 1 and 2.
// They can either: continue with the new environments, or use the "--legacy-env" flag.

Acceptance criteria:

  • All commands use Service environments.
  • If --legacy-env is passed, the "legacy" environment algorithm should be used.
  • Notifies users if it detects that it's replaced a "legacy" environment.
@Electroid Electroid added this to the 2.0 milestone Feb 3, 2022
@Electroid Electroid moved this to Blocking in workers-sdk Feb 7, 2022
@threepointone threepointone self-assigned this Feb 7, 2022
@threepointone threepointone moved this from Must-have to In Progress in workers-sdk Feb 10, 2022
@threepointone
Copy link
Contributor

threepointone commented Feb 21, 2022

Things to verify work well across legacy/service environments -

  • migrations
  • dev
  • secrets
  • sites
  • tail
  • kv
  • r2
  • publish
  • route ...args

Some open questions -

  • Apparently we consider the default environment to be 'production'. What happens if someone makes an environment called "production"? This seems like the worst problem.
  • What do we do with all the previous projects where we published wrangler environments, but we've now marked all as "production"? Leads to situations like this -
    image
  • When we run publish --env <name>, should env.<name> exist in wrangler.toml? Otherwise we could potentially publish scripts missing bindings/vars

@threepointone
Copy link
Contributor

threepointone commented Feb 21, 2022

First PR - #510 - --legacy-env / config.legacy_env

@threepointone
Copy link
Contributor

Fix routes - #517

@threepointone
Copy link
Contributor

secrets - #523

@threepointone
Copy link
Contributor

tail - #525

@threepointone
Copy link
Contributor

dev #532

@threepointone threepointone moved this from In Progress to Must-have in workers-sdk Mar 1, 2022
@threepointone
Copy link
Contributor

Unassigning this from myself while I work on a couple of other things for a while. The last major thing here is migrations with service envs. After this we need to make a call on the api side, and there may be breaking changes there.

@threepointone threepointone removed their assignment Mar 9, 2022
@petebacondarwin petebacondarwin modified the milestones: 2.0, 2.1 Mar 21, 2022
@threepointone
Copy link
Contributor

durable objects #868

@petebacondarwin petebacondarwin added the blocked Blocked on other work label May 11, 2022
@petebacondarwin petebacondarwin modified the milestones: 2.1, Blocked May 12, 2022
@petebacondarwin petebacondarwin added enhancement New feature or request and removed feature labels May 12, 2022
@petebacondarwin petebacondarwin modified the milestones: Selected for development, Backlog May 15, 2022
@petebacondarwin petebacondarwin moved this to Backlog in workers-sdk May 15, 2022
@petebacondarwin petebacondarwin removed this from the Backlog milestone May 15, 2022
@threepointone threepointone added the internal Requires support from the Cloudflare Platform label May 18, 2022
@alvgaona
Copy link

Any ETA on when this PR is getting merged?

@jspspike
Copy link
Contributor

The adoption of the current implementation of service/environments is on hold for now. There is a new implementation of environments that is being developed this year.

@github-project-automation github-project-automation bot moved this from Backlog to Done in workers-sdk Jan 23, 2023
@huv1k
Copy link

huv1k commented Mar 16, 2023

@jspspike Can we follow somewhere progress? I am really waiting for better information about this one, but can't find anything. Is there anything where I can subscribe to regarding updates? 🤔

@jspspike
Copy link
Contributor

jspspike commented Mar 17, 2023

@huv1k Unfortunately the new implementation of environments is currently being postponed for other features. I might have jumped the gun saying that it would be developed this year. I think information about this feature would be released once development has started through issues and PRs on this repository.
That being said the current implementation of service/environments is deprecated and will not be officially supported

@huv1k
Copy link

huv1k commented Mar 17, 2023

That is sad to hear, hopefully, we will get some solution soon. I don't particularly appreciate that we need to have multiple same workers with different names 🙈

@jspspike
Copy link
Contributor

@huv1k Yes that isn't ideal, if you aren't already using environments in wrangler I would recommend it. You still need to have workers with different names but it helps organize these separate workers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Blocked on other work enhancement New feature or request internal Requires support from the Cloudflare Platform
Projects
None yet
Development

No branches or pull requests

6 participants