Skip to content

Commit

Permalink
Removing SplitBrain functionality from GLSB spec, terratests, CRD
Browse files Browse the repository at this point in the history
  • Loading branch information
kuritka committed Feb 11, 2025
1 parent c80fbae commit 6a525ac
Show file tree
Hide file tree
Showing 33 changed files with 7 additions and 123 deletions.
2 changes: 0 additions & 2 deletions api/v1beta1/gslb_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ type Strategy struct {
PrimaryGeoTag string `json:"primaryGeoTag,omitempty"`
// Defines DNS record TTL in seconds
DNSTtlSeconds int `json:"dnsTtlSeconds,omitempty"`
// Split brain TXT record expiration in seconds
SplitBrainThresholdSeconds int `json:"splitBrainThresholdSeconds,omitempty"`
}

// ResourceRef selects a resource defining the GSLB's load balancer and server
Expand Down
1 change: 0 additions & 1 deletion chart/k8gb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ For Kubernetes `< 1.19` use this chart and k8gb in version `0.8.8` or lower.
| k8gb.securityContext.runAsNonRoot | bool | `true` | For more options consult https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#securitycontext-v1-core |
| k8gb.securityContext.runAsUser | int | `1000` | |
| k8gb.serviceMonitor | object | `{"enabled":false}` | enable ServiceMonitor |
| k8gb.splitBrainCheck | bool | `false` | Enable SplitBrain check (Infoblox only) |
| k8gb.validatingAdmissionPolicy | object | `{"enabled":false}` | enable validating admission policies |
| ns1.enabled | bool | `false` | Enable NS1 provider |
| ns1.ignoreSSL | bool | `false` | optional custom NS1 API endpoint for on-prem setups endpoint: https://api.nsone.net/v1/ |
Expand Down
3 changes: 0 additions & 3 deletions chart/k8gb/crd/k8gb.absa.oss_gslbs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,6 @@ spec:
primaryGeoTag:
description: Primary Geo Tag. Valid for failover strategy only
type: string
splitBrainThresholdSeconds:
description: Split brain TXT record expiration in seconds
type: integer
type:
description: Load balancing strategy type:(roundRobin|failover)
type: string
Expand Down
2 changes: 0 additions & 2 deletions chart/k8gb/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ spec:
value: {{ quote .Values.k8gb.log.level }}
- name: NO_COLOR
value: "true"
- name: SPLIT_BRAIN_CHECK
value: {{ quote .Values.k8gb.splitBrainCheck }}
- name: METRICS_ADDRESS
value: {{ .Values.k8gb.metricsAddress }}
{{- if .Values.tracing.enabled }}
Expand Down
3 changes: 0 additions & 3 deletions chart/k8gb/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,6 @@
"coredns": {
"$ref": "#/definitions/k8gbCoreDNS"
},
"splitBrainCheck": {
"type": "boolean"
},
"metricsAddress": {
"type": "string",
"minLength": 1
Expand Down
2 changes: 0 additions & 2 deletions chart/k8gb/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ k8gb:
format: simple # log format (simple,json)
# -- log level (panic,fatal,error,warn,info,debug,trace)
level: info # log level (panic,fatal,error,warn,info,debug,trace)
# -- Enable SplitBrain check (Infoblox only)
splitBrainCheck: false
# -- Metrics server address
metricsAddress: "0.0.0.0:8080"
securityContext:
Expand Down
10 changes: 1 addition & 9 deletions controllers/depresolver/depresolver_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ import (
)

var predefinedStrategy = k8gbv1beta1.Strategy{
DNSTtlSeconds: 30,
SplitBrainThresholdSeconds: 300,
DNSTtlSeconds: 30,
}

// ResolveGslbSpec fills Gslb by spec values. It executes always, when gslb is initialised.
Expand All @@ -44,9 +43,6 @@ func (dr *DependencyResolver) ResolveGslbSpec(ctx context.Context, gslb *k8gbv1b
if gslb.Spec.Strategy.DNSTtlSeconds == 0 {
gslb.Spec.Strategy.DNSTtlSeconds = predefinedStrategy.DNSTtlSeconds
}
if gslb.Spec.Strategy.SplitBrainThresholdSeconds == 0 {
gslb.Spec.Strategy.SplitBrainThresholdSeconds = predefinedStrategy.SplitBrainThresholdSeconds
}
dr.errorSpec = dr.validateSpec(gslb.Spec.Strategy)
if dr.errorSpec == nil {
dr.errorSpec = client.Update(ctx, gslb)
Expand All @@ -61,10 +57,6 @@ func (dr *DependencyResolver) validateSpec(strategy k8gbv1beta1.Strategy) (err e
if err != nil {
return
}
err = field("SplitBrainThresholdSeconds", strategy.SplitBrainThresholdSeconds).isHigherOrEqualToZero().err
if err != nil {
return
}
err = field("Type", strategy.Type).isOneOf(RoundRobinStrategy, GeoStrategy, FailoverStrategy).err
if err != nil {
return
Expand Down
27 changes: 0 additions & 27 deletions controllers/depresolver/depresolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ func TestResolveSpecWithFilledFields(t *testing.T) {
// assert
assert.NoError(t, err)
assert.Equal(t, 35, gslb.Spec.Strategy.DNSTtlSeconds)
assert.Equal(t, 305, gslb.Spec.Strategy.SplitBrainThresholdSeconds)
assert.False(t, len(gslb.Spec.Strategy.Weight) == 0)
assert.Equal(t, 15, gslb.Spec.Strategy.Weight["za"])
assert.Equal(t, 25, gslb.Spec.Strategy.Weight["eu"])
Expand All @@ -113,22 +112,9 @@ func TestResolveSpecWithoutFields(t *testing.T) {
// assert
assert.NoError(t, err)
assert.Equal(t, predefinedStrategy.DNSTtlSeconds, gslb.Spec.Strategy.DNSTtlSeconds)
assert.Equal(t, predefinedStrategy.SplitBrainThresholdSeconds, gslb.Spec.Strategy.SplitBrainThresholdSeconds)
assert.True(t, len(gslb.Spec.Strategy.Weight) == 0)
}

func TestResolveSpecWithZeroSplitBrain(t *testing.T) {
// arrange
cl, gslb := getTestContext("./testdata/filled_omitempty_with_zero_splitbrain.yaml")
resolver := NewDependencyResolver()
// act
err := resolver.ResolveGslbSpec(context.TODO(), gslb, cl)
// assert
assert.NoError(t, err)
assert.Equal(t, 35, gslb.Spec.Strategy.DNSTtlSeconds)
assert.Equal(t, predefinedStrategy.SplitBrainThresholdSeconds, gslb.Spec.Strategy.SplitBrainThresholdSeconds)
}

func TestResolveSpecWithEmptyFields(t *testing.T) {
// arrange
cl, gslb := getTestContext("./testdata/invalid_omitempty_empty.yaml")
Expand All @@ -138,17 +124,6 @@ func TestResolveSpecWithEmptyFields(t *testing.T) {
// assert
assert.NoError(t, err)
assert.Equal(t, predefinedStrategy.DNSTtlSeconds, gslb.Spec.Strategy.DNSTtlSeconds)
assert.Equal(t, predefinedStrategy.SplitBrainThresholdSeconds, gslb.Spec.Strategy.SplitBrainThresholdSeconds)
}

func TestResolveSpecWithNegativeFields(t *testing.T) {
// arrange
cl, gslb := getTestContext("./testdata/invalid_omitempty_negative.yaml")
resolver := NewDependencyResolver()
// act
err := resolver.ResolveGslbSpec(context.TODO(), gslb, cl)
// assert
assert.Error(t, err)
}

func TestResolveSpecWithType(t *testing.T) {
Expand Down Expand Up @@ -226,13 +201,11 @@ func TestSpecRunWhenChanged(t *testing.T) {
resolver := NewDependencyResolver()
// act
err1 := resolver.ResolveGslbSpec(ctx, gslb, cl)
gslb.Spec.Strategy.SplitBrainThresholdSeconds = 0
err2 := resolver.ResolveGslbSpec(ctx, gslb, cl)
// assert
assert.NoError(t, err1)
// err2 would not be empty
assert.NoError(t, err2)
assert.Equal(t, predefinedStrategy.SplitBrainThresholdSeconds, gslb.Spec.Strategy.SplitBrainThresholdSeconds)
assert.Equal(t, 35, gslb.Spec.Strategy.DNSTtlSeconds)
}

Expand Down
1 change: 0 additions & 1 deletion controllers/depresolver/testdata/filled_omitempty.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ spec:
name: http
strategy:
type: roundRobin # Use a round robin load balancing strategy, when deciding which downstream clusters to route clients too
splitBrainThresholdSeconds: 305
dnsTtlSeconds: 35
weight:
us: 60
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,5 @@ spec:
name: http
strategy:
type: roundRobin # Use a round robin load balancing strategy, when deciding which downstream clusters to route clients too
splitBrainThresholdSeconds: 0
dnsTtlSeconds: 35

Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,4 @@ spec:
name: http
strategy:
type: roundRobin # Use a round robin load balancing strategy, when deciding which downstream clusters to route clients too
splitBrainThresholdSeconds:
weight:
39 changes: 0 additions & 39 deletions controllers/depresolver/testdata/invalid_omitempty_negative.yaml

This file was deleted.

11 changes: 5 additions & 6 deletions controllers/gslb_controller_reconciliation.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,13 @@ type GslbReconciler struct {
}

const (
gslbFinalizer = "k8gb.absa.oss/finalizer"
primaryGeoTagAnnotation = "k8gb.io/primary-geotag"
strategyAnnotation = "k8gb.io/strategy"
dnsTTLSecondsAnnotation = "k8gb.io/dns-ttl-seconds"
splitBrainThresholdSecondsAnnotation = "k8gb.io/splitbrain-threshold-seconds"
gslbFinalizer = "k8gb.absa.oss/finalizer"
primaryGeoTagAnnotation = "k8gb.io/primary-geotag"
strategyAnnotation = "k8gb.io/strategy"
dnsTTLSecondsAnnotation = "k8gb.io/dns-ttl-seconds"
)

var k8gbAnnotations = []string{strategyAnnotation, primaryGeoTagAnnotation, dnsTTLSecondsAnnotation, splitBrainThresholdSecondsAnnotation}
var k8gbAnnotations = []string{strategyAnnotation, primaryGeoTagAnnotation, dnsTTLSecondsAnnotation}

var log = logging.Logger()

Expand Down
4 changes: 0 additions & 4 deletions controllers/gslb_controller_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,6 @@ func (r *GslbReconciler) parseStrategy(annotations map[string]string, strategy s
if result.DNSTtlSeconds, err = toInt(annotationKey, annotationValue); err != nil {
return result, err
}
case splitBrainThresholdSecondsAnnotation:
if result.SplitBrainThresholdSeconds, err = toInt(annotationKey, annotationValue); err != nil {
return result, err
}
case primaryGeoTagAnnotation:
result.PrimaryGeoTag = annotationValue
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ spec:
name: http
strategy:
type: roundRobin
splitBrainThresholdSeconds: 300
dnsTtlSeconds: 30
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ spec:
app: ingress-referenced
strategy:
type: roundRobin
splitBrainThresholdSeconds: 300
dnsTtlSeconds: 30
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ spec:
name: http
strategy:
type: roundRobin
splitBrainThresholdSeconds: 300
dnsTtlSeconds: 30
1 change: 0 additions & 1 deletion controllers/refresolver/testdata/gslb_istio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ spec:
app: istio
strategy:
type: roundRobin
splitBrainThresholdSeconds: 300
dnsTtlSeconds: 30
2 changes: 1 addition & 1 deletion controllers/utils/annotations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

var a2 = map[string]string{"k8gb.io/primary-geotag": "eu", "k8gb.io/strategy": "failover"}
var a1 = map[string]string{"field.cattle.io/publicEndpoints": "dummy"}
var annotations = []string{"k8gb.io/primary-geotag", "k8gb.io/strategy", "k8gb.io/dns-ttl-seconds", "k8gb.io/splitbrain-threshold-seconds"}
var annotations = []string{"k8gb.io/primary-geotag", "k8gb.io/strategy", "k8gb.io/dns-ttl-seconds"}

func TestAddNewAnnotations(t *testing.T) {
// arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,4 @@ spec:
app: notfound-istio
strategy:
type: roundRobin
splitBrainThresholdSeconds: 300
dnsTtlSeconds: 30
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,4 @@ spec:
name: http
strategy:
type: roundRobin # Use a round robin load balancing strategy, when deciding which downstream clusters to route clients too
splitBrainThresholdSeconds: 300 # Threshold after which external cluster is filtered out from delegated zone when it doesn't look alive
dnsTtlSeconds: 30 # TTL value for automatically created DNS records
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,4 @@ spec:
app: roundrobin-test-gslb
strategy:
type: roundRobin # Use a round robin load balancing strategy, when deciding which downstream clusters to route clients to
splitBrainThresholdSeconds: 300 # Threshold after which external cluster is filtered out from delegated zone when it doesn't look alive
dnsTtlSeconds: 30 # TTL value for automatically created DNS records
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,4 @@ spec:
app: roundrobin-istio
strategy:
type: roundRobin
splitBrainThresholdSeconds: 300
dnsTtlSeconds: 30
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,4 @@ spec:
app: unhealthy-istio
strategy:
type: roundRobin
splitBrainThresholdSeconds: 300
dnsTtlSeconds: 30
1 change: 0 additions & 1 deletion docs/deploy_cloudflare.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ spec:
strategy:
dnsTtlSeconds: 60 # Minimum for non-Enterprise Cloudflare https://developers.cloudflare.com/dns/manage-dns-records/reference/ttl/
primaryGeoTag: eu
splitBrainThresholdSeconds: 300
type: failover
```

Expand Down
1 change: 0 additions & 1 deletion docs/examples/cloudflare/test-gslb-failover.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,4 @@ spec:
strategy:
dnsTtlSeconds: 60 # Minimum for non-Enterprise Cloudflare https://developers.cloudflare.com/dns/manage-dns-records/reference/ttl/
primaryGeoTag: eu
splitBrainThresholdSeconds: 300
type: failover
1 change: 0 additions & 1 deletion docs/examples/route53/k8gb/gslb-roundrobin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,4 @@ spec:
app: test-gslb
strategy:
type: roundRobin # Use a round robin load balancing strategy, when deciding which downstream clusters to route clients too
splitBrainThresholdSeconds: 300 # Threshold after which external cluster is filtered out from delegated zone when it doesn't look alive
dnsTtlSeconds: 30 # TTL value for automatically created DNS records
2 changes: 0 additions & 2 deletions docs/examples/windowsdns/k8gb/aks1-helm-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ k8gb:
format: json # log format (simple,json)
# -- log level (panic,fatal,error,warn,info,debug,trace)
level: info # log level (panic,fatal,error,warn,info,debug,trace)
# -- Enable SplitBrain check (Infoblox only)
splitBrainCheck: false
# -- Metrics server address
metricsAddress: "0.0.0.0:8080"
securityContext:
Expand Down
2 changes: 0 additions & 2 deletions docs/examples/windowsdns/k8gb/aks2-helm-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ k8gb:
format: json # log format (simple,json)
# -- log level (panic,fatal,error,warn,info,debug,trace)
level: info # log level (panic,fatal,error,warn,info,debug,trace)
# -- Enable SplitBrain check (Infoblox only)
splitBrainCheck: false
# -- Metrics server address
metricsAddress: "0.0.0.0:8080"
securityContext:
Expand Down
1 change: 0 additions & 1 deletion terratest/examples/failover-lifecycle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ spec:
strategy:
type: failover
primaryGeoTag: "eu"
splitBrainThresholdSeconds: 600
dnsTtlSeconds: 5
1 change: 0 additions & 1 deletion terratest/examples/ingress-annotation-failover.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ metadata:
k8gb.io/strategy: failover
k8gb.io/primary-geotag: "eu"
k8gb.io/dns-ttl-seconds: "5"
k8gb.io/splitbrain-threshold-seconds: "600"
name: test-gslb-annotation-failover
spec:
ingressClassName: nginx
Expand Down
1 change: 0 additions & 1 deletion terratest/test/k8gb_ingress_annotation_failover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ func TestK8gbIngressAnnotationFailover(t *testing.T) {
utils.AssertGslbSpec(t, options, "test-gslb-annotation-failover", ".spec.strategy.type", "failover")
utils.AssertGslbSpec(t, options, "test-gslb-annotation-failover", ".spec.strategy.primaryGeoTag", settings.PrimaryGeoTag)
utils.AssertGslbSpec(t, options, "test-gslb-annotation-failover", ".spec.strategy.dnsTtlSeconds", "5")
utils.AssertGslbSpec(t, options, "test-gslb-annotation-failover", ".spec.strategy.splitBrainThresholdSeconds", "600")

t.Run("Broken ingress is not proccessed", func(t *testing.T) {
utils.CreateGslb(t, options, settings, brokenResourcePath)
Expand Down
2 changes: 0 additions & 2 deletions terratest/test/k8gb_lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func TestK8gbRepeatedlyRecreatedFromIngress(t *testing.T) {
const name = "test-gslb-failover-simple"

assertStrategy := func(t *testing.T, options *k8s.KubectlOptions) {
utils.AssertGslbSpec(t, options, name, "spec.strategy.splitBrainThresholdSeconds", "300")
utils.AssertGslbSpec(t, options, name, "spec.strategy.dnsTtlSeconds", "5")
utils.AssertGslbSpec(t, options, name, "spec.strategy.primaryGeoTag", settings.PrimaryGeoTag)
utils.AssertGslbSpec(t, options, name, "spec.strategy.type", "failover")
Expand Down Expand Up @@ -103,7 +102,6 @@ func TestK8gbSpecKeepsStableAfterIngressUpdates(t *testing.T) {
const name = "test-gslb-lifecycle"

assertStrategy := func(t *testing.T, options *k8s.KubectlOptions) {
utils.AssertGslbSpec(t, options, name, "spec.strategy.splitBrainThresholdSeconds", "600")
utils.AssertGslbSpec(t, options, name, "spec.strategy.dnsTtlSeconds", "5")
utils.AssertGslbSpec(t, options, name, "spec.strategy.primaryGeoTag", settings.PrimaryGeoTag)
utils.AssertGslbSpec(t, options, name, "spec.strategy.type", "failover")
Expand Down

0 comments on commit 6a525ac

Please sign in to comment.