Skip to content

Remove shared load balancer when deactivated #570

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
May 29, 2024
Merged
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
9 changes: 6 additions & 3 deletions pkg/lbmanager/lbmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ func (m *LBManager) ReconcileSvcLBs(ctx context.Context, in *api.Postgres) error
func (m *LBManager) CreateOrUpdateSharedSvcLB(ctx context.Context, in *api.Postgres) error {
if m.options.EnableForceSharedIP != true && in.Spec.DedicatedLoadBalancerIP != nil && *in.Spec.DedicatedLoadBalancerIP != "" {
// TODO logging?
// TODO delete shared LB if neccessary (cleanup after possible config change)?
err := m.DeleteSharedSvcLB(ctx, in)
if err != nil {
m.log.Info("could not delete dedicated loadbalancer", "ns", in.Namespace, "pgID", in.Name)
}
return nil
}

Expand Down Expand Up @@ -173,7 +176,7 @@ func (m *LBManager) DeleteSharedSvcLB(ctx context.Context, in *api.Postgres) err
lb := &corev1.Service{}
lb.Namespace = in.ToPeripheralResourceNamespace()
lb.Name = in.ToSharedSvcLBName()
if err := m.client.Delete(ctx, lb); client.IgnoreNotFound(err) != nil { // todo: remove ignorenotfound
if err := m.client.Delete(ctx, lb); client.IgnoreNotFound(err) != nil {
return err
}
return nil
Expand All @@ -184,7 +187,7 @@ func (m *LBManager) DeleteDedicatedSvcLB(ctx context.Context, in *api.Postgres)
lb := &corev1.Service{}
lb.Namespace = in.ToPeripheralResourceNamespace()
lb.Name = in.ToDedicatedSvcLBName()
if err := m.client.Delete(ctx, lb); client.IgnoreNotFound(err) != nil { // todo: remove ignorenotfound
if err := m.client.Delete(ctx, lb); client.IgnoreNotFound(err) != nil {
return err
}
return nil
Expand Down