Skip to content

Commit

Permalink
Add EDNS Persistence Support (#2950)
Browse files Browse the repository at this point in the history
  • Loading branch information
nandakishorepeddi authored Jun 26, 2023
1 parent c088922 commit a021059
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 24 deletions.
12 changes: 8 additions & 4 deletions config/apis/cis/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,14 @@ type ExternalDNS struct {
}

type ExternalDNSSpec struct {
DomainName string `json:"domainName"`
DNSRecordType string `json:"dnsRecordType"`
LoadBalanceMethod string `json:"loadBalanceMethod"`
Pools []DNSPool `json:"pools"`
DomainName string `json:"domainName"`
DNSRecordType string `json:"dnsRecordType"`
LoadBalanceMethod string `json:"loadBalanceMethod"`
PersistenceEnabled bool `json:"persistenceEnabled""`
PersistCidrIPv4 uint8 `json:"persistCidrIpv4"`
PersistCidrIPv6 uint8 `json:"persistCidrIpv6"`
TTLPersistence uint32 `json:"ttlPersistence"`
Pools []DNSPool `json:"pools"`
}

type DNSPool struct {
Expand Down
2 changes: 1 addition & 1 deletion docs/RELEASE-NOTES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Added Functionality
* Ingress
*
* CRD
*
* Support PERSISTENCE capability for service published through EDNS
Bug Fixes
````````````
* Exclude the removal of static ARP entries for Flannel CNI during CIS restart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,21 @@ spec:
loadBalanceMethod:
type: string
pattern: '^[a-z]+[a-z_-]+[a-z]+$'
persistenceEnabled:
type: boolean
persistCidrIpv4:
type: integer
minimum: 0
maximum: 32
persistCidrIpv6:
type: integer
minimum: 0
maximum: 128
ttlPersistence:
type: integer
format: int64
minimum: 0
maximum: 4294967295
pools:
type: array
items:
Expand Down
14 changes: 9 additions & 5 deletions pkg/controller/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -665,11 +665,15 @@ func (agent *Agent) createAS3GTMConfigADC(config ResourceConfigRequest, adc as3A
for domainName, wideIP := range gtmPartitionConfig.WideIPs {

gslbDomain := as3GLSBDomain{
Class: "GSLB_Domain",
DomainName: wideIP.DomainName,
RecordType: wideIP.RecordType,
LBMode: wideIP.LBMethod,
Pools: make([]as3GSLBDomainPool, 0, len(wideIP.Pools)),
Class: "GSLB_Domain",
DomainName: wideIP.DomainName,
RecordType: wideIP.RecordType,
LBMode: wideIP.LBMethod,
PersistenceEnabled: wideIP.PersistenceEnabled,
PersistCidrIPv4: wideIP.PersistCidrIPv4,
PersistCidrIPv6: wideIP.PersistCidrIPv6,
TTLPersistence: wideIP.TTLPersistence,
Pools: make([]as3GSLBDomainPool, 0, len(wideIP.Pools)),
}
for _, pool := range wideIP.Pools {
gslbPool := as3GSLBPool{
Expand Down
4 changes: 4 additions & 0 deletions pkg/controller/resourceConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,10 @@ func copyGTMConfig(cfg WideIP) (rc WideIP) {
rc.DomainName = cfg.DomainName
rc.UID = cfg.UID
rc.LBMethod = cfg.LBMethod
rc.TTLPersistence = cfg.TTLPersistence
rc.PersistCidrIPv4 = cfg.PersistCidrIPv4
rc.PersistCidrIPv6 = cfg.PersistCidrIPv6
rc.PersistenceEnabled = cfg.PersistenceEnabled
rc.RecordType = cfg.RecordType
// Pools
rc.Pools = make([]GSLBPool, len(cfg.Pools))
Expand Down
28 changes: 18 additions & 10 deletions pkg/controller/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,15 @@ type (
}

WideIP struct {
DomainName string `json:"name"`
RecordType string `json:"recordType"`
LBMethod string `json:"LoadBalancingMode"`
Pools []GSLBPool `json:"pools"`
UID string
DomainName string `json:"name"`
RecordType string `json:"recordType"`
LBMethod string `json:"LoadBalancingMode"`
PersistenceEnabled bool `json:"persistenceEnabled"`
PersistCidrIPv4 uint8 `json:"persistCidrIpv4"`
PersistCidrIPv6 uint8 `json:"persistCidrIpv6"`
TTLPersistence uint32 `json:"ttlPersistence"`
Pools []GSLBPool `json:"pools"`
UID string
}

GSLBPool struct {
Expand Down Expand Up @@ -1053,11 +1057,15 @@ type (

// as3GLSBDomain maps to GSLB_Domain in AS3 Resources
as3GLSBDomain struct {
Class string `json:"class"`
DomainName string `json:"domainName"`
RecordType string `json:"resourceRecordType"`
LBMode string `json:"poolLbMode"`
Pools []as3GSLBDomainPool `json:"pools"`
Class string `json:"class"`
DomainName string `json:"domainName"`
RecordType string `json:"resourceRecordType"`
LBMode string `json:"poolLbMode"`
PersistenceEnabled bool `json:"persistenceEnabled"`
PersistCidrIPv4 uint8 `json:"persistCidrIpv4"`
PersistCidrIPv6 uint8 `json:"persistCidrIpv6"`
TTLPersistence uint32 `json:"ttlPersistence"`
Pools []as3GSLBDomainPool `json:"pools"`
}

as3GSLBDomainPool struct {
Expand Down
22 changes: 18 additions & 4 deletions pkg/controller/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2506,10 +2506,24 @@ func (ctlr *Controller) processExternalDNS(edns *cisapiv1.ExternalDNS, isDelete
ctlr.TeemData.Unlock()

wip := WideIP{
DomainName: edns.Spec.DomainName,
RecordType: edns.Spec.DNSRecordType,
LBMethod: edns.Spec.LoadBalanceMethod,
UID: string(edns.UID),
DomainName: edns.Spec.DomainName,
RecordType: edns.Spec.DNSRecordType,
LBMethod: edns.Spec.LoadBalanceMethod,
PersistenceEnabled: edns.Spec.PersistenceEnabled,
PersistCidrIPv4: edns.Spec.PersistCidrIPv4,
PersistCidrIPv6: edns.Spec.PersistCidrIPv6,
TTLPersistence: edns.Spec.TTLPersistence,
UID: string(edns.UID),
}

if edns.Spec.TTLPersistence == 0 {
wip.TTLPersistence = 3600
}
if edns.Spec.PersistCidrIPv6 == 0 {
wip.PersistCidrIPv6 = 128
}
if edns.Spec.PersistCidrIPv4 == 0 {
wip.PersistCidrIPv4 = 32
}

if edns.Spec.DNSRecordType == "" {
Expand Down

0 comments on commit a021059

Please sign in to comment.