Files
locust-operator/internal/controller/sync.go
Chris Richardson d03dff5a05
Some checks failed
Lint / Run on Ubuntu (push) Failing after 5m54s
E2E Tests / Run on Ubuntu (push) Failing after 46s
Build images / Run lint test (push) Failing after 6m56s
Build images / Run unit test (push) Failing after 13m3s
Tests / Run on Ubuntu (push) Failing after 9m47s
Build images / Run e2e tests (push) Failing after 17m14s
Build images / Build docker image (push) Has been skipped
comment out
2025-07-02 13:22:50 -04:00

54 lines
1.5 KiB
Go

package controller
import (
"context"
locustCluster "git.lilpenguins.com/crichardson/locust-operator/api/v1alpha1"
"sigs.k8s.io/controller-runtime/pkg/client"
)
func GetLocustCluster(client client.Client, ctx context.Context, namespace string, name string) (
*locustCluster.LocustCluster, error) {
cluster := &locustCluster.LocustCluster{}
err := client.Get(ctx, BuildObjectKey(namespace, name), cluster)
if err != nil {
return nil, err
}
return cluster, nil
}
/*
func (r *LocustClusterReconciler) IsLeaderUp(log logr.Logger, locustCluster *locustCluster.LocustCluster, ctx context.Context) (*unstructured.UnstructuredList, error) {
podkind := &unstructured.UnstructuredList{}
podkind.SetKind("pod")
podkind.SetAPIVersion("v1")
searchLabels := map[string]string{
"job-name": BuildName(locustCluster.GetName(), KeyLeader),
}
err := r.List(ctx, podkind, client.InNamespace(locustCluster.Namespace), client.MatchingLabels(searchLabels))
if err != nil {
log.Info("Leader not found")
return nil, err
}
return podkind, nil
}
func (r *LocustClusterReconciler) CreateUpdateLeader(log logr.Logger, locustCluster *locustCluster.LocustCluster, ctx context.Context,
podList *unstructured.UnstructuredList) error {
var err error
if len(podList.Items) == 0 {
if err = r.CreateLeaderJob(log, locustCluster, ctx); err != nil {
log.Error(err, "Failed to create leader")
return err
}
if err = r.CreateLeaderService(log, locustCluster, ctx); err != nil {
log.Error(err, "Failed to create leader service")
return err
}
}
return err
}
*/