Varnish 5.1 #2

Closed
opened 2017-06-22 08:45:33 +00:00 by ghost · 7 comments
ghost commented 2017-06-22 08:45:33 +00:00 (Migrated from code.uplex.de)

Can i use this lib in varnish 5.1?

Can i use this lib in varnish 5.1?
geoff commented 2017-06-22 11:54:10 +00:00 (Migrated from code.uplex.de)

Reassigned to @geoff

Reassigned to @geoff
geoff commented 2017-06-22 11:55:44 +00:00 (Migrated from code.uplex.de)

@truonglx-56 I'll take your question as an expression of interest in trying it with 5.1 and will bring it up to date.

@truonglx-56 I'll take your question as an expression of interest in trying it with 5.1 and will bring it up to date.
geoff commented 2017-06-26 00:27:41 +00:00 (Migrated from code.uplex.de)

mentioned in commit eed3ff2e73

mentioned in commit eed3ff2e73d8103fc8bdf240e6c99718d4eb6ddd
geoff commented 2017-06-26 00:47:29 +00:00 (Migrated from code.uplex.de)

@truonglx-56 there is now a branch 5.1 of the VMOD for compatibility with Varnish 5.1. The tagged version v0.5 passes all of the vtc tests in src/tests with versions 5.1.0 through 5.1.2.

The master branch is compatible with the current Varnish master branch (which will become Varnish 6.0 in September). It won't pass the tests with Varnish 5.1.

For completeness: there are now branches (and corresponding tags) for Varnish versions 4.1.0 through 4.1.3, 4.1.4 through 4.1.6, and 5.0.0.

@truonglx-56 there is now a branch 5.1 of the VMOD for compatibility with Varnish 5.1. The tagged version v0.5 passes all of the vtc tests in src/tests with versions 5.1.0 through 5.1.2. The master branch is compatible with the current Varnish master branch (which will become Varnish 6.0 in September). It _won't_ pass the tests with Varnish 5.1. For completeness: there are now branches (and corresponding tags) for Varnish versions 4.1.0 through 4.1.3, 4.1.4 through 4.1.6, and 5.0.0.
geoff commented 2017-06-26 00:47:29 +00:00 (Migrated from code.uplex.de)

Status changed to closed

Status changed to closed
ghost commented 2017-06-26 04:39:47 +00:00 (Migrated from code.uplex.de)

@geoff Thank you so much for helping me!

And i have a question:
I have a shard manager to manage the backend, so my backends list is dynamic, so how do I load the list of backends and allocate them for my purposes?
And is this library the solution to my problem?

@geoff Thank you so much for helping me! And i have a question: I have a shard manager to manage the backend, so my backends list is dynamic, so how do I load the list of backends and allocate them for my purposes? And is this library the solution to my problem?
geoff commented 2017-06-26 09:36:17 +00:00 (Migrated from code.uplex.de)

@truonglx-56 I take it you're referring to the shard director, which has been in standard Varnish since version 5.0?

If so, you add a backend to the director using pretty much the same idiom as with any of the other directors -- use the director's add_backend method, as illustrated in some of the VMOD examples. The difference with the VMOD is that, rather than add a backend identified by its VCL symbol from a standard static configuration, you identify the dynamic backend with the VMOD's by_name function:

truongs_director.add_backend(backend_dyn.by_name("truongs_dynamic_backend"));

The string used in the by_name function ("truongs_dynamic_backend" in the example) is the same one established earlier when the backend was created with the create function.

When you say "load the list of backends": what you can do is execute the create function in the vcl_init subroutine to create your backends, then call the add_backend method for the director to assign them to your director. Calling add_director in vcl_init is what usually has to be done with directors and backends anyway, whether static or dynamic.

You may be touching on a problem that the VMOD has not solved yet. The VMOD makes it possible to add and remove backends at runtime, for example because of containers popping in and out of existence all over the place. This is an alternative to changing a static VCL declaration every time that happens, and then reloading VCL. But with the VMOD, the set of backends and their configurations are only known to the running instance of Varnish -- they're not persisted, so if Varnish is restarted, all of those backend configs are lost.

That's the idea behind the issue I added this morning as issue #3 here in the repo -- add a function to the VMOD that reads backend definitions from a file, so that the VMOD can manage them, and a function that writes the dynamic backend configs to a file, so that they can be read back in after a restart. That would solve the problem, but those functions have to be implemented.

Does that answer your questions?
If you try it, let me know how it goes (we can also be reached at varnish-support@uplex.de).

@truonglx-56 I take it you're referring to the [shard director](https://www.varnish-cache.org/docs/5.0/reference/vmod_directors.generated.html#obj-shard), which has been in standard Varnish since version 5.0? If so, you add a backend to the director using pretty much the same idiom as with any of the other directors -- use the director's ``add_backend`` method, as illustrated in some of the VMOD examples. The difference with the VMOD is that, rather than add a backend identified by its VCL symbol from a standard static configuration, you identify the dynamic backend with the VMOD's ``by_name`` function: ``` truongs_director.add_backend(backend_dyn.by_name("truongs_dynamic_backend")); ``` The string used in the ``by_name`` function (``"truongs_dynamic_backend"`` in the example) is the same one established earlier when the backend was created with the ``create`` function. When you say "load the list of backends": what you can do is execute the ``create`` function in the `` vcl_init`` subroutine to create your backends, then call the ``add_backend`` method for the director to assign them to your director. Calling ``add_director`` in ``vcl_init`` is what usually has to be done with directors and backends anyway, whether static or dynamic. You may be touching on a problem that the VMOD has not solved yet. The VMOD makes it possible to add and remove backends at runtime, for example because of containers popping in and out of existence all over the place. This is an alternative to changing a static VCL declaration every time that happens, and then reloading VCL. But with the VMOD, the set of backends and their configurations are only known to the running instance of Varnish -- they're not persisted, so if Varnish is restarted, all of those backend configs are lost. That's the idea behind the issue I added this morning as issue #3 here in the repo -- add a function to the VMOD that reads backend definitions from a file, so that the VMOD can manage them, and a function that writes the dynamic backend configs to a file, so that they can be read back in after a restart. That would solve the problem, but those functions have to be implemented. Does that answer your questions? If you try it, let me know how it goes (we can also be reached at <varnish-support@uplex.de>).
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
uplex-varnish/libvmod-backend_dyn#2
No description provided.