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

Refactor tracker to an abstract implementation #850

Merged
merged 5 commits into from
Sep 9, 2021
Merged

Conversation

jcmoraisjr
Copy link
Owner

@jcmoraisjr jcmoraisjr commented Sep 5, 2021

Tracker is used to link kubernetes resources and haproxy entities each other, allowing to list, remove and rebuild all objects related with a configuration change. This is the base of the partial parsing implementation.

The codebase used in v0.11 (starting implementation) up to v0.13 is a lot bigger than necessary, coupled with k8s and haproxy types , and also tricky to extend and test. This update changes the code base to an abstract implementation that can be expanded without the need to write more code, but instead just declaring a new type to every new k8s or haproxy type that need to be tracked.

Both old and new code base are compatible, they only change in the interface declaration, and the new one doesn't have a special behavior when the target doesn't exist - being missing or not, a resource creation or update will trigger the list+remove+recreate in the same way.

Backlog:

  • New tracker implementation
  • Move tracking query input generation to a common place
  • Decouple resource tracking from the HAProxy's hostname type
  • Unit tests covering all possible scenarios
  • Exploratory tests

Tracker is used to link kubernetes resources and haproxy entities each
other, allowing to list, remove and rebuild all objects related with a
configuration change. This is the base of the partial parsing
implementation.

The codebase used in v0.11 (starting implementation) up to v0.13 is
a lot bigger than necessary, coupled with k8s and haproxy types , and
also tricky to extend and test. This update changes the code base to an
abstract implementation that can be expanded without the need to write
more code, but instead just declaring a new type to every new k8s or
haproxy type that need to be tracked.

Both old and new code base are compatible, they only change in the
interface declaration, and the new one doesn't have a special behavior
when the target doesn't exist - being missing or not, a resource
creation or update will trigger the list+remove+recreate in the same
way.
Resource tracking uses arrays of resource namespaces/names as input
parameter. The resource array to string array conversion and
classification is being moved to cache, which already need to iterate
all the resource types. This simplifies the partial ingress converter
and also simplifies the future partial gateway implementation.
The old tracking component had a limited number of Kubernetes resources
and haproxy types that could be combined, leading to a number of
resource types using hostname as an anchor. New implementation allows
any<->any link, and this update starts some sanitization in the ingress
converter.
Kubernetes Services and Endpoints share the same resource name and
behavior from the controller point of view - no matter who changed,
controller will behaves in the same way. Since the first tracking
version Services and Endpoints are managed in the same scope.

This update creates a new scope to the Endpoints resource. This fixes
event logging and also allows to track Services and Endpoints
individually.
Hostname and TCPService from the HAProxy types were being tracked
together due to the missing of distinct tracking types in the old
implementation. This update adds TCPService as a new resource type and
decouple the implementations.
@jcmoraisjr jcmoraisjr merged commit 482ae5b into master Sep 9, 2021
@jcmoraisjr jcmoraisjr deleted the jm-track branch September 9, 2021 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant