ghojeong / faasnap

FaaSnap
MIT License
0 stars 0 forks source link

curl 요청하는 법 #4

Open ghojeong opened 2 years ago

ghojeong commented 2 years ago

Go 로 된 faasnap daemon 실행하기

go build cmd/faasnap-server/main.go 
./main --port 8080

Go 와는 별개로 실행하기

curl --request POST 'http://127.0.0.1:8080/functions' \
--header 'Content-Type: application/json' \
--data-raw '{
    "func_name": "exec",
    "image": "debian",
    "kernel": "v4.14",
    "vcpu": 2
}'

기타 들어가는 내용들

TESTID: 2022-09-15T10-07-47
no RESULT_DIR set, will not save results
test_dir: /home/intern/snapshots/
repeat: 1
parallelism: [1]
par_snapshots: [1]
kernels: namespace(v4.14='/home/intern/vmlinux', sanpage='/home/intern/faas-vmlinux')
vcpu: 2
record input: [0]
test input: [1]

=========vanilla hello: 0=========

-------- run_snap --------
func_name exec
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:07:57 GMT', 'Content-Length': '28'})
HTTP response body: {"message":"VM not exists"}

=========vanilla-cache hello: 0=========

-------- run_snap --------
func_name exec
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:08:02 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========reap hello: 0=========

-------- run_snap --------
func_name exec
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:08:07 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========faasnap hello: 0=========

-------- run_snap --------
func_name exec
image debian
kernel sanpage
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:08:12 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========vanilla mmap: 0=========

-------- run_snap --------
func_name exec
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:08:17 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========vanilla-cache mmap: 0=========

-------- run_snap --------
func_name exec
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:08:22 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========reap mmap: 0=========

-------- run_snap --------
func_name exec
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:08:27 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========faasnap mmap: 0=========

-------- run_snap --------
func_name exec
image debian
kernel sanpage
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:08:32 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========vanilla ffmpeg: 0=========

-------- run_snap --------
func_name ffmpeg
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:08:42 GMT', 'Content-Length': '28'})
HTTP response body: {"message":"VM not exists"}

=========vanilla-cache ffmpeg: 0=========

-------- run_snap --------
func_name ffmpeg
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:08:47 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========reap ffmpeg: 0=========

-------- run_snap --------
func_name ffmpeg
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:08:52 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========faasnap ffmpeg: 0=========

-------- run_snap --------
func_name ffmpeg
image debian
kernel sanpage
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:08:57 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========vanilla json: 0=========

-------- run_snap --------
func_name json
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:09:07 GMT', 'Content-Length': '28'})
HTTP response body: {"message":"VM not exists"}

=========vanilla-cache json: 0=========

-------- run_snap --------
func_name json
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:09:12 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========reap json: 0=========

-------- run_snap --------
func_name json
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:09:17 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========faasnap json: 0=========

-------- run_snap --------
func_name json
image debian
kernel sanpage
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:09:22 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========vanilla image: 0=========

-------- run_snap --------
func_name image
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:09:32 GMT', 'Content-Length': '28'})
HTTP response body: {"message":"VM not exists"}

=========vanilla-cache image: 0=========

-------- run_snap --------
func_name image
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:09:37 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========reap image: 0=========

-------- run_snap --------
func_name image
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:09:42 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========faasnap image: 0=========

-------- run_snap --------
func_name image
image debian
kernel sanpage
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:09:47 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========vanilla matmul: 0=========

-------- run_snap --------
func_name matmul
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:09:57 GMT', 'Content-Length': '28'})
HTTP response body: {"message":"VM not exists"}

=========vanilla-cache matmul: 0=========

-------- run_snap --------
func_name matmul
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:10:02 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========reap matmul: 0=========

-------- run_snap --------
func_name matmul
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:10:07 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========faasnap matmul: 0=========

-------- run_snap --------
func_name matmul
image debian
kernel sanpage
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:10:12 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========vanilla pyaes: 0=========

-------- run_snap --------
func_name pyaes
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:10:22 GMT', 'Content-Length': '28'})
HTTP response body: {"message":"VM not exists"}

=========vanilla-cache pyaes: 0=========

-------- run_snap --------
func_name pyaes
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:10:27 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========reap pyaes: 0=========

-------- run_snap --------
func_name pyaes
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:10:32 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========faasnap pyaes: 0=========

-------- run_snap --------
func_name pyaes
image debian
kernel sanpage
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:10:37 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========vanilla chameleon: 0=========

-------- run_snap --------
func_name chameleon
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:10:47 GMT', 'Content-Length': '28'})
HTTP response body: {"message":"VM not exists"}

=========vanilla-cache chameleon: 0=========

-------- run_snap --------
func_name chameleon
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:10:52 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========reap chameleon: 0=========

-------- run_snap --------
func_name chameleon
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:10:57 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========faasnap chameleon: 0=========

-------- run_snap --------
func_name chameleon
image debian
kernel sanpage
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:11:02 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========vanilla compression: 0=========

-------- run_snap --------
func_name compression
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:11:12 GMT', 'Content-Length': '28'})
HTTP response body: {"message":"VM not exists"}

=========vanilla-cache compression: 0=========

-------- run_snap --------
func_name compression
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:11:17 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========reap compression: 0=========

-------- run_snap --------
func_name compression
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:11:22 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========faasnap compression: 0=========

-------- run_snap --------
func_name compression
image debian
kernel sanpage
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:11:27 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========vanilla recognition: 0=========

-------- run_snap --------
func_name recognition
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:11:37 GMT', 'Content-Length': '28'})
HTTP response body: {"message":"VM not exists"}

=========vanilla-cache recognition: 0=========

-------- run_snap --------
func_name recognition
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:11:42 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========reap recognition: 0=========

-------- run_snap --------
func_name recognition
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:11:47 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========faasnap recognition: 0=========

-------- run_snap --------
func_name recognition
image debian
kernel sanpage
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:11:52 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========vanilla pagerank: 0=========

-------- run_snap --------
func_name pagerank
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:12:02 GMT', 'Content-Length': '28'})
HTTP response body: {"message":"VM not exists"}

=========vanilla-cache pagerank: 0=========

-------- run_snap --------
func_name pagerank
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:12:07 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========reap pagerank: 0=========

-------- run_snap --------
func_name pagerank
image debian
kernel v4.14
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:12:12 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}

=========faasnap pagerank: 0=========

-------- run_snap --------
func_name pagerank
image debian
kernel sanpage
vcpu 2
-------- run_snap --------
(400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 15 Sep 2022 10:12:17 GMT', 'Content-Length': '30'})
HTTP response body: {"message":"function exists"}
ghojeong commented 2 years ago

봐야할 것들

API 엔드포인트 보기

JSON 형식 보기

test.py 의 run_snap

AddNetwork

client.net_ifaces_namespace_put. ip route show 를 통해 라우팅 테이블 내용을 확인할 수 있다.

curl --request PUT 'http://127.0.0.1:8080/net-ifaces/fc1' \
--header 'Content-Type: application/json' \
--data-raw '{
        "host_dev_name": "vmtap0",
        "iface_id": "eth0",
        "guest_mac": "AA:FC:00:00:00:01",
        "guest_addr": "172.16.0.2",
        "unique_addr": "192.168.0.3"
}'

client.functions_post

curl --request POST 'http://127.0.0.1:8080/functions' \
--header 'Content-Type: application/json' \
--data-raw '{
    "func_name": "hello",
    "image": "debian",
    "kernel": "v4.14",
    "vcpu": 2
}'

ssIds = prepareVanilla or prepareMincore or prepareReap or prepareEmuMincore

prepareVanilla

VM 생성.

client.vms_post

curl --request POST 'http://127.0.0.1:8080/vms' \
--header 'Content-Type: application/json' \
--data-raw '{ 
    "func_name": "hello",
    "namespace": "fc1" 
}'

함수 호출

client.invocations_post

curl --request POST 'http://127.0.0.1:8080/invocations' \
--header 'Content-Type: application/json' \
--data-raw '{
    "func_name": "hello",
    "vmId": "lMCEyDL8",
    "params": "{}",
    "mincore": -1,
    "enableReap": false
}'

snapshot 찍기

client.snapshots_post. base_path 에 firecracker.sock 를 필요로 한다.

curl --request POST 'http://127.0.0.1:8080/snapshots' \
--header 'Content-Type: application/json' \
--data-raw '{
    "vmId": "Y0fXWEzr",
    "snapshot_type": "Full",
    "snapshot_path": "/home/intern/test_dir/Full.snapshot1",
    "mem_file_path": "/home/intern/test_dir/Full.memfile1",
    "version": "0.23.0"
}'

VM 삭제

client.vms_vm_id_delete. DELETE '/vms/{vmId}'

SnapShot 수정1

client.snapshots_put PUT '/snapshots'

SnapShot 수정2

client.snapshots_ss_id_patch PATCH '/snapshots/{ssId}'