babashka-sci-dev

lispyclouds 2022-01-14T09:23:15.047500Z

@borkdude we dont have a formal ability to send multiple values to the same key in the query params in bb.curl right? we currently pass a map to :query-params. I need this in https://github.com/lispyclouds/contajners/issues/8 . We can send a vector of vectors and that could work as a hack but if you think its a useful thing to add i can add the same functionality as https://github.com/into-docker/unixsocket-http/issues/17

borkdude 2022-01-14T09:27:23.048200Z

@rahul080327 Is the proposal to add a vector as a value for repeated args?

lispyclouds 2022-01-14T09:27:32.048500Z

yes

borkdude 2022-01-14T09:27:42.048800Z

The [[k v] [k v]] approach already works too right?

lispyclouds 2022-01-14T09:28:25.049900Z

yes it would but feels a bit hacky maybe? i was thinking we can keep it like clj-http does?

borkdude 2022-01-14T09:28:39.050300Z

If I were you I would maybe have replied that this is a sufficient way to do it. It's not accidental at all, the implementation treats the associative as a seq of key-vals.

borkdude 2022-01-14T09:29:50.051300Z

Also the [[k v] [k v]] approach allows you to specify the order of params

borkdude 2022-01-14T09:29:59.051700Z

if that is important for whatever reason

lispyclouds 2022-01-14T09:30:24.052300Z

right, the thing was it would need some translation in the contajners layer and its a bit of a mismatch when people read the docker/podman docs and try to send a list like its documented and it fails

borkdude 2022-01-14T09:30:37.052500Z

ah I see

borkdude 2022-01-14T09:30:48.052800Z

is the issue that contaijners uses bb curl?

lispyclouds 2022-01-14T09:31:04.053100Z

yeah thats how i make it run on bb

lispyclouds 2022-01-14T09:31:26.053700Z

i can just do the translation in contajners too

borkdude 2022-01-14T09:31:34.054Z

I think it's sufficient to document the [[k v]] approach and translate it in contaijners

lispyclouds 2022-01-14T09:31:53.054300Z

cool will go ahead with that

borkdude 2022-01-14T09:32:42.055Z

the clj-http also has :multi-param-style which you didn't introduce but just went ahead and treated vectors always as if you would specify multiple keys

borkdude 2022-01-14T09:32:49.055200Z

?

borkdude 2022-01-14T09:33:15.055500Z

oh sorry I misread the clj-http docs

borkdude 2022-01-14T09:33:17.055800Z

;; default style, with :multi-param-style unset
:a [1 2 3] => "a=1&a=2&a=3"
;; with :multi-param-style :array, a repeating param with array suffix
;; (PHP-style):
:a [1 2 3] => "a[]=1&a[]=2&a[]=3"

borkdude 2022-01-14T09:33:54.056100Z

ah well, if this is important, we can support this too I guess :)

borkdude 2022-01-14T09:34:05.056400Z

but [[k v]] should remain working

borkdude 2022-01-14T09:34:53.056800Z

I think you would have to do the translation to support older bb's anyway

lispyclouds 2022-01-14T09:42:25.057400Z

yeah i would do it in a similar way as https://github.com/into-docker/unixsocket-http/pull/18/files

lispyclouds 2022-01-14T09:48:18.058400Z

wouldnt really need a translation in contajners if we implement this in bb.curl. its broken currently if you pass a list 😛

borkdude 2022-01-14T09:50:17.058600Z

:-)

borkdude 2022-01-14T09:51:00.059100Z

what happens then? glancing at the code, it looks like it should work

lispyclouds 2022-01-14T10:18:52.060Z

well then contajners code is fine, its just that the vec that you pass is converted to a str and docker/podman isnt very happy at that

lispyclouds 2022-01-14T10:19:54.060900Z

what it wants is ?containers=id1&containers=id2 and what it sees now is containers=[id1, id2]

borkdude 2022-01-14T10:20:46.061500Z

sure but if you pass [["containers" "id1"] ["containers" "id2"]] to bb curl it should work right

lispyclouds 2022-01-14T10:21:38.062500Z

yep it would. with the translation in contajners. wanted your opinion if its something we'd wanna add in bb.curl too, to keep it like clj-http

borkdude 2022-01-14T10:22:11.063500Z

I already replied above. you will have to do the translation anyway for older bb's

lispyclouds 2022-01-14T10:22:15.063600Z

it worked like this in unixsocket-http too, but xsc added the chnage anyways

borkdude 2022-01-14T10:22:52.064Z

but adding that seems fine. you don't think it's a breaking behavior?

