Skip to content

Commit 02b5cbe

Browse files
authored
Revert "Enable leader election in ws-manager-mk2 (#18419)" (#18508)
This reverts commit 12d7430.
1 parent 9e5a2be commit 02b5cbe

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

components/ws-manager-mk2/cmd/sample-workspace/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ import (
1010
"log"
1111
"time"
1212

13+
workspacev1 "github.com/gitpod-io/gitpod/ws-manager/api/crd/v1"
1314
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1415
"k8s.io/utils/pointer"
1516
"sigs.k8s.io/yaml"
16-
17-
workspacev1 "github.com/gitpod-io/gitpod/ws-manager/api/crd/v1"
1817
)
1918

2019
func main() {

components/ws-manager-mk2/config/manager/manager.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ spec:
3333
containers:
3434
- command:
3535
- /manager
36+
args:
37+
- --leader-elect
3638
image: controller:latest
3739
name: manager
3840
securityContext:

components/ws-manager-mk2/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,13 @@ func init() {
6868
}
6969

7070
func main() {
71+
var enableLeaderElection bool
7172
var configFN string
7273
var jsonLog bool
7374
var verbose bool
75+
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
76+
"Enable leader election for controller manager. "+
77+
"Enabling this will ensure there is only one active controller manager.")
7478
flag.StringVar(&configFN, "config", "", "Path to the config file")
7579
flag.BoolVar(&jsonLog, "json-log", true, "produce JSON log output on verbose level")
7680
flag.BoolVar(&verbose, "verbose", false, "Enable verbose logging")
@@ -121,7 +125,7 @@ func main() {
121125
MetricsBindAddress: cfg.Prometheus.Addr,
122126
Port: 9443,
123127
HealthProbeBindAddress: cfg.Health.Addr,
124-
LeaderElection: true,
128+
LeaderElection: enableLeaderElection,
125129
LeaderElectionID: "ws-manager-mk2-leader.gitpod.io",
126130
NewCache: cache.MultiNamespacedCacheBuilder([]string{cfg.Manager.Namespace, cfg.Manager.SecretsNamespace}),
127131
})

install/installer/pkg/components/ws-manager-mk2/deployment.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@
55
package wsmanagermk2
66

77
import (
8+
"github.com/gitpod-io/gitpod/installer/pkg/cluster"
9+
"github.com/gitpod-io/gitpod/installer/pkg/common"
10+
wsdaemon "github.com/gitpod-io/gitpod/installer/pkg/components/ws-daemon"
11+
"github.com/gitpod-io/gitpod/installer/pkg/config/v1"
812
appsv1 "k8s.io/api/apps/v1"
913
corev1 "k8s.io/api/core/v1"
1014
"k8s.io/apimachinery/pkg/api/resource"
1115
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1216
"k8s.io/apimachinery/pkg/runtime"
1317
"k8s.io/apimachinery/pkg/util/intstr"
1418
"k8s.io/utils/pointer"
15-
16-
"github.com/gitpod-io/gitpod/installer/pkg/cluster"
17-
"github.com/gitpod-io/gitpod/installer/pkg/common"
18-
wsdaemon "github.com/gitpod-io/gitpod/installer/pkg/components/ws-daemon"
19-
"github.com/gitpod-io/gitpod/installer/pkg/config/v1"
2019
)
2120

2221
func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
@@ -59,6 +58,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
5958
Name: Component,
6059
Args: []string{
6160
"--config", "/config/config.json",
61+
"--leader-elect",
6262
},
6363
Image: ctx.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.WSManagerMk2.Version),
6464
ImagePullPolicy: corev1.PullIfNotPresent,
@@ -176,7 +176,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
176176
},
177177
Spec: appsv1.DeploymentSpec{
178178
Selector: &metav1.LabelSelector{MatchLabels: labels},
179-
Replicas: pointer.Int32(2),
179+
Replicas: common.Replicas(ctx, Component),
180180
Strategy: common.DeploymentStrategy,
181181
Template: corev1.PodTemplateSpec{
182182
ObjectMeta: metav1.ObjectMeta{

0 commit comments

Comments
 (0)