From 883905882997f39181406c06d9036ad50666e7a3 Mon Sep 17 00:00:00 2001 From: Fabien Boucher Date: Thu, 16 Nov 2023 16:04:17 +0000 Subject: [PATCH] nodepool-builer - user Service with a pod-name selector This ensures that the service will proxy traffic to only Pod-0 in case of scale up. The nodepool-builder service is not scalable. Also rename the service name to `nodepool-builder` for clarity. Change-Id: Ia69dbdf843d1115c0ac5753e0a0f634c947fdbe7 --- controllers/nodepool.go | 12 ++++++------ controllers/softwarefactory_controller.go | 13 +++++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/controllers/nodepool.go b/controllers/nodepool.go index b0e5104a..6d5613a9 100644 --- a/controllers/nodepool.go +++ b/controllers/nodepool.go @@ -48,7 +48,7 @@ const ( launcherPortName = "nlwebapp" launcherPort = 8006 buildLogsHttpdPort = 8080 - buildLogsHttpdPortName = "buildlogs-http" + BuildLogsHttpdPortName = "buildlogs-http" NodepoolProvidersSecretsName = "nodepool-providers-secrets" builderIdent = nodepoolIdent + "-builder" ) @@ -510,7 +510,7 @@ func (r *SFController) DeployNodepoolBuilder(statsdExporterVolume apiv1.Volume, }, } buildLogsContainer.Ports = []apiv1.ContainerPort{ - base.MkContainerPort(buildLogsHttpdPort, buildLogsHttpdPortName), + base.MkContainerPort(buildLogsHttpdPort, BuildLogsHttpdPortName), } buildLogsContainer.ReadinessProbe = base.MkReadinessHTTPProbe("/builds", buildLogsHttpdPort) buildLogsContainer.StartupProbe = base.MkStartupHTTPProbe("/builds", buildLogsHttpdPort) @@ -519,9 +519,9 @@ func (r *SFController) DeployNodepoolBuilder(statsdExporterVolume apiv1.Volume, buildLogsContainer, ) - httpdService := base.MkService( - buildLogsHttpdPortName, r.ns, builderIdent, []int32{buildLogsHttpdPort}, buildLogsHttpdPortName) - r.GetOrCreate(&httpdService) + svc := base.MkServicePod( + builderIdent, r.ns, builderIdent+"-0", []int32{buildLogsHttpdPort}, builderIdent) + r.EnsureService(&svc) current := appsv1.StatefulSet{} if r.GetM(builderIdent, ¤t) { @@ -538,7 +538,7 @@ func (r *SFController) DeployNodepoolBuilder(statsdExporterVolume apiv1.Volume, pvcReadiness := r.reconcileExpandPVC(builderIdent+"-"+builderIdent+"-0", r.cr.Spec.Nodepool.Builder.Storage) - routeReady := r.ensureHTTPSRoute(r.cr.Name+"-nodepool-builder", "nodepool", buildLogsHttpdPortName, "/builds", + routeReady := r.ensureHTTPSRoute(r.cr.Name+"-nodepool-builder", "nodepool", builderIdent, "/builds", buildLogsHttpdPort, map[string]string{}, r.cr.Spec.FQDN, r.cr.Spec.LetsEncrypt) var isReady = r.IsStatefulSetReady(¤t) && routeReady && pvcReadiness diff --git a/controllers/softwarefactory_controller.go b/controllers/softwarefactory_controller.go index 379460b0..b7d02ec7 100644 --- a/controllers/softwarefactory_controller.go +++ b/controllers/softwarefactory_controller.go @@ -119,7 +119,20 @@ func (r *SFController) DeployLogserverResource() bool { return logserverController.DeployLogserver().Ready } +// cleanup ensures removal of legacy resources +func (r *SFController) cleanup() { + r.DeleteR(&corev1.Service{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: r.ns, + Name: BuildLogsHttpdPortName, + }, + }) +} + func (r *SFController) Step() sfv1.SoftwareFactoryStatus { + + r.cleanup() + services := map[string]bool{} services["Zuul"] = false