mirror of
https://github.com/actions-runner-controller/actions-runner-controller.git
synced 2026-10-18 08:23:45 +02:00
Keep the outdated phase until the runner spec itself changes (#4660)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot App
Copilot Autofix powered by AI
parent
be44bb58cf
commit
dc12c2d417
@@ -39,6 +39,15 @@ func SetupIndexers(mgr ctrl.Manager) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := mgr.GetFieldIndexer().IndexField(
|
||||
context.Background(),
|
||||
&v1alpha1.AutoscalingListener{},
|
||||
autoscalingRunnerSetOwnerKey,
|
||||
autoscalingListenerRunnerSetIndexer,
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := mgr.GetFieldIndexer().IndexField(
|
||||
context.Background(),
|
||||
&v1alpha1.EphemeralRunner{},
|
||||
@@ -51,6 +60,28 @@ func SetupIndexers(mgr ctrl.Manager) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// autoscalingListenerRunnerSetIndexer indexes a listener by the scale set its
|
||||
// spec points back at, so the listeners belonging to a scale set can be found
|
||||
// without deriving their names. The derived name is a hash over the runner group
|
||||
// and the config URL, both of which a user may edit, so a name is only ever the
|
||||
// right lookup for the listener a scale set wants *now* - never for the ones it
|
||||
// already has.
|
||||
func autoscalingListenerRunnerSetIndexer(o client.Object) []string {
|
||||
listener, ok := o.(*v1alpha1.AutoscalingListener)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
return []string{autoscalingRunnerSetOwnerIndexValue(
|
||||
listener.Spec.AutoscalingRunnerSetNamespace,
|
||||
listener.Spec.AutoscalingRunnerSetName,
|
||||
)}
|
||||
}
|
||||
|
||||
func autoscalingRunnerSetOwnerIndexValue(namespace, name string) string {
|
||||
return namespace + "/" + name
|
||||
}
|
||||
|
||||
func newGroupVersionOwnerKindIndexer(ownerKind string, otherOwnerKinds ...string) client.IndexerFunc {
|
||||
owners := append([]string{ownerKind}, otherOwnerKinds...)
|
||||
return func(o client.Object) []string {
|
||||
|
||||
Reference in New Issue
Block a user