-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #338 from alexmwu/logging-fix
Fix logging blocking issue
- Loading branch information
Showing
37 changed files
with
821 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
#!/bin/bash | ||
|
||
main() { | ||
# copy systemd files | ||
# Copy service files. | ||
cp /usr/share/oem/confidential_space/container-runner.service /etc/systemd/system/container-runner.service | ||
# Override default fluent-bit config. | ||
cp /usr/share/oem/confidential_space/fluent-bit-cs.conf /etc/fluent-bit/fluent-bit.conf | ||
|
||
systemctl daemon-reload | ||
systemctl enable container-runner.service | ||
systemctl start container-runner.service | ||
systemctl start fluent-bit.service | ||
|
||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# | ||
# Copyright 2022 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
# Forked from https://cos.googlesource.com/cos/overlays/board-overlays/+/refs/heads/master/project-lakitu/app-admin/fluent-bit/files/fluent-bit.conf | ||
|
||
[SERVICE] | ||
# Flush | ||
# ===== | ||
# set an interval of seconds before to flush records to a destination | ||
flush 1 | ||
# Daemon | ||
# ====== | ||
# instruct Fluent Bit to run in foreground or background mode. | ||
daemon Off | ||
# Log_Level | ||
# ========= | ||
# Set the verbosity level of the service, values can be: | ||
# | ||
# - error | ||
# - warning | ||
# - info | ||
# - debug | ||
# - trace | ||
# | ||
# by default 'info' is set, that means it includes 'error' and 'warning'. | ||
log_level info | ||
# Storage | ||
# ======= | ||
# Fluent Bit can use memory and filesystem buffering based mechanisms | ||
# | ||
# - https://docs.fluentbit.io/manual/administration/buffering-and-storage | ||
# | ||
# storage metrics | ||
# --------------- | ||
# publish storage pipeline metrics in '/api/v1/storage'. The metrics are | ||
# exported only if the 'http_server' option is enabled. | ||
# | ||
storage.metrics on | ||
|
||
# Collects CS launcher and workload logs. | ||
[INPUT] | ||
Name systemd | ||
Tag confidential-space-launcher | ||
Systemd_Filter _SYSTEMD_UNIT=container-runner.service | ||
DB /var/log/google-fluentbit/container-runner.log.db | ||
Read_From_Tail False | ||
|
||
[OUTPUT] | ||
Name stackdriver | ||
Match * | ||
Resource gce_instance | ||
severity_key severity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
111 changes: 111 additions & 0 deletions
111
launcher/image/test/scripts/test_launcher_workload_cloudlogging.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
source util/read_cloud_logging.sh | ||
|
||
# This test requires the workload to run and print | ||
# corresponding messages to cloud logging. | ||
CLOUD_LOGGING_OUTPUT=$(read_cloud_logging $1) | ||
print_logs=false | ||
|
||
if echo $CLOUD_LOGGING_OUTPUT | grep -q 'Workload running' | ||
then | ||
echo "- workload running verified" | ||
else | ||
echo "FAILED: workload not running" | ||
echo 'TEST FAILED.' > /workspace/status.txt | ||
print_logs=true | ||
fi | ||
|
||
if echo $CLOUD_LOGGING_OUTPUT | grep -q 'Workload args: \[/main newCmd\]' | ||
then | ||
echo "- arguments verified" | ||
else | ||
echo "FAILED: arguments not verified" | ||
echo 'TEST FAILED.' > /workspace/status.txt | ||
print_logs=true | ||
fi | ||
|
||
if echo $CLOUD_LOGGING_OUTPUT | grep -q 'env_bar=val_bar' | ||
then | ||
echo "- env_bar env var verified" | ||
else | ||
echo "FAILED: env_bar env not verified" | ||
echo 'TEST FAILED.' > /workspace/status.txt | ||
print_logs=true | ||
fi | ||
|
||
if echo $CLOUD_LOGGING_OUTPUT | grep -q 'ALLOWED_OVERRIDE=overridden' | ||
then | ||
echo "- ALLOWED_OVERRIDE env var verified" | ||
else | ||
echo "FAILED: ALLOWED_OVERRIDE env not verified" | ||
echo 'TEST FAILED.' > /workspace/status.txt | ||
print_logs=true | ||
fi | ||
|
||
if echo $CLOUD_LOGGING_OUTPUT | grep -q 'aud: https://sts.googleapis.com' | ||
then | ||
echo "- token aud verified" | ||
else | ||
echo "FAILED: token aud not verified" | ||
echo 'TEST FAILED.' > /workspace/status.txt | ||
print_logs=true | ||
fi | ||
|
||
if echo $CLOUD_LOGGING_OUTPUT | grep -q 'iss: https://confidentialcomputing.googleapis.com' | ||
then | ||
echo "- token iss verified" | ||
else | ||
echo "FAILED: token iss not verified" | ||
echo 'TEST FAILED.' > /workspace/status.txt | ||
print_logs=true | ||
fi | ||
|
||
if echo $CLOUD_LOGGING_OUTPUT | grep -q 'secboot: true' | ||
then | ||
echo "- token secboot verified" | ||
else | ||
echo "FAILED: token secboot not verified" | ||
echo 'TEST FAILED.' > /workspace/status.txt | ||
print_logs=true | ||
fi | ||
|
||
if echo $CLOUD_LOGGING_OUTPUT | grep -q 'oemid: 11129' | ||
then | ||
echo "- token oemid verified" | ||
else | ||
echo "FAILED: token oemid not verified" | ||
echo 'TEST FAILED.' > /workspace/status.txt | ||
print_logs=true | ||
fi | ||
|
||
if echo $CLOUD_LOGGING_OUTPUT | grep -q 'hwmodel: GCP_AMD_SEV' | ||
then | ||
echo "- token hwmodel verified" | ||
else | ||
echo "FAILED: token hwmodel not verified" | ||
echo 'TEST FAILED.' > /workspace/status.txt | ||
print_logs=true | ||
fi | ||
|
||
if echo $CLOUD_LOGGING_OUTPUT | grep -q 'swname: GCE' | ||
then | ||
echo "- token swname verified" | ||
else | ||
echo "FAILED: token swname not verified" | ||
echo 'TEST FAILED.' > /workspace/status.txt | ||
print_logs=true | ||
fi | ||
|
||
if echo $CLOUD_LOGGING_OUTPUT | grep -q 'Token looks okay' | ||
then | ||
echo "- OIDC token accessible" | ||
else | ||
echo "FAILED: OIDC token not accessible" | ||
echo 'TEST FAILED.' > /workspace/status.txt | ||
print_logs=true | ||
fi | ||
|
||
if $print_logs; then | ||
echo $CLOUD_LOGGING_OUTPUT | ||
fi |
16 changes: 16 additions & 0 deletions
16
launcher/image/test/scripts/test_launchpolicy_cmd_cloudlogging.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
source util/read_cloud_logging.sh | ||
|
||
# Allow VM some time to boot and write to serial console. | ||
sleep 120 | ||
|
||
CLOUD_LOGGING_OUTPUT=$(read_cloud_logging $1) | ||
if echo $CLOUD_LOGGING_OUTPUT | grep -q 'CMD is not allowed to be overridden on this image' | ||
then | ||
echo "- CMD launch policy verified" | ||
else | ||
echo "FAILED: CMD launch policy verification" | ||
echo 'TEST FAILED' > /workspace/status.txt | ||
echo $CLOUD_LOGGING_OUTPUT | ||
fi |
16 changes: 16 additions & 0 deletions
16
launcher/image/test/scripts/test_launchpolicy_env_cloudlogging.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
source util/read_cloud_logging.sh | ||
|
||
# Allow VM some time to boot and write to cloud logging. | ||
sleep 120 | ||
|
||
CLOUD_LOGGING_OUTPUT=$(read_cloud_logging $1) | ||
if echo $CLOUD_LOGGING_OUTPUT | grep -q --fixed-strings 'env var {OUT a} is not allowed to be overridden on this image; allowed envs to be overridden: [ALLOWED_OVERRIDE]' | ||
then | ||
echo "- Env launch policy verified" | ||
else | ||
echo "FAILED: Env launch policy verification" | ||
echo 'TEST FAILED' > /workspace/status.txt | ||
echo $CLOUD_LOGGING_OUTPUT | ||
fi |
File renamed without changes.
Oops, something went wrong.