Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/onsi/ginkgo/v2 v2.27.3
github.com/onsi/gomega v1.38.3
github.com/prometheus/client_golang v1.23.2
github.com/uselagoon/machinery v0.0.35-0.20251124010253-71bebf6d6966
github.com/uselagoon/machinery v0.0.35-0.20260212022131-21706ba1be75
github.com/vshn/k8up v1.99.99
github.com/xhit/go-str2duration/v2 v2.1.0
golang.org/x/text v0.32.0
Expand Down Expand Up @@ -111,10 +111,10 @@ require (
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 // indirect
golang.org/x/mod v0.30.0 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/oauth2 v0.30.0 // indirect
golang.org/x/oauth2 v0.34.0 // indirect
golang.org/x/sync v0.19.0 // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/term v0.37.0 // indirect
golang.org/x/sys v0.40.0 // indirect
golang.org/x/term v0.39.0 // indirect
golang.org/x/time v0.9.0 // indirect
golang.org/x/tools v0.39.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
Expand Down
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1241,10 +1241,10 @@ github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijb
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/uselagoon/machinery v0.0.34 h1:5DsvXEyMeXmzQhjt11YH7+kZJueabovrwKTv0x7jQV8=
github.com/uselagoon/machinery v0.0.34/go.mod h1:G0ujppuNR0BrtAnlmH8xDb9TDfayb4A36aeo0DYg7fQ=
github.com/uselagoon/machinery v0.0.35-0.20251124010253-71bebf6d6966 h1:zfOFGy2aaAn5SnGoOBn/GqmiPzQKY4Crd5A0Y+DXI90=
github.com/uselagoon/machinery v0.0.35-0.20251124010253-71bebf6d6966/go.mod h1:G0ujppuNR0BrtAnlmH8xDb9TDfayb4A36aeo0DYg7fQ=
github.com/uselagoon/machinery v0.0.35-0.20260211024046-9280cba22264 h1:GwvwniG/hln2THN0f0c4QjqC6BsPtYqVp3J6FLhPtJ0=
github.com/uselagoon/machinery v0.0.35-0.20260211024046-9280cba22264/go.mod h1:UVqIxwF/Q9xO3LQMkQhWeuegpuKcsrxmBa4LE52SiWQ=
github.com/uselagoon/machinery v0.0.35-0.20260212022131-21706ba1be75 h1:F/KNUQJ0fs2mfaNKwaKfxOEuDBQhGWrIScXxkAKWKuo=
github.com/uselagoon/machinery v0.0.35-0.20260212022131-21706ba1be75/go.mod h1:UVqIxwF/Q9xO3LQMkQhWeuegpuKcsrxmBa4LE52SiWQ=
github.com/uudashr/gocognit v0.0.0-20190926065955-1655d0de0517/go.mod h1:j44Ayx2KW4+oB6SWMv8KsmHzZrOInQav7D3cQMJ5JUM=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.2.0/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk8LWSxF3s=
Expand Down Expand Up @@ -1533,8 +1533,8 @@ golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ
golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=
golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU=
golang.org/x/oauth2 v0.34.0 h1:hqK/t4AKgbqWkdkcAeI8XLmbK+4m4G5YeQRrmiotGlw=
golang.org/x/oauth2 v0.34.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down Expand Up @@ -1662,16 +1662,16 @@ golang.org/x/sys v0.0.0-20220405210540-1e041c57c461/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU=
golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254=
golang.org/x/term v0.39.0 h1:RclSuaJf32jOqZz74CkPA9qFuVTX7vhLlpfj/IGWlqY=
golang.org/x/term v0.39.0/go.mod h1:yxzUCTP/U+FzoxfdKmLaA0RV1WgE0VY7hXBwKtY/4ww=
golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
83 changes: 52 additions & 31 deletions internal/controllers/v1beta2/buildpodmonitor_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
)

type LagoonServices struct {
Services []schema.EnvironmentService `json:"services"`
Volumes []schema.EnvironmentVolume `json:"volumes"`
}

