lithops-cloud / lithops

A multi-cloud framework for big data analytics and embarrassingly parallel jobs, that provides an universal API for building parallel applications in the cloud ☁️🚀
http://lithops.cloud
Apache License 2.0
317 stars 105 forks source link

AWS Lambda delete runtime should have exact match semantics #1325

Closed tomwhite closed 5 months ago

tomwhite commented 5 months ago

When I ran

lithops runtime delete -b aws_lambda cubed-runtime

it didn't just delete the cubed-runtime image, but anything with cubed-runtime in the name, such as cubed-runtime-dev, cubed-runtime-main, etc. This is clearly a bug.

Previously I reported a bug where it wasn't possible to delete any AWS Lambda runtimes (#1290), where I suggested that runtime name matching should use equality:

runtimes = [tup for tup in runtimes if runtime_name == tup[0]]

But the fix in #1294, did not use equality, but instead used inclusion (in):

runtimes = [tup for tup in runtimes if runtime_name in tup[0]]
JosepSampe commented 5 months ago

If I remember correctly, in the AWS Lambda backend this behavior was intended so that the runtime name passed to the list_runtime() can act like a filter in the way *runtime_name*.

I agree the runtime to be deleted should be only that runtime that exactly matches the name passed to the delete command, but in my opinion the fix should be placed in the delete_runtime() function of the cli, in here:

https://github.com/lithops-cloud/lithops/blob/155b43417192b80e2817776424ccf77a573479b5/lithops/scripts/cli.py#L633-L640

tomwhite commented 5 months ago

Thanks @JosepSampe.

If I remember correctly, in the AWS Lambda backend this behavior was intended so that the runtime name passed to the list_runtime() can act like a filter in the way *runtime_name*.

Other backends don't seem to have wildcard matching in list_runtimes(). For example:

https://github.com/lithops-cloud/lithops/blob/3bc81710e1d94ae52b1ab62652bf51a6e4d8a256/lithops/serverless/backends/gcp_functions/gcp_functions.py#L371

So it would be more consistent to make AWS Lambda do exact matches for list_runtimes() too don't you think?

(Also, the lithops runtime list CLI always shows all runtimes - there's no filtering or wildcard matching going on there either.)

JosepSampe commented 5 months ago

Yes, I agree. Someone was using list_runtimes() programmatically in the AWS Lambda backend in the past (not trough the cli), but for now we can proceed like this