Skip to content

Add debugging setup & re-add release optimizations #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 8, 2023

Conversation

dominikschubert
Copy link
Member

@dominikschubert dominikschubert commented Mar 6, 2023

You can now run:

cd debugging
make build-init

which will build the necessary files under debugging/init/var/rapid/ for mounting into localstack when debugging.

@dominikschubert dominikschubert requested a review from joe4dev March 6, 2023 12:38
@dominikschubert dominikschubert self-assigned this Mar 6, 2023
@dominikschubert dominikschubert requested a review from dfangl March 6, 2023 20:55
Copy link
Member

@joe4dev joe4dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added ARM build support and basic instructions.
It Simplifies development a lot and optimizes the production build 👍

@@ -20,6 +20,8 @@ jobs:
go-version: '~1.18.2'

- name: Build
env:
RELEASE_BUILD_LINKER_FLAGS: "-s -w"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice to optimize the production version 👍

LAMBDA_INIT_DELVE_PORT="${LAMBDA_INIT_DELVE_PORT:-40000}"

# Run init without delve debugger
#exec /var/rapid/init
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it useful to have a non-debug entrypoint at hand.
We could even make this configurable through a custom environment variable in the future.

## Debugging with LocalStack
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some basic docs

docker run --rm -v $$(pwd)/build-delve/:/app/ $(DOCKER_GOLANG_IMAGE) \
bash -c "cd /app && export GOARCH=$(GOARCH) && ./build.sh"

clean clean-init: clean-rapid clean-delve
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added cleanup because unless we encode the architecture in the delve build, this is frequently required when switching architectures.

# On ARM hosts, use: make ARCH=arm64 build-init
# Check host architecture: uname -m
# x86_64 or arm64
ARCH ?= x86_64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added an architecture flag

@joe4dev
Copy link
Member

joe4dev commented Mar 8, 2023

Should we make the RIE log level configurable through LocalStack (LAMBDA_INIT_LOG)?
I guess LAMBDA_INIT_VERBOSE here is intended for that purpose later 🤔

Going forward, we could then use info (or even warn) to reduce default log verbosity.

@dominikschubert
Copy link
Member Author

@joe4dev Yeah that was the intention, but I didn't follow-up on that thought yet since I probably first want to rework the logging a bit in the init. For now it's probably best we just remove it from the config

Copy link
Member

@dfangl dfangl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! My only minor nit is the custom-tests folder, I find the naming confusing, as I do not get the connection between custom-tests and adding a debugger.

build:
docker build -t rapid-debug .
# Golang EOL overview: https://endoflife.date/go
DOCKER_GOLANG_IMAGE ?= golang:1.18.2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to update this at least to 1.18.10, don't you think? We also might want to rebase localstack update localstack to upstream, as they have some dependency updates as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's do this separately though 😁

We'll iterate over a few init releases anyway in the coming days/weeks

@dominikschubert
Copy link
Member Author

LGTM! My only minor nit is the custom-tests folder, I find the naming confusing, as I do not get the connection between custom-tests and adding a debugger.

Yeah that one existed for a while now (also with a quite unclear purpose so far), but we can rename this now 👍

@dominikschubert dominikschubert merged commit 5a4c741 into localstack Mar 8, 2023
@dominikschubert dominikschubert deleted the debug-setup branch March 8, 2023 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants