-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change setups the initial hound service. A follow-up is required to generate the repo list from the zuul tenant config. RHOSZUUL-2163 Change-Id: I0e1151c8fa29e44f5f8d263797f4566345a00336
- Loading branch information
1 parent
8b1b41c
commit d07f081
Showing
9 changed files
with
131 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright (C) 2024 Red Hat | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package controllers | ||
|
||
import ( | ||
v1 "github.com/softwarefactory-project/sf-operator/api/v1" | ||
"github.com/softwarefactory-project/sf-operator/controllers/libs/base" | ||
"github.com/softwarefactory-project/sf-operator/controllers/libs/utils" | ||
apiv1 "k8s.io/api/core/v1" | ||
) | ||
|
||
func MkHoundSearchContainer() apiv1.Container { | ||
container := base.MkContainer("hound-search", "quay.io/software-factory/hound:0.5.1-1") | ||
container.Command = []string{"/sf-tooling/hound-search-init.sh"} | ||
container.Ports = []apiv1.ContainerPort{ | ||
base.MkContainerPort(6080, "hound-search"), | ||
} | ||
container.ReadinessProbe = base.MkReadinessHTTPProbe("/", 6080) | ||
container.VolumeMounts = []apiv1.VolumeMount{ | ||
{ | ||
Name: "hound-search-data", | ||
MountPath: "/var/lib/hound", | ||
}, | ||
{ | ||
Name: "zuul-config", | ||
MountPath: "/etc/zuul", | ||
ReadOnly: true, | ||
}, | ||
{ | ||
Name: "tooling-vol", | ||
MountPath: "/sf-tooling", | ||
ReadOnly: true, | ||
}, | ||
} | ||
return container | ||
} | ||
|
||
func (r *SFController) DeployHoundSearch() bool { | ||
svc := base.MkService("hound-search", r.ns, "hound-search", []int32{6080}, "hound-search", r.cr.Spec.ExtraLabels) | ||
r.EnsureService(&svc) | ||
pvc := base.MkPVC("hound-search-data", r.ns, BaseGetStorageConfOrDefault(v1.StorageSpec{}, r.cr.Spec.StorageDefault), apiv1.ReadWriteOnce) | ||
container := MkHoundSearchContainer() | ||
container.Env = []apiv1.EnvVar{ | ||
base.MkEnvVar("CONFIG_REPO_BASE_URL", r.cr.Spec.ConfigRepositoryLocation.BaseURL), | ||
base.MkEnvVar("CONFIG_REPO_NAME", r.cr.Spec.ConfigRepositoryLocation.Name), | ||
} | ||
sts := base.MkStatefulset("hound-search", r.ns, 1, "hound-search", container, pvc, r.cr.Spec.ExtraLabels) | ||
sts.Spec.Template.Spec.Volumes = AppendToolingVolume(sts.Spec.Template.Spec.Volumes) | ||
sts.Spec.Template.Spec.Volumes = append(sts.Spec.Template.Spec.Volumes, base.MkVolumeSecret("zuul-config")) | ||
|
||
annotations := map[string]string{ | ||
"config-repo-info": r.cr.Spec.ConfigRepositoryLocation.BaseURL + r.cr.Spec.ConfigRepositoryLocation.Name, | ||
} | ||
sts.Spec.Template.ObjectMeta.Annotations = annotations | ||
current, stsUpdated := r.ensureStatefulset(sts) | ||
if !utils.MapEquals(¤t.Spec.Template.ObjectMeta.Annotations, &annotations) { | ||
utils.LogI("hound configuration changed, rollout pods ...") | ||
current.Spec = sts.DeepCopy().Spec | ||
r.UpdateR(current) | ||
return false | ||
} | ||
return !stsUpdated | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh | ||
# Copyright (C) 2025 Red Hat | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set -ex | ||
|
||
export HOME=/var/lib/hound | ||
bash /sf-tooling/fetch-config-repo.sh $1 | ||
|
||
# TODO: Render the config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/sh | ||
# Copyright (C) 2025 Red Hat | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set -ex | ||
|
||
export HOME=/var/lib/hound | ||
mkdir -p ${HOME}/data | ||
cd $HOME | ||
if [ ! -z "${CONFIG_REPO_BASE_URL}" ]; then | ||
bash /sf-tooling/hound-search-config.sh | ||
fi | ||
if [ ! -f "/var/lib/hound/config.json" ]; then | ||
cat <<EOF> /var/lib/hound/config.json | ||
{ | ||
"dbpath": "/var/lib/hound/data", | ||
"max-concurrent-indexers": 2, | ||
"repos": {} | ||
} | ||
EOF | ||
fi | ||
exec /go/bin/houndd -conf /var/lib/hound/config.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters