Skip to content

Instantly share code, notes, and snippets.

View char-1ee's full-sized avatar

Li Xingjian char-1ee

  • Nanyang Technological University
  • Singapore
  • X @lix1ngjian
View GitHub Profile
@char-1ee
char-1ee / fc_logs.txt
Created May 14, 2024 10:05
Firecracker debug logs
Running Firecracker v1.4.1
2024-04-25T08:55:23.499421130 [6:fc_api:INFO] The request was executed successfully. Status code: 204 No Content.
2024-04-25T08:55:23.499458726 [6:fc_api:DEBUG] Total previous API call duration: 132 us.
2024-04-25T08:55:23.499687521 [6:fc_api:INFO] The API server received a Put request on "/metrics" with body "{\"metrics_path\":\"/var/lib/firecracker-containerd/shim-base/firecracker-containerd#6/fc-metrics.fifo\"}\n".
2024-04-25T08:55:23.499730906 [6:fc_api:INFO] The request was executed successfully. Status code: 204 No Content.
2024-04-25T08:55:23.499739481 [6:fc_api:DEBUG] Total previous API call duration: 57 us.
2024-04-25T08:55:23.500157496 [6:fc_api:INFO] The API server received a Put request on "/snapshot/load" with body "{\"container_snapshot_path\":\"/dev/mapper/fc-dev-thinpool-snap-11\",\"mem_backend\":{\"backend_path\":\"/fccd/snapshots/2/mem_file\",\"backend_type\":\"File\"},\"resume_vm\":true,\"snapshot_path\":\"/fccd/snapshots/2/snap_file\"}\n".
2024-04-25T08:55:23.500
@char-1ee
char-1ee / build.sh
Last active May 14, 2024 09:03
A script to set up vHive development environment on cloudlab
# Binary
cd firecracker-containerd
make all
cp runtime/containerd-shim-aws-firecracker ~/vHive/bin/
cp firecracker-control/cmd/containerd/firecracker-containerd ~/vHive/bin/
cp firecracker-control/cmd/containerd/firecracker-ctr ~/vHive/bin/
## Comment 'devtool strip' in the firecracker makefile
make firecracker
cp _submodules/firecracker/build/cargo_target/x86_64-unknown-linux-musl/release/jailer ~/vHive/bin/
time="2024-02-20T08:08:45-07:00" level=warning msg="containerd config version `1` has been deprecated and will be removed in containerd v2.0, please switch to version `2`, see https://github.com/containerd/containerd/blob/main/docs/PLUGINS.md#version-header"
time="2024-02-20T08:08:45.546233702-07:00" level=info msg="starting containerd" revision=49cac5eea1347954f2a6ce4dd57365b1c0f783c7 version=1.6.20+unknown
time="2024-02-20T08:08:45.565957518-07:00" level=info msg="loading plugin \"io.containerd.content.v1.content\"..." type=io.containerd.content.v1
time="2024-02-20T08:08:45.566052297-07:00" level=info msg="loading plugin \"io.containerd.snapshotter.v1.devmapper\"..." type=io.containerd.snapshotter.v1
time="2024-02-20T08:08:45.566103540-07:00" level=info msg="initializing pool device \"fc-dev-thinpool\""
time="2024-02-20T08:08:45.567493970-07:00" level=info msg="using dmsetup:\nLibrary version: 1.02.167 (2019-11-30)\nDriver version: 4.41.0"
time="2024-02-20T08:08:45.570251671-07:00" level=info msg="load
@char-1ee
char-1ee / vhive_log
Last active December 21, 2023 08:48
sudo mkdir -m777 -p /tmp/ctrd-logs && sudo env "PATH=/users/char/.vscode-server/bin/0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2/bin/remote-cli:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/go/bin:/users/char/go/bin" /usr/local/bin/firecracker-containerd --config /etc/firecracker-containerd/config.toml 1>/tmp/ctrd-logs/fccd_orch_noupf_log.out 2>/tmp/ctrd-logs/fccd_orch_noupf_log.err &
sudo env "PATH=/users/char/.vscode-server/bin/0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2/bin/remote-cli:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/go/bin:/users/char/go/bin" go test vhive_test.go stats.go vhive.go functions.go -short -v -race -cover -args -snapshotsTest -upfTest
time="2023-12-21T01:13:24.046702112-07:00" level=info msg="Orchestrator snapshots enabled: true"
time="2023-12-21T01:13:24.046883819-07:00" level=info msg="Orchestrator UPF enabled: true"
time="2023-12-21T01:13:24.046936398-07:00"
time="2023-10-18T13:29:03-06:00" level=warning msg="containerd config version `1` has been deprecated and will be removed in containerd v2.0, please switch to version `2`, see https://github.com/containerd/containerd/blob/main/docs/PLUGINS.md#version-header"
time="2023-10-18T13:29:03.250772173-06:00" level=info msg="starting containerd" revision=09e74c6de86fb093077a8aed11ad35b612c35b6a version=1.6.20+unknown
time="2023-10-18T13:29:03.272993881-06:00" level=info msg="loading plugin \"io.containerd.content.v1.content\"..." type=io.containerd.content.v1
time="2023-10-18T13:29:03.273097784-06:00" level=info msg="loading plugin \"io.containerd.snapshotter.v1.devmapper\"..." type=io.containerd.snapshotter.v1
time="2023-10-18T13:29:03.273150551-06:00" level=info msg="initializing pool device \"fc-dev-thinpool\""
time="2023-10-18T13:29:03.274583053-06:00" level=info msg="using dmsetup:\nLibrary version: 1.02.167 (2019-11-30)\nDriver version: 4.41.0"
time="2023-10-18T13:29:03.277705526-06:00" level=info msg="load
@char-1ee
char-1ee / firecracker-go-sdk-demo.md
Last active May 14, 2024 09:58
Vanilla firecracker support UPF work

How firecraker-go-sdk interact with firecracker

The example_demo.go gives an example of how to use go sdk to interact with firecrack. It creates an AWS S3 instance and sends a sleep 422 as a marker, and then load the instance from snapshotting to show this process sleep 422 is still existing. The example follows firecracker snapshot API support to

  • Create snapshot
    • Start new machine with socket and firecracker binary
    • Pause the VM
    • Create snapshot
    • Resume VM, stop and shutdown
  • Load snapshot
@char-1ee
char-1ee / fccd_orch_noupf_log.err
Last active September 14, 2023 05:39
test-pause-snaps-resume
time="2023-09-13T23:27:14-06:00" level=warning msg="deprecated version : `1`, please switch to version `2`"
time="2023-09-13T23:27:14.064495251-06:00" level=info msg="starting containerd" revision=4a8adae2660e3db2ea9b5b7b057b4388b9f5bab8 version=1.5.2+unknown
time="2023-09-13T23:27:14.098658687-06:00" level=info msg="loading plugin \"io.containerd.content.v1.content\"..." type=io.containerd.content.v1
time="2023-09-13T23:27:14.098700213-06:00" level=info msg="loading plugin \"io.containerd.snapshotter.v1.devmapper\"..." type=io.containerd.snapshotter.v1
time="2023-09-13T23:27:14.098755066-06:00" level=info msg="initializing pool device \"fc-dev-thinpool\""
time="2023-09-13T23:27:14.101261954-06:00" level=info msg="using dmsetup:\nLibrary version: 1.02.167 (2019-11-30)\nDriver version: 4.41.0"
time="2023-09-13T23:27:17.116848974-06:00" level=debug msg="(*service).Write started" expected="sha256:a87533385b75fd1d476d8a1112a0c5db953e3d5b44d4f9db814b1e2e6abb8734" ref="config-sha256:a87533385b75fd1d476d8a1112
Same usages
Native methods in Object class to compare two objects.
Whats the difference?
equals() compares by fields in class
hashCode() compares by hashCode generated, faster than former
So why we need equals()?
If equals() then must be hashCode() equals
If hashCode() equals cannot ensure real equals() because of hash collsions
@char-1ee
char-1ee / tree-of-responsibility.md
Last active July 29, 2022 05:02
Tree-of-responsibility pattern and its application in business scenario.

Tree of Responsibility

My notes on an article in Alibaba Cloud developer community.

This article introduces a design pattern, Tree of Responsibility, and how to apply it on if-else logic. Tree of Responsibility pattern, noted as ToR below, is a generalized chain design pattern combines of Chain-of-responsibility pattern and Strategy pattern. ToR not only can implment a level-to-level delegation as Chain-of-responsibiliy, but provides availiability to choose next-level strategy when currently in any level, as a high-level abstraction.

Preface

We should forget about small efficiencies,say about 97% of the time:premature optimization is the root of all evil.