Comments (5)
But isn't Traefik somewhat responsible for the life cycle of the Plugin? Traefik instantiates the plugin, but there is no way of knowing if plugin instance is no longer needed e.g. if its configuration is removed. Like a method close() on the plugin that is called when the plugin is no longer needed, so that it can cleanup resources allocated (like the mentioned goroutine).
I just don't see how the plugin is suppose to know when it is no longer needed? But maybe there is already another mechanism for this in place?
from traefik.
Hi @simonpahl
There is not much Traefik can do with the problem you are mentionning, it must be handled by the plugin. Plugins are maintained by the community, therefore, I encourage you to reach out directly to the maintainers of the plugin.
I'm closing this issue, don't hesitate to open a new one if you find another bug :)
Thank you
from traefik.
I agree with @simonpahl it is very weird that the middleware API notifies you of new configurations but does not notify of updates/removals, which means it only covers half the life-cycle of middleware management and makes it easy to leak resources :-/
@simonpahl you can use runtime.SetFinalizer() as a workaround, it is a bit hackish but there's no other way around as far as I know.
from traefik.
I did experiments with runtime.SetFinalizer() on the config object, but it never seems to be called. I don't think i can register a finalizer on the plugin itself, because the goroutine would always have a reference of it and thus it would never be GCed.
from traefik.
You can definitely register a finalizer, that's what I had to do in a middleware I wrote to prevent a memory leak upon configuration reload, and I have a log in the finalizer so I know for sure it is being called.
One caveat though: the finalizer callback must be very careful not to reference (directly or indirectly) the object being finalized otherwise the object can´t be garbage collected...
[...]
z.member = f
runtime.SetFinalizer(f, func (o *Foo) {
fmt.Println("ooopsy, now f is directly referenced so it never gets finalized ", f)
fmt.Println("ooopsy, now z is indirectly referenced so it never gets finalized ", z)
})
[...]
I'll just point out that this is very hackish and that in the past there were discussions about runtime.SetFinalizer
deprecation due to the lack of guarantees it offers consumers so in my opinion it is only a hack to work around a broken API. If the next version of Go deprecated it, there would be no way to write a middleware with config-specific elements that doesn´t leak due to missing lifecycle events. The problem would exist with or without yaegi, so I expect the same problem with upcoming webasm API.
from traefik.
Related Issues (20)
- Missing Docker Swarm logo HOT 2
- Support different TLS options for different ClientIP in the same Host HOT 3
- Support ability to set a specific redirect status in RedirectRegex HOT 4
- Traefik does not forward on bridge network when also attached to ipvlan
- Routing syntax in v3.0.0-rc3 is not backwards compatible HOT 1
- httputil.ReverseProxy logs to Go default logger instead of logrus HOT 2
- middleware \"biz4000018p-svc-id4qrkl6hbe1c331oj6e@kubernetescrd\" does not exist HOT 1
- ECS provider misdetecs tasks with attached volumes as missing network interfaces when not in `awsvpc` network mode
- documented usage of excludedIPs with IPAllowList middleware HOT 2
- Add namespace of the ingress/ingressroute in the logs HOT 1
- When Traefik v3.0 does not set the certificate through acme, the log reports an error. HOT 1
- Replacement for lost multiple host definition HOT 2
- zstandard compression HOT 4
- Configurable Span Creation for Reduced Tracing Verbosity HOT 2
- Forward OpenTracing Headers in Plugin HTTP Calls HOT 6
- IPAllowList not working when using ipStrategy.excludedIPs HOT 8
- Traefik 2.11 file provider fail with ReadDirectoryChanges error HOT 2
- Request Entity Too Large - 413 HOT 1
- Traefik api access not logged HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from traefik.