Skip to content

Commit

Permalink
use seconds instead of duration in regreshDnsInterval
Browse files Browse the repository at this point in the history
  • Loading branch information
cottand committed Apr 5, 2024
1 parent bd9cd7e commit 026e931
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
5 changes: 2 additions & 3 deletions api/v1/externalservice_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ limitations under the License.
package v1

import (
"github.com/golang/protobuf/ptypes/duration"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -67,10 +66,10 @@ type ExternalServiceSpec struct {
// Input to the --log-level command line option. See the help text for the available log levels and the default.
EnvoyLogLevel string `json:"envoyArguments,omitempty"`

// Corresponds to Envoy's dns_refresh_rate config field for this cluster.
// Corresponds to Envoy's dns_refresh_rate config field for this cluster, in seconds
// See https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto
// +optional
EnvoyDnsRefreshRate *duration.Duration `json:"envoy_dns_refresh_rate,omitempty"`
EnvoyDnsRefreshRateS int64 `json:"envoy_dns_refresh_rate,omitempty"`

// Corresponds to Envoy's respect_dns_ttl config field for this cluster.
// See https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto
Expand Down
7 changes: 6 additions & 1 deletion api/v1/zz_generated.deepcopy.go

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

6 changes: 3 additions & 3 deletions config/crd/bases/egress.monzo.com_externalservices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ spec:
envoyLogLevel:
description: Input to the --log-level command line option. See the help text for the available log levels and the default.
type: string
envoyDnsRefreshRate:
envoyDnsRefreshRateS:
description: |
Corresponds to Envoy's dns_refresh_rate config field for this cluster.
Corresponds to Envoy's dns_refresh_rate config field for this cluster, in seconds
See https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto
type: string
type: number
envoyRespectDnsTTL:
description: |
Corresponds to Envoy's respect_dns_ttl config field for this cluster.
Expand Down
7 changes: 6 additions & 1 deletion controllers/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package controllers
import (
"context"
"fmt"
"google.golang.org/protobuf/types/known/durationpb"
"hash/fnv"
"strconv"

Expand Down Expand Up @@ -298,6 +299,10 @@ func configmap(es *egressv1.ExternalService) (*corev1.ConfigMap, string, error)

func generateOverrideCluster(name string, spec egressv1.ExternalServiceSpec, port egressv1.ExternalServicePort, protocol envoycorev3.SocketAddress_Protocol) *envoyv3.Cluster {
overrideClusterName := fmt.Sprintf("%v-override", name)
var dnsRefreshRate *duration.Duration
if spec.EnvoyDnsRefreshRateS != 0 {
dnsRefreshRate = &durationpb.Duration{Seconds: spec.EnvoyDnsRefreshRateS}
}
var endpoints []*envoyendpoint.LocalityLbEndpoints

for _, ip := range spec.IpOverride {
Expand Down Expand Up @@ -357,7 +362,7 @@ func generateOverrideCluster(name string, spec egressv1.ExternalServiceSpec, por
Endpoints: endpoints,
},

DnsRefreshRate: spec.EnvoyDnsRefreshRate,
DnsRefreshRate: dnsRefreshRate,
RespectDnsTtl: spec.EnvoyRespectDnsTTL,
}
}
Expand Down

0 comments on commit 026e931

Please sign in to comment.