func (r *BuildMonitorReconciler) handleBuildMonitor(ctx context.Context,
opLog logr.Logger,
req ctrl.Request,
Expand Down Expand Up @@ -285,41 +290,57 @@ func (r *BuildMonitorReconciler) updateDeploymentAndEnvironmentTask(
Cluster: r.LagoonTargetName,
},
}
labelRequirements1, _ := labels.NewRequirement("lagoon.sh/service", selection.NotIn, []string{"faketest"})
listOption := (&client.ListOptions{}).ApplyOptions([]client.ListOption{
client.InNamespace(jobPod.Namespace),
client.MatchingLabelsSelector{
Selector: labels.NewSelector().Add(*labelRequirements1),
},
})
depList := &appsv1.DeploymentList{}
serviceNames := []string{}
services := []schema.EnvironmentService{}
if err := r.APIReader.List(context.TODO(), depList, listOption); err == nil {
// generate the list of services to add or update to the environment
for _, deployment := range depList.Items {
var serviceName, serviceType string
containers := []schema.ServiceContainer{}
if name, ok := deployment.Labels["lagoon.sh/service"]; ok {
serviceName = name
serviceNames = append(serviceNames, serviceName)
for _, container := range deployment.Spec.Template.Spec.Containers {
containers = append(containers, schema.ServiceContainer{Name: container.Name})
lagoonServices := &corev1.ConfigMap{}
if err := r.APIReader.Get(ctx, types.NamespacedName{Namespace: jobPod.Namespace, Name: "lagoon-services"}, lagoonServices); err != nil {
if helpers.IgnoreNotFound(err) != nil {
return err
}
// if configmap doesn't exist, fall back to previous service check behaviour
labelRequirements1, _ := labels.NewRequirement("lagoon.sh/service", selection.NotIn, []string{"faketest"})
listOption := (&client.ListOptions{}).ApplyOptions([]client.ListOption{
client.InNamespace(jobPod.Namespace),
client.MatchingLabelsSelector{
Selector: labels.NewSelector().Add(*labelRequirements1),
},
})
depList := &appsv1.DeploymentList{}
serviceNames := []string{}
services := []schema.EnvironmentService{}
if err := r.APIReader.List(context.TODO(), depList, listOption); err == nil {
// generate the list of services to add or update to the environment
for _, deployment := range depList.Items {
var serviceName, serviceType string
containers := []schema.ServiceContainer{}
if name, ok := deployment.Labels["lagoon.sh/service"]; ok {
serviceName = name
serviceNames = append(serviceNames, serviceName)
for _, container := range deployment.Spec.Template.Spec.Containers {
containers = append(containers, schema.ServiceContainer{Name: container.Name})
}
}
if sType, ok := deployment.Labels["lagoon.sh/service-type"]; ok {
serviceType = sType
}
// probably need to collect dbaas consumers too at some stage
services = append(services, schema.EnvironmentService{
Name: serviceName,
Type: serviceType,
Containers: containers,
Replicas: *deployment.Spec.Replicas,
})
}
if sType, ok := deployment.Labels["lagoon.sh/service-type"]; ok {
serviceType = sType
msg.Meta.Services = serviceNames
msg.Meta.EnvironmentServices = services
}
} else {
// otherwise get the values from configmap
if val, ok := lagoonServices.Data["post-deploy"]; ok {
serviceConfig := LagoonServices{}
err := json.Unmarshal([]byte(val), &serviceConfig)
if err == nil {
msg.Meta.EnvironmentServices = serviceConfig.Services
}
// probably need to collect dbaas consumers too at some stage
services = append(services, schema.EnvironmentService{
Name: serviceName,
Type: serviceType,
Containers: containers,
Replicas: *deployment.Spec.Replicas,
})
}
msg.Meta.Services = serviceNames
msg.Meta.EnvironmentServices = services
}
route, routes, err := helpers.GetLagoonEnvRoutes(ctx, opLog, r.Client, namespace.Name)
// if we aren't being provided the lagoon config, we can skip adding the routes etc
Expand Down
84 changes: 54 additions & 30 deletions internal/messenger/build_messenger.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@ import (
"github.com/uselagoon/machinery/api/schema"
lagooncrd "github.com/uselagoon/remote-controller/api/lagoon/v1beta2"
"github.com/uselagoon/remote-controller/internal/helpers"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/selection"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
)

type LagoonServices struct {
Services []schema.EnvironmentService `json:"services"`
Volumes []schema.EnvironmentVolume `json:"volumes"`
}

// buildStatusLogsToLagoonLogs sends the logs to lagoon-logs message queue, used for general messaging
func (m *Messenger) BuildStatusLogsToLagoonLogs(
ctx context.Context,
Expand Down Expand Up @@ -117,40 +123,58 @@ func (m *Messenger) UpdateDeploymentAndEnvironmentTask(
Cluster: targetName,
},
}
labelRequirements1, _ := labels.NewRequirement("lagoon.sh/service", selection.NotIn, []string{"faketest"})
listOption := (&client.ListOptions{}).ApplyOptions([]client.ListOption{
client.InNamespace(lagoonBuild.Namespace),
client.MatchingLabelsSelector{
Selector: labels.NewSelector().Add(*labelRequirements1),
},
})
podList := &corev1.PodList{}
serviceNames := []string{}
services := []schema.EnvironmentService{}
if err := m.Client.List(context.TODO(), podList, listOption); err == nil {
// generate the list of services to add to the environment
for _, pod := range podList.Items {
var serviceName, serviceType string
containers := []schema.ServiceContainer{}
if name, ok := pod.Labels["lagoon.sh/service"]; ok {
serviceName = name
serviceNames = append(serviceNames, serviceName)
for _, container := range pod.Spec.Containers {
containers = append(containers, schema.ServiceContainer{Name: container.Name})

lagoonServices := &corev1.ConfigMap{}
if err := m.Client.Get(ctx, types.NamespacedName{Namespace: lagoonBuild.Namespace, Name: "lagoon-services"}, lagoonServices); err != nil {
if helpers.IgnoreNotFound(err) != nil {
opLog.Error(err, "configmap %s not found", "lagoon-services")
return
}
// if configmap doesn't exist, fall back to previous service check behaviour
labelRequirements1, _ := labels.NewRequirement("lagoon.sh/service", selection.NotIn, []string{"faketest"})
listOption := (&client.ListOptions{}).ApplyOptions([]client.ListOption{
client.InNamespace(lagoonBuild.Namespace),
client.MatchingLabelsSelector{
Selector: labels.NewSelector().Add(*labelRequirements1),
},
})
depList := &appsv1.DeploymentList{}
serviceNames := []string{}
services := []schema.EnvironmentService{}
if err := m.Client.List(context.TODO(), depList, listOption); err == nil {
// generate the list of services to add or update to the environment
for _, deployment := range depList.Items {
var serviceName, serviceType string
containers := []schema.ServiceContainer{}
if name, ok := deployment.Labels["lagoon.sh/service"]; ok {
serviceName = name
serviceNames = append(serviceNames, serviceName)
for _, container := range deployment.Spec.Template.Spec.Containers {
containers = append(containers, schema.ServiceContainer{Name: container.Name})
}
}
if sType, ok := deployment.Labels["lagoon.sh/service-type"]; ok {
serviceType = sType
}
// probably need to collect dbaas consumers too at some stage
services = append(services, schema.EnvironmentService{
Name: serviceName,
Type: serviceType,
Containers: containers,
})
}
if sType, ok := pod.Labels["lagoon.sh/service-type"]; ok {
serviceType = sType
msg.Meta.Services = serviceNames
msg.Meta.EnvironmentServices = services
}
} else {
// otherwise get the values from configmap
if val, ok := lagoonServices.Data["post-deploy"]; ok {
serviceConfig := LagoonServices{}
err := json.Unmarshal([]byte(val), &serviceConfig)
if err == nil {
msg.Meta.EnvironmentServices = serviceConfig.Services
}
// probably need to collect dbaas consumers too at some stage
services = append(services, schema.EnvironmentService{
Name: serviceName,
Type: serviceType,
Containers: containers,
})
}
msg.Meta.Services = serviceNames
msg.Meta.EnvironmentServices = services
}
if checkLagoonEnv {
route, routes, err := helpers.GetLagoonEnvRoutes(ctx, opLog, m.Client, lagoonBuild.Namespace)
Expand Down
Loading