Skip to content
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

Extending DepResolver #173

Merged
merged 1 commit into from
Oct 19, 2020
Merged

Conversation

kuritka
Copy link
Collaborator

@kuritka kuritka commented Oct 15, 2020

related to (#170)

The primary purpose of this improvement is to read all k8gb input at one place, validate it and provide to GSLB in typed, well-formatted way. Depresolver is a single point of k8gb inputs now and fail-fast with proper error message if inputs are incorrect.

Inputs:

spec

  • DNSTtlSeconds
  • SplitBrainThresholdSeconds

config

  • ReconcileRequeueSeconds
  • ClusterGeoTag
  • Route53Enabled
  • ExtClustersGeoTags
  • EdgeDNSType
  • EdgeDNSServer
  • EdgeDNSZone
  • DNSZone
  • Infoblox.Host
  • Infoblox.Version
  • Infoblox.Port
  • Infoblox.Username
  • Infoblox.Password

Validations

We implement the new validator, applying various rules to each input.

Tests

75% coverage checking depresolver works as expected. Extensive coverage allow us to make safe refactoring.
Because I introduced new validation rules, I had to update controller_tests.

EdgeDNSType

Providing new computed property EdgeDNSType telling which configuration(s) loaded to depresolver. This allows us to write conditions like

if config.EdgeDNSType == DNSTypeRoute53 || config.EdgeDNSType == DNSTypeInfo

which overall simplify logic and helps in case we provide EdgeDNS implementations by Factory

depresolver as single point of environment variables names

So we are not using names like "DNS_ZONE" directly. Instead, we use depresolver.DnsZone constant. I replaced variables in controller_tests while the DNS code will not access inputs directly. Will be part of following PR.

TODO:

Will follow in next PR (s). Thanks to validator, we can remove validations from GSLB logic and simplify code. Also, accessing depresolver instead of direct access environment variables will enhance code readability. We can more concentrate on DNS logic rather than checking inputs. It will require changes in the code that I postpone to the next PR, because this PR is too large.

@kuritka kuritka force-pushed the 170-include-envvars-into-depresolver branch 3 times, most recently from e445f99 to cd15b29 Compare October 16, 2020 10:13
controllers/depresolver/depresolver.go Outdated Show resolved Hide resolved
controllers/gslb_controller_test.go Outdated Show resolved Hide resolved
controllers/gslb_controller_test.go Outdated Show resolved Hide resolved
@kuritka kuritka force-pushed the 170-include-envvars-into-depresolver branch 3 times, most recently from febb650 to 4ea7841 Compare October 16, 2020 15:15
related to (#170)

extensions

validations

tests

EdgeDNSType

move environment variables keys into one place - depresolver

TODO:
@kuritka kuritka force-pushed the 170-include-envvars-into-depresolver branch from 4ea7841 to 407140b Compare October 16, 2020 15:18
Copy link
Member

@ytsarev ytsarev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff, thanks!

@kuritka kuritka merged commit b62a798 into master Oct 19, 2020
@kuritka kuritka deleted the 170-include-envvars-into-depresolver branch October 27, 2020 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants