Kong/kong-python-pdk

Old instances of plugin not getting deleted

abhisheksharma2805 opened this issue · 2 comments

I have 5 multiple instances of the same plugin (different config) applied to 5 different services. I was just testing the setup by disabling and enabling the plugin. After enabling the plugin again, pdk created a new instance #6 but did not delete the older instance. Is this expected? I see the following error logs when I enable the plugin again. Seems like it is unable to close the instance. This is not affecting anything, the requests are being forwarded correctly but unnecessarily kong is maintaining the older instances which are not being used.

2021/10/27 11:52:34 [info] 30#0: *16 [py:32] INFO - [19:52:34] instance #6 of auth_plugin started, context: ngx.timer
2021/10/27 11:52:34 [info] 30#0: *16 [py:32] ERROR - [19:52:34] rpc: #85 exception: Traceback (most recent call last):, context: ngx.timer
2021/10/27 11:52:34 [info] 30#0: *16 [py:32]   File "/usr/local/lib/python3.6/site-packages/kong_pdk/listener.py", line 68, in handle, context: ngx.timer
2021/10/27 11:52:34 [info] 30#0: *16 [py:32]     ret = getattr(self.ps, cmd_r)(*args), context: ngx.timer
2021/10/27 11:52:34 [info] 30#0: *16 [py:32]   File "/usr/local/lib/python3.6/site-packages/kong_pdk/server.py", line 49, in wrapper, context: ngx.timer
2021/10/27 11:52:34 [info] 30#0: *16 [py:32]     raise(ex), context: ngx.timer
2021/10/27 11:52:34 [info] 30#0: *16 [py:32]   File "/usr/local/lib/python3.6/site-packages/kong_pdk/server.py", line 46, in wrapper, context: ngx.timer
2021/10/27 11:52:34 [info] 30#0: *16 [py:32]     r = fn(*args, **kwargs), context: ngx.timer
2021/10/27 11:52:34 [info] 30#0: *16 [py:32]   File "/usr/local/lib/python3.6/site-packages/kong_pdk/server.py", line 262, in close_instance, context: ngx.timer
2021/10/27 11:52:34 [info] 30#0: *16 [py:32]     "Name": ins['name'],, context: ngx.timer
2021/10/27 11:52:34 [info] 30#0: *16 [py:32] TypeError: 'Instance' object is not subscriptable, context: ngx.timer

@abhisheksharma2805 Just to double check when you mean enablding/disabling the plugin is it something
like attaching it to a Service then delete it? There might be a bug, let me try to reproduce.

@fffonion Yes, setting plugin.enabled = false or even deleting the plugin and re-attaching to the service is throwing this error. Basically I also see that updating any config parameter of the plugin it throws this error.