Add runner rotate ability to CLI
This change adds a new "generation" field to pools, scalesets and runners. The generation field is inherited by runners from scale sets or pools at the time of creation. The generation field on scalesets and pools is incremented when the pool or scale set is updated in a way that might influence how runners are created (flavor, image, specs, runner groups, etc). Using this new field, we can determine if existing runners have diverged from the settings of the pool/scale set that spawned them. In the CLI we now have a new set of commands available for both pools and scalesets that lists runners, with an optional --outdated flag and a new "rotate" flag that removes all idle runners. Optionally the --outdated flag can be passed to the rotate command to only remove outdated runners. Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
61b4b4cadd
commit
80e042ee88
27 changed files with 648 additions and 93 deletions
|
|
@ -121,6 +121,14 @@ type Pool struct {
|
|||
GitHubRunnerGroup string
|
||||
EnableShell bool
|
||||
|
||||
// Generation holds the numeric generation of the pool. This number
|
||||
// will be incremented, every time certain settings of the pool, which
|
||||
// may influence how runners are created (flavor, specs, image) are changed.
|
||||
// When a runner is created, this generation will be copied to the runners as
|
||||
// well. That way if some settings diverge, we can target those runners
|
||||
// to be recreated.
|
||||
Generation uint64
|
||||
|
||||
RepoID *uuid.UUID `gorm:"index"`
|
||||
Repository Repository `gorm:"foreignKey:RepoID;"`
|
||||
|
||||
|
|
@ -178,6 +186,13 @@ type ScaleSet struct {
|
|||
ExtraSpecs datatypes.JSON
|
||||
EnableShell bool
|
||||
|
||||
// Generation is the scaleset generation at the time of creating this instance.
|
||||
// This field is to track a divergence between when the instance was created
|
||||
// and the settings currently set on a scaleset. We can then use this field to know
|
||||
// if the instance is out of date with the scaleset, allowing us to remove it if we
|
||||
// need to.
|
||||
Generation uint64
|
||||
|
||||
RepoID *uuid.UUID `gorm:"index"`
|
||||
Repository Repository `gorm:"foreignKey:RepoID;"`
|
||||
|
||||
|
|
@ -336,6 +351,12 @@ type Instance struct {
|
|||
GitHubRunnerGroup string
|
||||
AditionalLabels datatypes.JSON
|
||||
Capabilities datatypes.JSON
|
||||
// Generation is the pool generation at the time of creating this instance.
|
||||
// This field is to track a divergence between when the instance was created
|
||||
// and the settings currently set on a pool. We can then use this field to know
|
||||
// if the instance is out of date with the pool, allowing us to remove it if we
|
||||
// need to.
|
||||
Generation uint64
|
||||
|
||||
PoolID *uuid.UUID
|
||||
Pool Pool `gorm:"foreignKey:PoolID"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue