Skip to content

Commit

Permalink
Merge "zuul-executor - make it optional"
Browse files Browse the repository at this point in the history
  • Loading branch information
Microzuul CI authored and Gerrit Code Review committed Feb 12, 2024
2 parents abf81fd + c9d0b08 commit f329bc9
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 7 deletions.
4 changes: 4 additions & 0 deletions api/v1/softwarefactory_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ type ZuulExecutorSpec struct {
// Changing this value will restart the service.
// +optional
LogLevel LogLevel `json:"logLevel,omitempty"`
// +kubebuilder:default:=true
// +optional
// If set to false, the zuul-executor deployment won't be applied
Enabled *bool `json:"enabled,omitempty"`
}

type ZuulWebSpec struct {
Expand Down
5 changes: 5 additions & 0 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,11 @@ spec:
executor:
description: Configuration of the executor microservices
properties:
enabled:
default: true
description: If set to false, the zuul-executor deployment
won't be applied
type: boolean
logLevel:
description: 'Specify the Log Level of the zuul-executor service.
Valid values are: "INFO" (default), "WARN", "DEBUG". Changing
Expand Down
11 changes: 9 additions & 2 deletions controllers/softwarefactory_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,20 @@ func (r *SFController) Step() sfv1.SoftwareFactoryStatus {
monitoredPorts = append(
monitoredPorts,
sfmonitoring.GetTruncatedPortName("zuul-scheduler", sfmonitoring.NodeExporterPortNameSuffix),
sfmonitoring.GetTruncatedPortName("zuul-executor", sfmonitoring.NodeExporterPortNameSuffix),
sfmonitoring.GetTruncatedPortName("zuul-merger", sfmonitoring.NodeExporterPortNameSuffix),
sfmonitoring.GetTruncatedPortName("zuul-web", sfmonitoring.NodeExporterPortNameSuffix),
ZuulPrometheusPortName,
ZuulStatsdExporterPortName,
)
selectorRunList = append(selectorRunList, "zuul-scheduler", "zuul-executor", "zuul-merger", "zuul-web")
selectorRunList = append(selectorRunList, "zuul-scheduler", "zuul-merger", "zuul-web")

if r.IsExecutorEnabled() {
monitoredPorts = append(
monitoredPorts,
sfmonitoring.GetTruncatedPortName("zuul-executor", sfmonitoring.NodeExporterPortNameSuffix))
selectorRunList = append(selectorRunList, "zuul-executor")
}

services["Config"] = r.SetupConfigJob()
if services["Config"] {
conds.RefreshCondition(&r.cr.Status.Conditions, "ConfigReady", metav1.ConditionTrue, "Ready", "Config is ready")
Expand Down
21 changes: 19 additions & 2 deletions controllers/zuul.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strconv"
"strings"

"golang.org/x/exp/maps"
ini "gopkg.in/ini.v1"
appsv1 "k8s.io/api/apps/v1"
apiv1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -694,16 +695,32 @@ func (r *SFController) EnsureZuulComponentsFrontServices() {

}

func (r *SFController) IsExecutorEnabled() bool {
if r.cr.Spec.Zuul.Executor.Enabled != nil && !*r.cr.Spec.Zuul.Executor.Enabled {
return false
} else {
return true
}
}

func (r *SFController) EnsureZuulComponents(cfg *ini.File) bool {

zuulServices := map[string]bool{}
r.setZuulLoggingfile()
zuulServices["scheduler"] = r.EnsureZuulScheduler(cfg)
zuulServices["executor"] = r.EnsureZuulExecutor(cfg)
if r.IsExecutorEnabled() {
zuulServices["executor"] = r.EnsureZuulExecutor(cfg)
}
zuulServices["web"] = r.EnsureZuulWeb(cfg)
zuulServices["merger"] = r.EnsureZuulMerger(cfg)

return zuulServices["scheduler"] && zuulServices["executor"] && zuulServices["web"] && zuulServices["merger"]
for _, ready := range maps.Values(zuulServices) {
if !ready {
return false
}
}

return true
}

// create default alerts
Expand Down
1 change: 1 addition & 0 deletions doc/reference/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ _Appears in:_
| --- | --- | --- |
| `storage` _[StorageSpec](#storagespec)_ | Storage-related settings | -|
| `logLevel` _[LogLevel](#loglevel)_ | Specify the Log Level of the zuul-executor service. Valid values are: "INFO" (default), "WARN", "DEBUG". Changing this value will restart the service. | INFO|
| `enabled` _boolean_ | If set to false, the zuul-executor deployment won't be applied | {true}|


#### ZuulMergerSpec
Expand Down
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ require (
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.10.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3
golang.org/x/net v0.10.0 // indirect
golang.org/x/oauth2 v0.6.0 // indirect
golang.org/x/sys v0.8.0 // indirect
Expand All @@ -103,6 +104,4 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
)

replace (
github.com/softwarefactory-project/sf-operator/cli/cmd => ./cli/cmd
)
replace github.com/softwarefactory-project/sf-operator/cli/cmd => ./cli/cmd
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 h1:/RIbNt/Zr7rVhIkQhooTxCxFcdWLGIKnZA4IXNFSrvo=
golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
Expand Down

0 comments on commit f329bc9

Please sign in to comment.