Skip to content

Revert "Enable leader election in ws-manager-mk2" #18508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 14, 2023
Merged
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
3 changes: 1 addition & 2 deletions components/ws-manager-mk2/cmd/sample-workspace/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ import (
"log"
"time"

workspacev1 "github.com/gitpod-io/gitpod/ws-manager/api/crd/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
"sigs.k8s.io/yaml"

workspacev1 "github.com/gitpod-io/gitpod/ws-manager/api/crd/v1"
)

func main() {
Expand Down
2 changes: 2 additions & 0 deletions components/ws-manager-mk2/config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ spec:
containers:
- command:
- /manager
args:
- --leader-elect
image: controller:latest
name: manager
securityContext:
Expand Down
6 changes: 5 additions & 1 deletion components/ws-manager-mk2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,13 @@ func init() {
}

func main() {
var enableLeaderElection bool
var configFN string
var jsonLog bool
var verbose bool
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")
flag.StringVar(&configFN, "config", "", "Path to the config file")
flag.BoolVar(&jsonLog, "json-log", true, "produce JSON log output on verbose level")
flag.BoolVar(&verbose, "verbose", false, "Enable verbose logging")
Expand Down Expand Up @@ -121,7 +125,7 @@ func main() {
MetricsBindAddress: cfg.Prometheus.Addr,
Port: 9443,
HealthProbeBindAddress: cfg.Health.Addr,
LeaderElection: true,
LeaderElection: enableLeaderElection,
LeaderElectionID: "ws-manager-mk2-leader.gitpod.io",
NewCache: cache.MultiNamespacedCacheBuilder([]string{cfg.Manager.Namespace, cfg.Manager.SecretsNamespace}),
})
Expand Down
12 changes: 6 additions & 6 deletions install/installer/pkg/components/ws-manager-mk2/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@
package wsmanagermk2

import (
"github.com/gitpod-io/gitpod/installer/pkg/cluster"
"github.com/gitpod-io/gitpod/installer/pkg/common"
wsdaemon "github.com/gitpod-io/gitpod/installer/pkg/components/ws-daemon"
"github.com/gitpod-io/gitpod/installer/pkg/config/v1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/utils/pointer"

"github.com/gitpod-io/gitpod/installer/pkg/cluster"
"github.com/gitpod-io/gitpod/installer/pkg/common"
wsdaemon "github.com/gitpod-io/gitpod/installer/pkg/components/ws-daemon"
"github.com/gitpod-io/gitpod/installer/pkg/config/v1"
)

func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
Expand Down Expand Up @@ -59,6 +58,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
Name: Component,
Args: []string{
"--config", "/config/config.json",
"--leader-elect",
},
Image: ctx.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.WSManagerMk2.Version),
ImagePullPolicy: corev1.PullIfNotPresent,
Expand Down Expand Up @@ -176,7 +176,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
},
Spec: appsv1.DeploymentSpec{
Selector: &metav1.LabelSelector{MatchLabels: labels},
Replicas: pointer.Int32(2),
Replicas: common.Replicas(ctx, Component),
Strategy: common.DeploymentStrategy,
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Expand Down