Skip to content
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

testing debug config value #1058

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e057a84
testing debug config value
Ian-Nara Oct 4, 2024
a70141b
testing debug config value
Ian-Nara Oct 4, 2024
ec27533
[CI Pipeline] Released Snapshot version: 5.40.49-alpha-24-SNAPSHOT
Oct 4, 2024
b24fbf8
don't use logback conf in debug mode
Ian-Nara Oct 4, 2024
3f1eb09
Merge remote-tracking branch 'origin/ian-UID2-4235-enclave-debug-thro…
Ian-Nara Oct 4, 2024
59d9dd7
add more log information
Ian-Nara Oct 4, 2024
b4aa9c4
[CI Pipeline] Released Snapshot version: 5.40.50-alpha-25-SNAPSHOT
Oct 4, 2024
da0e058
fix if statement
Ian-Nara Oct 4, 2024
7589983
Merge remote-tracking branch 'origin/ian-UID2-4235-enclave-debug-thro…
Ian-Nara Oct 4, 2024
7ec499f
[CI Pipeline] Released Snapshot version: 5.40.51-alpha-27-SNAPSHOT
Oct 4, 2024
3a377d5
add debug logback conf
Ian-Nara Oct 7, 2024
ea6d9fd
Merge remote-tracking branch 'origin/ian-UID2-4235-enclave-debug-thro…
Ian-Nara Oct 7, 2024
ba116b3
[CI Pipeline] Released Snapshot version: 5.40.52-alpha-28-SNAPSHOT
Oct 7, 2024
4803b7f
operator debug
Ian-Nara Oct 7, 2024
0de3185
[CI Pipeline] Released Snapshot version: 5.40.53-alpha-29-SNAPSHOT
Oct 7, 2024
7772761
Adding vsock and dante logging
thomasm-ttd Oct 7, 2024
4823823
[CI Pipeline] Released Snapshot version: 5.40.54-alpha-30-SNAPSHOT
Oct 7, 2024
407e548
Temp change the CID
thomasm-ttd Oct 8, 2024
3b65da6
Revert CID change
thomasm-ttd Oct 8, 2024
b7dd254
Adding debug port to eks pod
cody-constine-ttd Oct 8, 2024
efbc1ac
[CI Pipeline] Released Snapshot version: 5.40.55-alpha-31-SNAPSHOT
Oct 8, 2024
d45f4cf
Turn of the exit on error
thomasm-ttd Oct 11, 2024
912a6a9
[CI Pipeline] Released Snapshot version: 5.40.56-alpha-34-SNAPSHOT
Oct 11, 2024
dff8dae
remove sleep and reset version
Ian-Nara Oct 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Makefile.eif
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ build/make_config.py: ./scripts/aws/make_config.py

.PHONY: build_configs

build_configs: build/conf/default-config.json build/conf/prod-uid2-config.json build/conf/integ-uid2-config.json build/conf/prod-euid-config.json build/conf/integ-euid-config.json build/conf/logback.xml
build_configs: build/conf/default-config.json build/conf/prod-uid2-config.json build/conf/integ-uid2-config.json build/conf/prod-euid-config.json build/conf/integ-euid-config.json build/conf/logback.xml build/conf/logback-debug.xml

build/conf/default-config.json: build_artifacts ./scripts/aws/conf/default-config.json
cp ./scripts/aws/conf/default-config.json ./build/conf/
Expand All @@ -57,6 +57,9 @@ build/conf/integ-euid-config.json: build_artifacts ./scripts/aws/conf/integ-euid
build/conf/logback.xml: build_artifacts ./scripts/aws/conf/logback.xml
cp ./scripts/aws/conf/logback.xml ./build/conf/

build/conf/logback-debug.xml: build_artifacts ./scripts/aws/conf/logback-debug.xml
cp ./scripts/aws/conf/logback-debug.xml ./build/conf/

build/Dockerfile: build_artifacts ./scripts/aws/Dockerfile
cp ./scripts/aws/Dockerfile ./build/

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.uid2</groupId>
<artifactId>uid2-operator</artifactId>
<version>5.40.48</version>
<version>5.40.56-alpha-34-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
15 changes: 15 additions & 0 deletions scripts/aws/conf/logback-debug.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<configuration>
<statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<jsonGeneratorDecorator class="net.logstash.logback.mask.MaskingJsonGeneratorDecorator">
<defaultMask>REDACTED - S3</defaultMask>
<value>\S+s3\.amazonaws\.com\/\S*X-Amz-Security-Token=\S+</value>
</jsonGeneratorDecorator>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>
20 changes: 16 additions & 4 deletions scripts/aws/eks-pod/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/bin/bash -eufx
#!/bin/bash -ufx
CID=42
EIF_PATH=/home/uid2operator.eif
MEMORY_MB=24576
CPU_COUNT=6
DEBUG_MODE="false"

set -x

Expand All @@ -13,7 +14,9 @@ function terminate_old_enclave() {
nitro-cli terminate-enclave --enclave-id ${ENCLAVE_ID}
echo "Terminated enclave with ID ${ENCLAVE_ID}"
else
nitro-cli describe-enclaves
echo "No running enclaves to terminate."
sleep 30
fi
}

Expand All @@ -27,7 +30,7 @@ function setup_vsockproxy() {
VSOCK_PROXY=${VSOCK_PROXY:-/home/vsockpx}
VSOCK_CONFIG=${VSOCK_CONFIG:-/home/proxies.host.yaml}
VSOCK_THREADS=${VSOCK_THREADS:-$(( $(nproc) * 2 )) }
VSOCK_LOG_LEVEL=${VSOCK_LOG_LEVEL:-3}
VSOCK_LOG_LEVEL=1
echo "starting vsock proxy at $VSOCK_PROXY with $VSOCK_THREADS worker threads..."
$VSOCK_PROXY -c $VSOCK_CONFIG --workers $VSOCK_THREADS --log-level $VSOCK_LOG_LEVEL --daemon
echo "vsock proxy now running in background."
Expand Down Expand Up @@ -87,12 +90,20 @@ function update_config() {
{ set +x; } 2>/dev/null; { CPU_COUNT=$(echo $IDENTITY_SERVICE_CONFIG | jq -r '.enclave_cpu_count'); set -x; }
{ set +x; } 2>/dev/null; { MEMORY_MB=$(echo $IDENTITY_SERVICE_CONFIG | jq -r '.enclave_memory_mb'); set -x; }
fi

{ set +x; } 2>/dev/null; { DEBUG_MODE=$(echo $IDENTITY_SERVICE_CONFIG | jq -r '.debug_mode'); set -x; }

shopt -u nocasematch
}

function run_enclave() {
echo "starting enclave... --cpu-count $CPU_COUNT --memory $MEMORY_MB --eif-path $EIF_PATH --enclave-cid $CID"
nitro-cli run-enclave --cpu-count $CPU_COUNT --memory $MEMORY_MB --eif-path $EIF_PATH --enclave-cid $CID --enclave-name uid2-operator
if [ "$DEBUG_MODE" = "true" ]; then
echo "starting enclave... --cpu-count $CPU_COUNT --memory $MEMORY_MB --eif-path $EIF_PATH --enclave-cid $CID --debug-mode --attach-console"
nitro-cli run-enclave --cpu-count $CPU_COUNT --memory $MEMORY_MB --eif-path $EIF_PATH --enclave-cid $CID --enclave-name uid2-operator --debug-mode --attach-console
else
echo "starting enclave... --cpu-count $CPU_COUNT --memory $MEMORY_MB --eif-path $EIF_PATH --enclave-cid $CID"
nitro-cli run-enclave --cpu-count $CPU_COUNT --memory $MEMORY_MB --eif-path $EIF_PATH --enclave-cid $CID --enclave-name uid2-operator
fi
}

echo "starting ..."
Expand All @@ -111,6 +122,7 @@ wait_for_config
update_config
run_enclave

nitro-cli describe-enclaves
sleep 60s
set +x
ENCLAVE_ID=$(nitro-cli describe-enclaves | jq -r ".[0].EnclaveID")
Expand Down
5 changes: 5 additions & 0 deletions scripts/aws/eks-pod/proxies.host.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ operator-service:
listen: tcp://0.0.0.0:80
connect: vsock://42:8080

operator-debug:
service: direct
listen: tcp://0.0.0.0:8000
connect: vsock://42:8000

operator-prometheus:
service: direct
listen: tcp://0.0.0.0:9080
Expand Down
8 changes: 4 additions & 4 deletions scripts/aws/eks-pod/sockd_eks.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#logoutput: stdout
logoutput: stdout
errorlog: stdout
#debug: 2
debug: 2
internal: 127.0.0.1 port = 3306
external: eth0
user.notprivileged: ec2-user
Expand All @@ -9,12 +9,12 @@ socksmethod: none

client pass {
from: 127.0.0.1/32 to: 127.0.0.1/32
log: error # connect disconnect iooperation
log: connect disconnect tcpinfo # connect disconnect iooperation
}

socks pass {
from: 127.0.0.1/32 to: 0.0.0.0/0
command: bind connect
protocol: tcp
log: error
log: connect disconnect tcpinfo
}
50 changes: 33 additions & 17 deletions scripts/aws/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#!/bin/bash -eufx
#!/bin/bash -ufx

# This is the entrypoint for the Enclave. It is executed in all enclaves - EC2 and EKS

LOG_FILE="/home/start.txt"

set -x
exec > $LOG_FILE
exec 2>&1
exec &> >(tee -a "$LOG_FILE")

set -o pipefail
ulimit -n 65536
Expand All @@ -17,11 +16,7 @@ ifconfig lo 127.0.0.1

# -- start vsock proxy
echo "Starting vsock proxy..."
/app/vsockpx --config /app/proxies.nitro.yaml --daemon --workers $(( $(nproc) * 2 )) --log-level 3

# -- setup syslog-ng
echo "Starting syslog-ng..."
/usr/sbin/syslog-ng --verbose
/app/vsockpx --config /app/proxies.nitro.yaml --daemon --workers $(( $(nproc) * 2 )) --log-level 1

# -- load config from identity service
echo "Loading config from identity service via proxy..."
Expand All @@ -42,6 +37,14 @@ do
sleep 2
done

DEBUG_MODE=$(jq -r ".debug_mode" < "${OVERRIDES_CONFIG}")

if [[ ! "$DEBUG_MODE" = "true" ]]; then
# -- setup syslog-ng
echo "Starting syslog-ng..."
/usr/sbin/syslog-ng --verbose
fi

# check the config is valid. Querying for a known missing element (empty) makes jq parse the file, but does not echo the results
if jq empty "${OVERRIDES_CONFIG}"; then
echo "Identity service returned valid config"
Expand Down Expand Up @@ -95,12 +98,25 @@ cd /app

# -- start operator
echo "Starting Java application..."
java \
-XX:MaxRAMPercentage=95 -XX:-UseCompressedOops -XX:+PrintFlagsFinal \
-Djava.security.egd=file:/dev/./urandom \
-Djava.library.path=/app/lib \
-Dvertx-config-path="${FINAL_CONFIG}" \
-Dvertx.logger-delegate-factory-class-name=io.vertx.core.logging.SLF4JLogDelegateFactory \
-Dlogback.configurationFile=./conf/logback.xml \
-Dhttp_proxy=socks5://127.0.0.1:3305 \
-jar /app/"${JAR_NAME}"-"${JAR_VERSION}".jar
if [[ "$DEBUG_MODE" = "true" ]]; then
java \
-XX:MaxRAMPercentage=95 -XX:-UseCompressedOops -XX:+PrintFlagsFinal \
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000 \
-Djava.security.egd=file:/dev/./urandom \
-Djava.library.path=/app/lib \
-Dvertx-config-path="${FINAL_CONFIG}" \
-Dvertx.logger-delegate-factory-class-name=io.vertx.core.logging.SLF4JLogDelegateFactory \
-Dlogback.configurationFile=./conf/logback-debug.xml \
-Dhttp_proxy=socks5://127.0.0.1:3305 \
-jar /app/"${JAR_NAME}"-"${JAR_VERSION}".jar
else
java \
-XX:MaxRAMPercentage=95 -XX:-UseCompressedOops -XX:+PrintFlagsFinal \
-Djava.security.egd=file:/dev/./urandom \
-Djava.library.path=/app/lib \
-Dvertx-config-path="${FINAL_CONFIG}" \
-Dvertx.logger-delegate-factory-class-name=io.vertx.core.logging.SLF4JLogDelegateFactory \
-Dlogback.configurationFile=./conf/logback.xml \
-Dhttp_proxy=socks5://127.0.0.1:3305 \
-jar /app/"${JAR_NAME}"-"${JAR_VERSION}".jar
fi
5 changes: 5 additions & 0 deletions scripts/aws/proxies.host.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ operator-service:
listen: tcp://0.0.0.0:80
connect: vsock://42:8080

operator-debug:
service: direct
listen: tcp://0.0.0.0:8000
connect: vsock://42:8000

operator-prometheus:
service: direct
listen: tcp://0.0.0.0:9080
Expand Down
5 changes: 5 additions & 0 deletions scripts/aws/proxies.nitro.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ uid-operator-in:
listen: vsock://-1:8080
connect: tcp://127.0.0.1:8080

uid-operator-debug-in:
service: direct
listen: vsock://-1:8000
connect: tcp://127.0.0.1:8000

prometheus-server:
service: direct
listen: vsock://-1:9080
Expand Down
7 changes: 5 additions & 2 deletions scripts/aws/sockd.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
logoutput: stdout
errorlog: stdout
debug: 2
internal: 127.0.0.1 port = 3306
external: ens5
user.notprivileged: ec2-user
Expand All @@ -6,12 +9,12 @@ socksmethod: none

client pass {
from: 127.0.0.1/32 to: 127.0.0.1/32
log: error # connect disconnect iooperation
log: connect disconnect tcpinfo # connect disconnect iooperation
}

socks pass {
from: 127.0.0.1/32 to: 0.0.0.0/0
command: bind connect
protocol: tcp
log: error
log: connect disconnect tcpinfo
}
Loading