lispyclouds 2022-01-14T10:23:28.064700Z

i was thinking i would just check if v is a coll? in https://github.com/babashka/babashka.curl/blob/master/src/babashka/curl.clj#L102 and do the recur differently?

lispyclouds 2022-01-14T10:23:46.065300Z

instead of just (str v)

borkdude 2022-01-14T10:23:48.065500Z

please answer my question ;)

lispyclouds 2022-01-14T10:25:09.066700Z

would not be breaking right? {:a 42} and {:a [42 43]} should both work if passed to :query-params as well as [[:a 42] [:a 43]]?

borkdude 2022-01-14T10:25:49.067200Z

you're changing the behavior or {:a [42 43]} then right?

lispyclouds 2022-01-14T10:26:16.067800Z

yeah i want it to also accept a coll as the v in the query params map

borkdude 2022-01-14T10:26:31.068400Z

I don't think coll? is the right predicate. it should be sequential? imo

borkdude 2022-01-14T10:26:42.068700Z

a map is also a coll?

lispyclouds 2022-01-14T10:27:07.069200Z

right, brb in a bit!

borkdude 2022-01-14T10:34:39.070600Z

So to summarize: 1. You would have to do the translation in contaijners anyway, since older bb's don't have this new query-params feature 2. Adding it to bb.curl seems fine, but I'm a bit concerned about breaking changes: the behavior of {:a [1 2 3]} is changed, instead of a=[1 2 3] we get a=1&a=2&a=3. Not sure if this is even worth the change. My inclination is to keep the old behavior and just document how to get multiple keys with the same name, but I could be convinced otherwise with strong arguments :)

lispyclouds 2022-01-14T11:12:14.074300Z

yeah my only argument is that this makes it explicit that this key in the query params has multiple values and since bb.curl was inspired by clj-http, we can follow its behavior 😄 but i see the point of the change of behaviour and i can just add it as a translation to contajners

borkdude 2022-01-14T11:13:04.074900Z

> i can just add it as a translation to contajners not only can, you should because of older versions of bb, a point which I've been trying to make several times now ;)

borkdude 2022-01-14T11:14:13.075800Z

imo [["a" "1"] ["a" "2"]] is pretty explicit and resembles the query string even more than {:a [1 2]} but perhaps if you have a lot of those, it becomes annoying.

borkdude 2022-01-14T11:14:58.076500Z

adding too much magic always is going to shoot you in the foot in the long run

lispyclouds 2022-01-14T11:15:17.077Z

yes, i was missing the point of bb being a runtime and not another lib 😅

lispyclouds 2022-01-14T11:16:21.077800Z

> but perhaps if you have a lot of those, it becomes annoying its all gonna be generated in my case so not an issue 😄

lispyclouds 2022-01-14T11:32:09.078100Z

heres the doc PR: https://github.com/babashka/babashka.curl/pull/42

borkdude 2022-01-14T11:33:04.078500Z

perfect, thank you

🙏🏼 1
cap10morgan 2022-01-14T15:39:08.079700Z

hmm, I think I should add the arch into the graalvm dir. think it's not re-downloading b/c it has the amd64 one cached already.

borkdude 2022-01-14T15:40:30.079900Z

@cap10morgan hmm.

bin/gu: cannot execute binary file: Exec format error

Exited with code exit status 126

borkdude 2022-01-14T15:40:39.080300Z

cached, how so?

cap10morgan 2022-01-14T15:40:46.080700Z

in circleci's cache

borkdude 2022-01-14T15:40:54.081Z

oh yes, I see

borkdude 2022-01-14T15:41:04.081300Z

you can add the arch name into the cache key perhaps

👍 1
borkdude 2022-01-14T15:46:08.082Z

I think this time it will work

🤞 1
borkdude 2022-01-14T15:51:30.082400Z

@cap10morgan so perhaps you can smoke-test this on your work env: https://560-325868827-gh.circle-artifacts.com/0/release/pod-babashka-aws-0.1.0-linux-aarch64-static.zip

cap10morgan 2022-01-14T15:51:40.082700Z

can do

borkdude 2022-01-14T15:52:05.083300Z

after that I can release to pod registry. but perhaps we also want to update the cognitect lib, while I'm at it. I'll do that after merge

borkdude 2022-01-14T15:53:29.083600Z

you probably know that you can load a pod by path too right?

cap10morgan 2022-01-14T15:53:41.083900Z

yep, thanks

cap10morgan 2022-01-14T19:55:59.084500Z

