-
Notifications
You must be signed in to change notification settings - Fork 501
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15313 from tlm/teardown-2.0
#15313 With the introduction of sidecar charms and Pebble Juju had no logic to tear down charms. Specifically when a pod/unit inside of a Statefulset for Kubernetes was going away through the receiving of (SIGTERM) it would be given at most 5 seconds to run the charms tear down hooks. This also applied to cases of using `juju scale-application` as this subsequently just trigger a scale within Kubernetes. Obviously in a lot of situations this isn't enough time for a charm to clean up after itself and push the state of the application into one that can be safely shut down. As part of this PR we are introducing the ability to use `juju scale-application` to now take individual units of an application into a "zombie" state by where tear down hooks are run and given an infinite amount of time to execute. Once the desired number of units have entered a zombie/dead state then Juju will command the Kubernetes deployment resource to scale down. To make sure that the zombie pod starts to be de-considered for traffic after tear down the charms readiness probe is set to failing. This PR also fixes storage reattaching for sidecar applications. Depends on juju/description#128 ## Checklist - [x] Code style: imports ordered, good names, simple structure, etc - [x] Comments saying why design decisions were made - [x] Go unit tests, with comments saying what you're testing - [x] [Integration tests](https://github.com/juju/juju/tree/develop/tests), with comments saying what you're testing - [x] [doc.go](https://discourse.charmhub.io/t/readme-in-packages/451) added or updated in changed packages ## QA steps - create a sidecar charm that sleeps on remove hook - bootstrap k8s - `juju deploy mycharm` - `juju scale-application 3` - wait for units to settle - `juju scale-application 0` - wait for units to start running the remove hook - `juju scale-application 3` - observe that the units get removed/pods get removed, then the pods come back and new units come back. - verify storage is reattached to the same unit - verify all hooks have run before the unit and pod are removed Things to also try: - during scale down, delete a pod from the application, it should come back and continue the hooks. - add a sleep in storage-attached or storage-detached hook and ensure the pod can be deleted and comes back during that hook and it reruns successfully. - manually scale the stateful set in kubernetes, notice that the unwanted pods block in the init container. ## Documentation changes N/A ## Bug reference https://bugs.launchpad.net/juju/+bug/1951415 https://bugs.launchpad.net/juju/+bug/1995466 https://bugs.launchpad.net/juju/+bug/2018147
- Loading branch information
Showing
128 changed files
with
4,962 additions
and
2,926 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2023 Canonical Ltd. | ||
// Licensed under the AGPLv3, see LICENCE file for details. | ||
|
||
package lifeflag | ||
|
||
import ( | ||
"github.com/juju/names/v4" | ||
|
||
"github.com/juju/juju/api/base" | ||
"github.com/juju/juju/api/common/lifeflag" | ||
"github.com/juju/juju/core/life" | ||
"github.com/juju/juju/core/watcher" | ||
) | ||
|
||
// Client is the client used for connecting to the life flag facade. | ||
type Client interface { | ||
Life(names.Tag) (life.Value, error) | ||
Watch(names.Tag) (watcher.NotifyWatcher, error) | ||
} | ||
|
||
// NewClient creates a new life flag client. | ||
func NewClient(caller base.APICaller) Client { | ||
return lifeflag.NewClient(caller, "AgentLifeFlag") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.