From users-return-7609-archive-asf-public=cust-asf.ponee.io@trafficserver.apache.org Thu Mar 14 13:04:47 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id CD5C8180630 for ; Thu, 14 Mar 2019 14:04:46 +0100 (CET) Received: (qmail 86780 invoked by uid 500); 14 Mar 2019 13:04:45 -0000 Mailing-List: contact users-help@trafficserver.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@trafficserver.apache.org Delivered-To: mailing list users@trafficserver.apache.org Received: (qmail 86770 invoked by uid 99); 14 Mar 2019 13:04:45 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Mar 2019 13:04:45 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 3E91ECA08B for ; Thu, 14 Mar 2019 13:04:45 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.011 X-Spam-Level: ** X-Spam-Status: No, score=2.011 tagged_above=-999 required=6.31 tests=[DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, T_SPF_PERMERROR=0.01, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=uolet-com.20150623.gappssmtp.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id 7xuSlzESs4O6 for ; Thu, 14 Mar 2019 13:04:42 +0000 (UTC) Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 57E045F1ED for ; Thu, 14 Mar 2019 13:04:42 +0000 (UTC) Received: by mail-lj1-f170.google.com with SMTP id v10so4747363lji.3 for ; Thu, 14 Mar 2019 06:04:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uolet-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=JTUF8BBKwCiovoYuE4kh78VWWt/qLaJYMX7v9kTLqG0=; b=IYYB+/C0PxwkJLHIJJJt6bEIDGcMZ7xPBu/7+Mytfwz7olwnE3NGKN4LTL0cDuO5BP CblRGK8k/1OwMyv8SfqP/3rRSJqRMiRdSkBa0JoWRXr/Tyck9Mem6vclPv7MN5wP0WbD iG1oS3Z/ZQfz3H8/jR1hi3j0qSv15JwYfBapcu6lppN+AY6UmaBrfQMXPuMk30TznSCH qeFMoMU3zDQnsSBHodIofisHH8LvN7QiWQ05WXw2PEj604moQloMhcpkXQcPFq8AU+B9 jWzbl7iGzpwQ0UHr1sievcFYB6G96dmYE8QfGuBu/y8Uc7fcEJlJreM+y2bKgBvjtzKV Pk6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=JTUF8BBKwCiovoYuE4kh78VWWt/qLaJYMX7v9kTLqG0=; b=g755/quK6plDYLy8UlJVjxQU9AkhOZdFcbJGSwUcA+Sz/b6lSHIjFH0YfjQhOGChCG x67Wy4FNExmafaXOWsaBVB5CoD6FFW41y3eX9tLB+BNV7mYd/Xfkn2P2+mRmhz4FuA7T odzZ+mjLYKkv+qgWhwbo8iiew9QHXFINkqoI06LVPMtMBhwuSottR/gI2PRx2H8JErbf wgA2h/0BSyYQVw+6K2ZnE+pTpoiNnjBhPj9pl9bOiDVarueZ9gz+iGhKl0l4+kY/7xqJ tImcNOBolQPbu1SMsVFKnQbe8ByJHY6HVY6Ek0crhn/HWjvxJCUeovDEnKaX3forv64B vnxg== X-Gm-Message-State: APjAAAUDQDqDjYmZ6oeMbOz3maAH7vtEZ2KWoISd/hFyCaaqukrG08GP hLATgTTHTp21nBI5R5iXxHon8E4H2fVS8O2R+r5p7M6v X-Google-Smtp-Source: APXvYqwGELoY5t/S8MlDD0qPN34QjrDBpcQo/hJp2bkJuEzf0XwE/MuSP5rvrnqOYjWuWMqi5K3UZU5DFQ9kwEmblnQ= X-Received: by 2002:a2e:7817:: with SMTP id t23mr1143114ljc.174.1552568681011; Thu, 14 Mar 2019 06:04:41 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Eric Chaves Date: Thu, 14 Mar 2019 10:04:29 -0300 Message-ID: Subject: Re: ts_lua error after using ts.add_package_path To: users@trafficserver.apache.org Content-Type: multipart/alternative; boundary="000000000000b8b0e405840d9045" --000000000000b8b0e405840d9045 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Awesome! I'll take a look into it this weekend. Thanks! Em qua, 13 de mar de 2019 =C3=A0s 14:11, Shu Kit Chan escreveu: > Hopefully this would be the answer to your problem - > https://github.com/apache/trafficserver/issues/5158 > > Thanks. > > Kit > > On Mon, Mar 11, 2019 at 9:54 AM Eric Chaves wrote: > > > > Hi Shun, thanks for helping me out in this out-of-topic situation. I > spent the weekend reading about this error on the internet (starting with > the links you shared) trying to figure out what I could be doing wrong bu= t > with my limited knowledge on lua I wasn't able to figure it out. > > > > The comments on luasocket issue's implies that this error could be due > to a misconfigured build whose symbols were not being linked/exported > properly, so I tried to check the symbol resolution for tslua.so using th= e > command line 'nm -gC libexec/trafficserver/tslua.so | grep lua_' using > different build configs (with only luajit installed/not lua, without > luajit, with luajit path explicitly set, etc). In all builds the results > were the same: every lua_* symbol is marked as Undefined (39 symbols in > total). > > > > I'm not sure if this means something since the tslua plugin does execut= e > lua properly, but this was as far as I got. > > > > I also tried to install luasocket from it's source code but it failed > because it didn't find some lua headers (ie lua.h, etc) which enforces th= at > I'm somehow breaking the build but I can't point my finger on anything. A= s > far as I can tell I'm following the steps present both at the docs and at > trafficserve's confluence. I've also based my self on some 3rd part > dockerfiles at github. > > > > If have some spare time could you please take a look on my Dockerfile ( > https://github.com/ericchaves/ats-lua-playground/blob/master/trafficserve= r.dockerfile) > so see if you spot any mistakes that I may be doing (maybe I'm missing so= me > required CC flag)? Or if you could share your build steps (even if it's n= ot > dockerbased) so I can compare with mine. > > > > If you can't help me any further for any reason, that's ok either. You > have being of great support no matter what. =3D) > > > > Regards, > > > > Em sex, 8 de mar de 2019 =C3=A0s 13:15, Shu Kit Chan > escreveu: > >> > >> I am not sure what's wrong with your setup. i have used luasocket > >> before with no problem. perhaps this will shed some light ? > >> > >> https://github.com/diegonehab/luasocket/issues/158 > >> https://github.com/diegonehab/luasocket/issues/87 > >> > >> Thanks. > >> > >> Kit > >> > >> On Thu, Mar 7, 2019 at 6:59 AM Eric Chaves wrote: > >> > > >> > Nice!, It solved this error but now I got the error "ERROR: [ts_lua= ] > lua_pcall failed: error loading module 'socket.core' from file > '/opt/ats/lua_modules/lib/lua/5.1/socket/core.so': > /opt/ats/lua_modules/lib/lua/5.1/socket/core.so: undefined symbol: > lua_gettop. > >> > > >> > Everything was built using lua 5.1. Any clues why I could be getting > the undefined symbol? Could I be missing some dependency? > >> > > >> > Em qua, 6 de mar de 2019 =C3=A0s 18:37, Shu Kit Chan > escreveu: > >> >> > >> >> Try not to call "add_package_path" / "add_package_cpath" inside the > >> >> lua module . > >> >> Call them in the same lua file containing the do_remap() function a= nd > >> >> see if your problem is solved. > >> >> > >> >> Kit > >> >> > >> >> On Wed, Mar 6, 2019 at 1:23 PM Eric Chaves wrote: > >> >> > > >> >> > Hi folks, > >> >> > > >> >> > This may be a little off-topic. Not sure if questions regarding > lua plugins/lua scripts should be asked here in the list. If so forgive m= e > and please point me the proper place to ask. > >> >> > > >> >> > I'm trying to learn TS lua script's. At first I just followed the > sample code for reverse host header presented in the lua_plugin docs by > writing a module named my_module.lua required inside a do_remap() with th= e > following content: > >> >> > > >> >> > local my_module =3D {} > >> >> > function my_module.send_response() > >> >> > ts.debug('executing my_module.send_response') > >> >> > ts.client_response.header['Rhost'] =3D ts.ctx['rhost'] > >> >> > return 0 > >> >> > end > >> >> > return my_module > >> >> > > >> >> > This works fine and after that I tried to add some code to connec= t > into a local redis instance using libs installed by luarocks (eg.: luaroc= ks > install --tree /opt/ats/lua_modules luasocket) > >> >> > > >> >> > I found some scripts at github that uses the ts.add_package_path > to include the new modules and based on them I added those two lines at t= he > top of my_module.lua: > >> >> > > >> >> > > ts.add_package_path('/opt/ats/lua_modules/share/lua/5.1/?.lua;/opt/ats/lu= a_modules/share/lua/5.1/?/init.lua') > >> >> > ts.add_package_cpath('/opt/ats/lua_modules/share/lua/5.1/?.so') > >> >> > > >> >> > By doing so, even without actually requiring any new module (ie n= o > other changes in my_module logic) when my do_remap tries require my_modul= e, > I got an error: ERROR: [ts_lua] lua_pcall failed: > /opt/ats/lua-plugins/my_module.lua:6: can't get the instance conf > >> >> > > >> >> > So it's clear that I'm breaking something using the > ts.add_package_path. I've also tried to mangle with package.path variable > with the same outcome. > >> >> > > >> >> > What am I doing wrong and how should I do to add those new > packages? > >> >> > > >> >> > Cheers, > >> >> > > >> >> > Eric > >> >> > > --000000000000b8b0e405840d9045 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Awesome! I'll take a look into it this weekend.
Thanks!

Em qua, 13 de mar de 2019 =C3=A0s 14:11, Shu Kit = Chan <chanshukit@gmail.com&g= t; escreveu:
Hop= efully this would be the answer to your problem -
https://github.com/apache/trafficserver/issues/51= 58

Thanks.

Kit

On Mon, Mar 11, 2019 at 9:54 AM Eric Chaves <eric@uolet.com> wrote:
>
> Hi Shun, thanks for helping me out in this out-of-topic situation. I s= pent the weekend reading about this error on the internet (starting with th= e links you shared) trying to figure out what I could be doing wrong but wi= th my limited knowledge on lua I wasn't able to figure it out.
>
> The comments on luasocket issue's implies that this error could be= due to a misconfigured build whose symbols were not being linked/exported = properly, so I tried to check the symbol resolution for tslua.so using the = command line 'nm -gC libexec/trafficserver/tslua.so | grep lua_' us= ing different build configs (with only luajit installed/not lua, without lu= ajit, with luajit path explicitly set, etc). In all builds the results were= the same: every lua_* symbol is marked as Undefined (39 symbols in total).=
>
> I'm not sure if this means something since the tslua plugin does e= xecute lua properly, but this was as far as I got.
>
> I also tried to install luasocket from it's source code but it fai= led because it didn't find some lua headers (ie lua.h, etc) which enfor= ces that I'm somehow breaking the build but I can't point my finger= on anything. As far as I can tell I'm following the steps present both= at the docs and at trafficserve's confluence. I've also based my s= elf on some 3rd part dockerfiles at github.
>
> If have some spare time could you please take a look on my Dockerfile = (https://github= .com/ericchaves/ats-lua-playground/blob/master/trafficserver.dockerfile= ) so see if you spot any mistakes that I may be doing (maybe I'm missin= g some required CC flag)? Or if you could share your build steps (even if i= t's not dockerbased) so I can compare with mine.
>
> If you can't help me any further for any reason, that's ok eit= her. You have being of great support no matter what. =3D)
>
> Regards,
>
> Em sex, 8 de mar de 2019 =C3=A0s 13:15, Shu Kit Chan <chanshukit@gmail.com> e= screveu:
>>
>> I am not sure what's wrong with your setup.=C2=A0 i have used = luasocket
>> before with no problem. perhaps this will shed some light ?
>>
>> https://github.com/diegonehab/luasocket/i= ssues/158
>> https://github.com/diegonehab/luasocket/i= ssues/87
>>
>> Thanks.
>>
>> Kit
>>
>> On Thu, Mar 7, 2019 at 6:59 AM Eric Chaves <eric@uolet.com> wrote:
>> >
>> > Nice!, It solved this error but=C2=A0 now I got the error &qu= ot;ERROR: [ts_lua] lua_pcall failed: error loading module 'socket.core&= #39; from file '/opt/ats/lua_modules/lib/lua/5.1/socket/core.so': /= opt/ats/lua_modules/lib/lua/5.1/socket/core.so: undefined symbol: lua_getto= p.
>> >
>> > Everything was built using lua 5.1. Any clues why I could be = getting the undefined symbol? Could I be missing some dependency?
>> >
>> > Em qua, 6 de mar de 2019 =C3=A0s 18:37, Shu Kit Chan <chanshukit@gmail.com<= /a>> escreveu:
>> >>
>> >> Try not to call "add_package_path" / "add_= package_cpath" inside the
>> >> lua module .
>> >> Call them in the same lua file containing the do_remap() = function and
>> >> see if your problem is solved.
>> >>
>> >> Kit
>> >>
>> >> On Wed, Mar 6, 2019 at 1:23 PM Eric Chaves <
eric@uolet.com> wrote:
>> >> >
>> >> > Hi folks,
>> >> >
>> >> > This may be a little off-topic. Not sure if question= s regarding lua plugins/lua scripts should be asked here in the list. If so= forgive me and please point me the proper place to ask.
>> >> >
>> >> > I'm trying to learn TS lua script's. At firs= t I just followed the sample code for reverse host header presented in the = lua_plugin docs by writing a module named my_module.lua required inside a d= o_remap() with the following content:
>> >> >
>> >> > local my_module =3D {}
>> >> > function my_module.send_response()
>> >> >=C2=A0 =C2=A0ts.debug('executing my_module.send_r= esponse')
>> >> >=C2=A0 =C2=A0ts.client_response.header['Rhost'= ;] =3D ts.ctx['rhost']
>> >> >=C2=A0 =C2=A0return 0
>> >> > end
>> >> > return my_module
>> >> >
>> >> > This works fine and after that I tried to add some c= ode to connect into a local redis instance using libs installed by luarocks= (eg.: luarocks install --tree /opt/ats/lua_modules luasocket)
>> >> >
>> >> >=C2=A0 I found some scripts at github that uses the t= s.add_package_path to include the new modules and based on them I added tho= se two lines at the top of my_module.lua:
>> >> >
>> >> > ts.add_package_path('/opt/ats/lua_modules/share/= lua/5.1/?.lua;/opt/ats/lua_modules/share/lua/5.1/?/init.lua')
>> >> > ts.add_package_cpath('/opt/ats/lua_modules/share= /lua/5.1/?.so')
>> >> >
>> >> > By doing so, even without actually requiring any new= module (ie no other changes in my_module logic) when my do_remap tries req= uire my_module, I got an error: ERROR: [ts_lua] lua_pcall failed: /opt/ats/= lua-plugins/my_module.lua:6: can't get the instance conf
>> >> >
>> >> > So it's clear that I'm breaking something us= ing the ts.add_package_path. I've also tried to mangle with package.pat= h variable with the same outcome.
>> >> >
>> >> > What am I doing wrong and how should I do to add tho= se new packages?
>> >> >
>> >> > Cheers,
>> >> >
>> >> > Eric
>> >> >
--000000000000b8b0e405840d9045--