ok finally got that arm64 pod build packaged up and deployed w/ my app. getting this error from it: /opt/pods/pod-babashka-aws: error while loading shared libraries: cannot make segment writable for relocation: Cannot allocate memory

cap10morgan 2022-01-14T19:56:16.084800Z

this is an aws lambda function

borkdude 2022-01-14T19:56:21.085Z

wut

borkdude 2022-01-14T19:58:04.085400Z

does that arm64 environment have glibc?

cap10morgan 2022-01-14T20:01:10.085700Z

it's amazon linux 2, so I would think so

borkdude 2022-01-14T20:02:49.086300Z

what do you get for ldd /opt/pods/pod-babashka-aws and are you 100% sure you have the right binary? :)

cap10morgan 2022-01-14T20:04:32.086500Z

pretty sure but I'll double check

borkdude 2022-01-14T20:05:05.086900Z

I see some info here too: https://linux-tips.com/t/cannot-make-segment-writable-for-relocation-error/481/2

borkdude 2022-01-14T20:05:10.087300Z

perhaps some security thing?

cap10morgan 2022-01-14T20:05:16.087400Z

ldd pod-babashka-aws outputs:

linux-vdso.so.1 (0x0000ffffb6ed9000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x0000ffffb093b000)
	libdl.so.2 => /lib64/libdl.so.2 (0x0000ffffb091a000)
	libc.so.6 => /lib64/libc.so.6 (0x0000ffffb0794000)
	/lib/ld-linux-aarch64.so.1 (0x0000ffffb6e9b000)

cap10morgan 2022-01-14T20:06:05.088Z

seems like I can run the pod in an amazonlinux:2 docker container locally, so yeah security thing in the lambda env seems likely

borkdude 2022-01-14T20:07:09.088200Z

perhaps @rahul080327 knows something

borkdude 2022-01-14T20:08:15.088500Z

are you using a custom docker env for lambda?

cap10morgan 2022-01-14T20:10:21.088700Z

don't think so

cap10morgan 2022-01-14T20:10:29.088900Z

it's the provided.al2 runtime

borkdude 2022-01-14T20:11:19.089300Z

perhaps we need to leave out the --static flag altogether and only provide the other one

borkdude 2022-01-14T20:11:34.089500Z

worth a shot

borkdude 2022-01-14T20:12:07.089700Z

So here:

if [ "$BABASHKA_STATIC" = "true" ]; then
    args+=("--static")
    if [ "$BABASHKA_MUSL" = "true" ]; then
        args+=("--libc=musl"
               # see 
               "-H:CCompilerOption=-Wl,-z,stack-size=2097152")
    else
        # see 
        args+=("-H:+StaticExecutableWithDynamicLibC")
    fi
fi

borkdude 2022-01-14T20:12:31.090300Z

move args+=("--static") to the musl part only

cap10morgan 2022-01-14T20:12:39.090500Z

ok

borkdude 2022-01-14T20:15:55.090800Z

if that is the solution, then we need to change it in the bb bash as well

borkdude 2022-01-14T20:24:22.091300Z

it's there

cap10morgan 2022-01-14T20:25:22.091500Z

yep, got it. thanks!

cap10morgan 2022-01-14T20:25:30.091700Z

trying it now

cap10morgan 2022-01-14T20:27:03.091900Z

hmm, same error

borkdude 2022-01-14T20:27:15.092100Z

:'(

cap10morgan 2022-01-14T20:27:25.092400Z

maybe it just needs a higher mem limit

borkdude 2022-01-14T20:27:35.092600Z

what's the memory limit now?

cap10morgan 2022-01-14T20:27:54.092800Z

128MB

borkdude 2022-01-14T20:30:00.093300Z

In the blog post I linked earlier they have some kind of patch tool to work around that security thing

cap10morgan 2022-01-14T20:37:00.093500Z

I think that fixed it

cap10morgan 2022-01-14T20:37:10.093700Z

just needed a higher mem limit

cap10morgan 2022-01-14T20:37:58.094200Z

I'll try the original binary again too

borkdude 2022-01-14T20:38:31.094600Z

ah alright. weird! graalvm images normally don't take a lot of mem

cap10morgan 2022-01-14T20:53:01.094800Z

ok original binary works too

cap10morgan 2022-01-14T20:53:09.095100Z

want me to revert that last change?

borkdude 2022-01-14T20:53:28.095400Z

yeah, let's do that

👍 1
borkdude 2022-01-14T20:55:17.096Z

after that we can merge and then do some updating, etc. I'll roll out the new version tomorrow

👍 1
cap10morgan 2022-01-14T20:56:04.096300Z

it's pushed