diff --git a/docs/generated/kuma-cp.md b/docs/generated/kuma-cp.md index ac57f9a81047..7e950bf24d6b 100644 --- a/docs/generated/kuma-cp.md +++ b/docs/generated/kuma-cp.md @@ -507,7 +507,7 @@ multizone: responseBackoff: 0s # ENV: KUMA_MULTIZONE_GLOBAL_KDS_RESPONSE_BACKOFF zone: # Kuma Zone name used to mark the zone dataplane resources - name: "" # ENV: KUMA_MULTIZONE_ZONE_NAME + name: "default" # ENV: KUMA_MULTIZONE_ZONE_NAME # GlobalAddress URL of Global Kuma CP globalAddress: # ENV KUMA_MULTIZONE_ZONE_GLOBAL_ADDRESS kds: diff --git a/docs/generated/raw/kuma-cp.yaml b/docs/generated/raw/kuma-cp.yaml index 7ab3db9179c9..8136a224b665 100644 --- a/docs/generated/raw/kuma-cp.yaml +++ b/docs/generated/raw/kuma-cp.yaml @@ -504,7 +504,7 @@ multizone: responseBackoff: 0s # ENV: KUMA_MULTIZONE_GLOBAL_KDS_RESPONSE_BACKOFF zone: # Kuma Zone name used to mark the zone dataplane resources - name: "" # ENV: KUMA_MULTIZONE_ZONE_NAME + name: "default" # ENV: KUMA_MULTIZONE_ZONE_NAME # GlobalAddress URL of Global Kuma CP globalAddress: # ENV KUMA_MULTIZONE_ZONE_GLOBAL_ADDRESS kds: diff --git a/pkg/defaults/envoy_admin_ca.go b/pkg/defaults/envoy_admin_ca.go index fcf67dded3e9..bdce13e23696 100644 --- a/pkg/defaults/envoy_admin_ca.go +++ b/pkg/defaults/envoy_admin_ca.go @@ -24,17 +24,24 @@ var _ component.Component = &EnvoyAdminCaDefaultComponent{} func (e *EnvoyAdminCaDefaultComponent) Start(stop <-chan struct{}) error { ctx, cancelFn := context.WithCancel(user.Ctx(context.Background(), user.ControlPlane)) + defer cancelFn() + logger := kuma_log.AddFieldsFromCtx(log, ctx, e.Extensions) + errChan := make(chan error) go func() { - <-stop - cancelFn() + errChan <- retry.Do(ctx, retry.WithMaxDuration(10*time.Minute, retry.NewConstant(5*time.Second)), func(ctx context.Context) error { + if err := EnsureEnvoyAdminCaExist(ctx, e.ResManager, e.Extensions); err != nil { + logger.V(1).Info("could not ensure that Envoy Admin CA exists. Retrying.", "err", err) + return retry.RetryableError(err) + } + return nil + }) }() - return retry.Do(ctx, retry.WithMaxDuration(10*time.Minute, retry.NewConstant(5*time.Second)), func(ctx context.Context) error { - if err := EnsureEnvoyAdminCaExist(ctx, e.ResManager, e.Extensions); err != nil { - log.V(1).Info("could not ensure that Envoy Admin CA exists. Retrying.", "err", err) - return retry.RetryableError(err) - } + select { + case <-stop: return nil - }) + case err := <-errChan: + return err + } } func (e EnvoyAdminCaDefaultComponent) NeedLeaderElection() bool { diff --git a/pkg/defaults/zone.go b/pkg/defaults/zone.go index f0ff5c51cefd..3a9b1f937c40 100644 --- a/pkg/defaults/zone.go +++ b/pkg/defaults/zone.go @@ -27,18 +27,24 @@ var _ component.Component = &ZoneDefaultComponent{} func (e *ZoneDefaultComponent) Start(stop <-chan struct{}) error { ctx, cancelFn := context.WithCancel(user.Ctx(context.Background(), user.ControlPlane)) + defer cancelFn() + logger := kuma_log.AddFieldsFromCtx(log, ctx, e.Extensions) + errChan := make(chan error) go func() { - <-stop - cancelFn() + errChan <- retry.Do(ctx, retry.WithMaxDuration(10*time.Minute, retry.NewConstant(5*time.Second)), func(ctx context.Context) error { + if err := EnsureOnlyOneZoneExists(ctx, e.ResManager, e.ZoneName, logger); err != nil { + log.V(1).Info("could not ensure that Zone exists. Retrying.", "err", err) + return retry.RetryableError(err) + } + return nil + }) }() - return retry.Do(ctx, retry.WithMaxDuration(10*time.Minute, retry.NewConstant(5*time.Second)), func(ctx context.Context) error { - logger := kuma_log.AddFieldsFromCtx(log, ctx, e.Extensions) - if err := EnsureOnlyOneZoneExists(ctx, e.ResManager, e.ZoneName, logger); err != nil { - log.V(1).Info("could not ensure that Zone exists. Retrying.", "err", err) - return retry.RetryableError(err) - } + select { + case <-stop: return nil - }) + case err := <-errChan: + return err + } } func (e ZoneDefaultComponent) NeedLeaderElection() bool { diff --git a/test/e2e_env/universal/resilience/leader_election_postgres.go b/test/e2e_env/universal/resilience/leader_election_postgres.go index 8c220c42d1b0..668648d89c27 100644 --- a/test/e2e_env/universal/resilience/leader_election_postgres.go +++ b/test/e2e_env/universal/resilience/leader_election_postgres.go @@ -58,7 +58,7 @@ func LeaderElectionPostgres() { Expect(metrics).To(ContainSubstring(`leader{zone="kuma-leader2"} 0`)) // when CP 1 is killed - _, _, err = zone1.Exec("", "", AppModeCP, "pkill", "-9", "kuma-cp") + _, _, err = zone1.Exec("", "", AppModeCP, "pkill", "kuma-cp") Expect(err).ToNot(HaveOccurred()) // then CP 2 is leader