You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/12/23 03:53:30 UTC

[GitHub] [apisix] kingluo opened a new pull request, #8557: fix: define destroy() to close protos

kingluo opened a new pull request, #8557:
URL: https://github.com/apache/apisix/pull/8557

   ### Description
   
   <!-- Please include a summary of the change and which issue is fixed. -->
   <!-- Please also include relevant motivation and context. -->
   
   Fixes #8519
   
   ### Checklist
   
   - [x] I have explained the need for this PR and the problem it solves
   - [x] I have explained the changes or the new features added to this PR
   - [x] I have added tests corresponding to this change
   - [x] I have updated the documentation to reflect this change
   - [x] I have verified that this change is backward compatible (If not, please discuss on the [APISIX mailing list](https://github.com/apache/apisix/tree/master#community) first)
   
   <!--
   
   Note
   
   1. Mark the PR as draft until it's ready to be reviewed.
   2. Always add/update tests for any changes unless you have a good reason.
   3. Always update the documentation to reflect the changes made in the PR.
   4. Make a new commit to resolve conversations instead of `push -f`.
   5. To resolve merge conflicts, merge master instead of rebasing.
   6. Use "request review" to notify the reviewer after making changes.
   7. Only a reviewer can mark a conversation as resolved.
   
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] spacewander commented on a diff in pull request #8557: fix: define destroy() to close protos

Posted by GitBox <gi...@apache.org>.
spacewander commented on code in PR #8557:
URL: https://github.com/apache/apisix/pull/8557#discussion_r1057140073


##########
t/plugin/grpc-transcode-reload-bugfix.t:
##########
@@ -0,0 +1,76 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+log_level('warn');
+repeat_each(1);
+no_long_string();
+no_root_location();
+
+add_block_preprocessor(sub {
+    my ($block) = @_;
+
+    if (!$block->request) {
+        $block->set_value("request", "GET /t");
+    }
+
+    my $extra_init_by_lua = <<_EOC_;
+    local core = require("apisix.core")
+    local orig_new = core.config.new
+    close_cnt = 0
+    core.config.new = function(key, opts)
+        local obj, err = orig_new(key, opts)
+        if key == "/protos" then
+            local orig_close = obj.close
+            obj.close = function(...)
+                core.log.warn("call config close")
+                close_cnt = close_cnt + 1
+                return orig_close(...)
+            end
+        end
+        return obj, err
+    end
+_EOC_
+
+    $block->set_value("extra_init_by_lua", $extra_init_by_lua);
+});
+
+run_tests;
+
+__DATA__
+
+=== TEST 1: close protos when grpc-transcode plugin reload
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code = t('/apisix/admin/plugins/reload',
+                ngx.HTTP_PUT)
+            if code >= 300 then
+                ngx.status = code
+                return
+            end
+
+            ngx.sleep(2)
+            if close_cnt ~= 1 then
+                ngx.status = 500
+            end
+        }
+    }
+--- timeout: 3

Review Comment:
   The default timeout is already 3 seconds. We don't need to repeat it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] spacewander merged pull request #8557: fix: define destroy() to close protos

Posted by GitBox <gi...@apache.org>.
spacewander merged PR #8557:
URL: https://github.com/apache/apisix/pull/8557


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] spacewander commented on a diff in pull request #8557: fix: define destroy() to close protos

Posted by GitBox <gi...@apache.org>.
spacewander commented on code in PR #8557:
URL: https://github.com/apache/apisix/pull/8557#discussion_r1056083134


##########
apisix/plugins/grpc-transcode/proto.lua:
##########
@@ -270,5 +270,10 @@ function _M.init()
     end
 end
 
+function _M.destroy()
+    if protos then
+        protos:close()

Review Comment:
   Could we add a test to ensure the `close` is called? For instance, via injecting some code.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org