Skip to content
This repository was archived by the owner on Jan 8, 2024. It is now read-only.

Introduce Generations for Mutable Deployments #1298

Merged
merged 30 commits into from
Apr 20, 2021
Merged

Conversation

mitchellh
Copy link
Contributor

Fixes #1235

This introduces the core concept of a "generation." Deployments can optionally advertise a "generation". Two operations that operate on the same generation expect that underlying resources were mutated rather than replaced. This enables plugins such as Nomad jobspec where the job specification updates a deployment in place. This will in the future enable support for raw Kubernetes apply, Helm charts, etc. as well.

The behavior of matching generations in a nutshell:

  • All matching generations share the same deployment URL.
  • When a generation is not new, waypoint up shows output to let the user know the URL will be the same and it was updated in place.
  • When pruning old deployments, deployments with a matching generation with the release are ignored (since they share underlying resources).
  • When releasing a deployment, it is a no-op if the generation matches the currently released deployment (since they should point to the same place).
  • Generation information is available via the API directly on the operation.
  • Generations are UUIDs.

@mitchellh mitchellh added this to the 0.4.0 milestone Apr 8, 2021
@mitchellh mitchellh requested a review from a team April 8, 2021 19:54
@github-actions github-actions bot added the core label Apr 8, 2021
@mitchellh mitchellh mentioned this pull request Apr 8, 2021
@mitchellh mitchellh force-pushed the feature/generations branch from 6f123a3 to be47a50 Compare April 8, 2021 19:59
seq = g.InitialSequence
}

return "v" + strconv.FormatUint(seq, 10)
Copy link
Member

Choose a reason for hiding this comment

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

For mutable deploys with a generation ID, should we append something like latest after v<generation-id> onto the URL to show they will share the same URL for future deploys?

Deployment URL: https://namely-adapting-poodle--v1-latest.waypoint.run

Or maybe even just latest instead of v1 if it never changes?

Copy link
Member

Choose a reason for hiding this comment

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

I could see where a plugin might do in-place deploys but want to increment the generation id, so maybe something like v<gen-id>-latest would work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Generation IDs are long UUIDs though so that'd be a pretty wild URL I think.

Copy link
Member

Choose a reason for hiding this comment

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

Ahh, ok. Yeah maybe not then 😅

Copy link
Member

@briancain briancain left a comment

Choose a reason for hiding this comment

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

I had been using this after testing the nomad jobspec and k8s apply plugins. Looks good to me and works as expected.

Do you plan on opening a PR for the SDK changes before merging these?

Copy link
Contributor

@evanphx evanphx left a comment

Choose a reason for hiding this comment

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

cb80dd8b-4a88-476a-a82b-1e1e71ade13b-8cb64c44-6a64-4f62-9642-460dd37039d6-v1

So clean!

Copy link
Contributor

@krantzinator krantzinator left a comment

Choose a reason for hiding this comment

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

🥳

// Init the metadata
msg, err := op.Init(a)
if err != nil {
return nil, nil, err
}

// Get our hooks
hooks := op.Hooks(a)
Copy link
Contributor

Choose a reason for hiding this comment

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

Did this need to move because of the added functionality to reinit components, or is this a "this should have been here all along" thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah this was necessary for the init change, I updated the comment on init to reflect why hopefully (basically adding the semantics that Init is always called first before any other callback)

@gregone
Copy link
Contributor

gregone commented Apr 20, 2021

Thins looks great! Just a question on this: for easier debugging, should we output the generation UUID in the CLI success message?

plugin/kubernetes-apply: Apply a directory of YAML or JSON files
@mitchellh
Copy link
Contributor Author

Thins looks great! Just a question on this: for easier debugging, should we output the generation UUID in the CLI success message?

The UUIDs aren't currently useful for anything (they don't show up in the UI, you can't look things up with them via the API, etc.) so at the moment I think no. I do think showing the UUIDs in some way for the UI, or some other visual marker or grouping that an operation is all part of the same generation, would be helpful. I think this may require some API changes but happy to do so and discuss that.

@mitchellh mitchellh merged commit 649da7d into main Apr 20, 2021
@mitchellh mitchellh deleted the feature/generations branch April 20, 2021 15:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mutable Deployment Support
5 participants