提交 b29509be 编写于 作者: J jiazhiguang

reimplement the bundle cache

上级 8d46bc6a
......@@ -4,6 +4,10 @@ ROOTDIR=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))
# Base path used to install.
DESTDIR ?= /usr/local
ifneq ($(GO111MODULE),off)
MOD_VENDOR := "-mod=vendor"
endif
ifneq "$(strip $(shell command -v go 2>/dev/null))" ""
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
......@@ -47,7 +51,7 @@ all: binaries
# Build a binary from a cmd.
bin/epm:
@echo "bin/epm"
@CGO_ENABLED=${EPM_CGO_ENABLED} GOOS=${GOOS} go build ${GO_BUILD_FLAGS} -o bin/epm ./cmd/epm/main.go
@CGO_ENABLED=${EPM_CGO_ENABLED} GOOS=${GOOS} go build $(MOD_VENDOR) ${GO_BUILD_FLAGS} -o bin/epm ./cmd/epm/main.go
binaries: clean $(BINARIES) ## build binaries
......
......@@ -44,25 +44,14 @@ func runServer(opts *options.Options) error {
server := epm.EnclavePoolManagerServer{}
bundleCache0 := occlum.BundleCach0Manager{
DefaultEnclavePool: epm.DefaultEnclavePool{
Root: cfg.Root,
CacheMetadata: metadata,
}}
bundleCache1 := occlum.BundleCach1Manager{
DefaultEnclavePool: epm.DefaultEnclavePool{
Root: cfg.Root,
CacheMetadata: metadata,
}}
bundleCache2 := occlum.BundleCach2Manager{
DefaultEnclavePool: epm.DefaultEnclavePool{
Root: cfg.Root,
CacheMetadata: metadata,
}}
bundleCache0 := occlum.NewBundleCach0Manager(cfg.Root, metadata)
bundleCache1 := occlum.NewBundleCach1Manager(cfg.Root, metadata)
bundleCache2 := occlum.NewBundleCach2Manager(cfg.Root, metadata)
// register the bundle cache pool managers to the manager server
server.RegisterCachePoolManager(&bundleCache0)
server.RegisterCachePoolManager(&bundleCache1)
server.RegisterCachePoolManager(&bundleCache2)
server.RegisterCachePoolManager(bundleCache0)
server.RegisterCachePoolManager(bundleCache1)
server.RegisterCachePoolManager(bundleCache2)
// start the grpc server with the server options
s := grpc.NewServer(serverOpts...)
......
......@@ -11,7 +11,7 @@ require (
github.com/prometheus/procfs v0.0.5 // indirect
github.com/spf13/cobra v1.0.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.4.0 // indirect
github.com/stretchr/testify v1.4.0
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9 // indirect
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d // indirect
golang.org/x/text v0.3.2 // indirect
......
......@@ -8,6 +8,7 @@ package v1alpha1
import (
proto "github.com/golang/protobuf/proto"
any "github.com/golang/protobuf/ptypes/any"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
......@@ -43,6 +44,8 @@ type Cache struct {
Size int64 `protobuf:"varint,5,opt,name=size,proto3" json:"size,omitempty"`
// Created represents the creation time of the cache which is the number of seconds elapsed since January 1, 1970 UTC
Created int64 `protobuf:"varint,6,opt,name=created,proto3" json:"created,omitempty"`
// Options is an optional field which can extend any type of data structure
Options *any.Any `protobuf:"bytes,7,opt,name=options,proto3" json:"options,omitempty"`
}
func (x *Cache) Reset() {
......@@ -119,6 +122,13 @@ func (x *Cache) GetCreated() int64 {
return 0
}
func (x *Cache) GetOptions() *any.Any {
if x != nil {
return x.Options
}
return nil
}
// GetCacheRequest
type GetCacheRequest struct {
state protoimpl.MessageState
......@@ -669,80 +679,85 @@ var File_api_proto protoreflect.FileDescriptor
var file_api_proto_rawDesc = []byte{
0x0a, 0x09, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x76, 0x31, 0x61,
0x6c, 0x70, 0x68, 0x61, 0x31, 0x22, 0x9e, 0x01, 0x0a, 0x05, 0x43, 0x61, 0x63, 0x68, 0x65, 0x12,
0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74,
0x79, 0x70, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x02, 0x49, 0x44, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x61, 0x76, 0x65, 0x50, 0x61, 0x74, 0x68, 0x18,
0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x61, 0x76, 0x65, 0x50, 0x61, 0x74, 0x68, 0x12,
0x27, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x0f, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65,
0x52, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65,
0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x18, 0x0a, 0x07,
0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x63,
0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x22, 0x35, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x43, 0x61, 0x63,
0x68, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70,
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x0e, 0x0a,
0x02, 0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x44, 0x22, 0x39, 0x0a,
0x10, 0x47, 0x65, 0x74, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x12, 0x25, 0x0a, 0x05, 0x63, 0x61, 0x63, 0x68, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x0f, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x61, 0x63, 0x68,
0x65, 0x52, 0x05, 0x63, 0x61, 0x63, 0x68, 0x65, 0x22, 0x59, 0x0a, 0x10, 0x53, 0x61, 0x76, 0x65,
0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x05,
0x6c, 0x70, 0x68, 0x61, 0x31, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x22, 0xce, 0x01, 0x0a, 0x05, 0x43, 0x61, 0x63, 0x68, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79,
0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x0e,
0x0a, 0x02, 0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x44, 0x12, 0x1a,
0x0a, 0x08, 0x73, 0x61, 0x76, 0x65, 0x50, 0x61, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09,
0x52, 0x08, 0x73, 0x61, 0x76, 0x65, 0x50, 0x61, 0x74, 0x68, 0x12, 0x27, 0x0a, 0x06, 0x70, 0x61,
0x72, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x31, 0x61,
0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x06, 0x70, 0x61, 0x72,
0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28,
0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74,
0x65, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65,
0x64, 0x12, 0x2e, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x07, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e,
0x73, 0x22, 0x35, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x44, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x44, 0x22, 0x39, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x43,
0x61, 0x63, 0x68, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x05,
0x63, 0x61, 0x63, 0x68, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x31,
0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x05, 0x63, 0x61,
0x63, 0x68, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x61, 0x74,
0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50,
0x61, 0x74, 0x68, 0x22, 0x23, 0x0a, 0x11, 0x53, 0x61, 0x76, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x01,
0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x6f, 0x6b, 0x22, 0x5e, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74,
0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04,
0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65,
0x12, 0x20, 0x0a, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x43, 0x61, 0x63, 0x68, 0x65, 0x49, 0x44, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x43, 0x61, 0x63, 0x68, 0x65,
0x49, 0x44, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28,
0x05, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x3c, 0x0a, 0x11, 0x4c, 0x69, 0x73, 0x74,
0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a,
0x06, 0x63, 0x61, 0x63, 0x68, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e,
0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x06,
0x63, 0x61, 0x63, 0x68, 0x65, 0x73, 0x22, 0x38, 0x0a, 0x12, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65,
0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04,
0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65,
0x12, 0x0e, 0x0a, 0x02, 0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x44,
0x22, 0x25, 0x0a, 0x13, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x01, 0x20,
0x01, 0x28, 0x08, 0x52, 0x02, 0x6f, 0x6b, 0x22, 0x56, 0x0a, 0x10, 0x4c, 0x6f, 0x61, 0x64, 0x43,
0x61, 0x63, 0x68, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x74,
0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12,
0x0e, 0x0a, 0x02, 0x49, 0x44, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x44, 0x12,
0x1e, 0x0a, 0x0a, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x50, 0x61, 0x74, 0x68, 0x18, 0x04, 0x20,
0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x50, 0x61, 0x74, 0x68, 0x22,
0x23, 0x0a, 0x11, 0x4c, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08,
0x52, 0x02, 0x6f, 0x6b, 0x32, 0xff, 0x02, 0x0a, 0x12, 0x45, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65,
0x50, 0x6f, 0x6f, 0x6c, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x12, 0x43, 0x0a, 0x08, 0x47,
0x65, 0x74, 0x43, 0x61, 0x63, 0x68, 0x65, 0x12, 0x19, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68,
0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65,
0x74, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00,
0x12, 0x46, 0x0a, 0x09, 0x53, 0x61, 0x76, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, 0x12, 0x1a, 0x2e,
0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x61, 0x76, 0x65, 0x43, 0x61, 0x63,
0x68, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x76, 0x31, 0x61, 0x6c,
0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x61, 0x76, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x46, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74,
0x43, 0x61, 0x63, 0x68, 0x65, 0x12, 0x1a, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31,
0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x1b, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73,
0x74, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00,
0x12, 0x4c, 0x0a, 0x0b, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, 0x12,
0x1c, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74,
0x65, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e,
0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x43,
0x61, 0x63, 0x68, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x46,
0x0a, 0x09, 0x4c, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x63, 0x68, 0x65, 0x12, 0x1a, 0x2e, 0x76, 0x31,
0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x63, 0x68, 0x65,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68,
0x61, 0x31, 0x2e, 0x4c, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x63, 0x68, 0x65, 0x22, 0x59, 0x0a, 0x10, 0x53, 0x61, 0x76, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x05, 0x63, 0x61, 0x63, 0x68, 0x65,
0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61,
0x31, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x05, 0x63, 0x61, 0x63, 0x68, 0x65, 0x12, 0x1e,
0x0a, 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01,
0x28, 0x09, 0x52, 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x61, 0x74, 0x68, 0x22, 0x23,
0x0a, 0x11, 0x53, 0x61, 0x76, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52,
0x02, 0x6f, 0x6b, 0x22, 0x5e, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x61, 0x63, 0x68, 0x65,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x6c,
0x61, 0x73, 0x74, 0x43, 0x61, 0x63, 0x68, 0x65, 0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x52, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x43, 0x61, 0x63, 0x68, 0x65, 0x49, 0x44, 0x12, 0x14, 0x0a,
0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x69,
0x6d, 0x69, 0x74, 0x22, 0x3c, 0x0a, 0x11, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x61, 0x63, 0x68, 0x65,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x06, 0x63, 0x61, 0x63, 0x68,
0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70,
0x68, 0x61, 0x31, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x06, 0x63, 0x61, 0x63, 0x68, 0x65,
0x73, 0x22, 0x38, 0x0a, 0x12, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x49,
0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x44, 0x22, 0x25, 0x0a, 0x13, 0x44,
0x65, 0x6c, 0x65, 0x74, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02,
0x6f, 0x6b, 0x22, 0x56, 0x0a, 0x10, 0x4c, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x44,
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x44, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x61,
0x72, 0x67, 0x65, 0x74, 0x50, 0x61, 0x74, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a,
0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x50, 0x61, 0x74, 0x68, 0x22, 0x23, 0x0a, 0x11, 0x4c, 0x6f,
0x61, 0x64, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x6f, 0x6b, 0x32,
0xff, 0x02, 0x0a, 0x12, 0x45, 0x6e, 0x63, 0x6c, 0x61, 0x76, 0x65, 0x50, 0x6f, 0x6f, 0x6c, 0x4d,
0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x12, 0x43, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x43, 0x61, 0x63,
0x68, 0x65, 0x12, 0x19, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65,
0x74, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e,
0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x61, 0x63, 0x68,
0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x46, 0x0a, 0x09, 0x53,
0x61, 0x76, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, 0x12, 0x1a, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70,
0x68, 0x61, 0x31, 0x2e, 0x53, 0x61, 0x76, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e,
0x53, 0x61, 0x76, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x22, 0x00, 0x12, 0x46, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x61, 0x63, 0x68, 0x65,
0x12, 0x1a, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74,
0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x76,
0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x61, 0x63, 0x68,
0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4c, 0x0a, 0x0b, 0x44,
0x65, 0x6c, 0x65, 0x74, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, 0x12, 0x1c, 0x2e, 0x76, 0x31, 0x61,
0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x43, 0x61, 0x63, 0x68,
0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70,
0x68, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x46, 0x0a, 0x09, 0x4c, 0x6f, 0x61,
0x64, 0x43, 0x61, 0x63, 0x68, 0x65, 0x12, 0x1a, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61,
0x31, 0x2e, 0x4c, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x6f,
0x61, 0x64, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
......@@ -770,27 +785,29 @@ var file_api_proto_goTypes = []interface{}{
(*DeleteCacheResponse)(nil), // 8: v1alpha1.DeleteCacheResponse
(*LoadCacheRequest)(nil), // 9: v1alpha1.LoadCacheRequest
(*LoadCacheResponse)(nil), // 10: v1alpha1.LoadCacheResponse
(*any.Any)(nil), // 11: google.protobuf.Any
}
var file_api_proto_depIdxs = []int32{
0, // 0: v1alpha1.Cache.parent:type_name -> v1alpha1.Cache
0, // 1: v1alpha1.GetCacheResponse.cache:type_name -> v1alpha1.Cache
0, // 2: v1alpha1.SaveCacheRequest.cache:type_name -> v1alpha1.Cache
0, // 3: v1alpha1.ListCacheResponse.caches:type_name -> v1alpha1.Cache
1, // 4: v1alpha1.EnclavePoolManager.GetCache:input_type -> v1alpha1.GetCacheRequest
3, // 5: v1alpha1.EnclavePoolManager.SaveCache:input_type -> v1alpha1.SaveCacheRequest
5, // 6: v1alpha1.EnclavePoolManager.ListCache:input_type -> v1alpha1.ListCacheRequest
7, // 7: v1alpha1.EnclavePoolManager.DeleteCache:input_type -> v1alpha1.DeleteCacheRequest
9, // 8: v1alpha1.EnclavePoolManager.LoadCache:input_type -> v1alpha1.LoadCacheRequest
2, // 9: v1alpha1.EnclavePoolManager.GetCache:output_type -> v1alpha1.GetCacheResponse
4, // 10: v1alpha1.EnclavePoolManager.SaveCache:output_type -> v1alpha1.SaveCacheResponse
6, // 11: v1alpha1.EnclavePoolManager.ListCache:output_type -> v1alpha1.ListCacheResponse
8, // 12: v1alpha1.EnclavePoolManager.DeleteCache:output_type -> v1alpha1.DeleteCacheResponse
10, // 13: v1alpha1.EnclavePoolManager.LoadCache:output_type -> v1alpha1.LoadCacheResponse
9, // [9:14] is the sub-list for method output_type
4, // [4:9] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
11, // 1: v1alpha1.Cache.options:type_name -> google.protobuf.Any
0, // 2: v1alpha1.GetCacheResponse.cache:type_name -> v1alpha1.Cache
0, // 3: v1alpha1.SaveCacheRequest.cache:type_name -> v1alpha1.Cache
0, // 4: v1alpha1.ListCacheResponse.caches:type_name -> v1alpha1.Cache
1, // 5: v1alpha1.EnclavePoolManager.GetCache:input_type -> v1alpha1.GetCacheRequest
3, // 6: v1alpha1.EnclavePoolManager.SaveCache:input_type -> v1alpha1.SaveCacheRequest
5, // 7: v1alpha1.EnclavePoolManager.ListCache:input_type -> v1alpha1.ListCacheRequest
7, // 8: v1alpha1.EnclavePoolManager.DeleteCache:input_type -> v1alpha1.DeleteCacheRequest
9, // 9: v1alpha1.EnclavePoolManager.LoadCache:input_type -> v1alpha1.LoadCacheRequest
2, // 10: v1alpha1.EnclavePoolManager.GetCache:output_type -> v1alpha1.GetCacheResponse
4, // 11: v1alpha1.EnclavePoolManager.SaveCache:output_type -> v1alpha1.SaveCacheResponse
6, // 12: v1alpha1.EnclavePoolManager.ListCache:output_type -> v1alpha1.ListCacheResponse
8, // 13: v1alpha1.EnclavePoolManager.DeleteCache:output_type -> v1alpha1.DeleteCacheResponse
10, // 14: v1alpha1.EnclavePoolManager.LoadCache:output_type -> v1alpha1.LoadCacheResponse
10, // [10:15] is the sub-list for method output_type
5, // [5:10] is the sub-list for method input_type
5, // [5:5] is the sub-list for extension type_name
5, // [5:5] is the sub-list for extension extendee
0, // [0:5] is the sub-list for field type_name
}
func init() { file_api_proto_init() }
......
......@@ -2,6 +2,8 @@ syntax = 'proto3';
package v1alpha1;
import "google/protobuf/any.proto";
// Cache represents the metadata of a cache managed by enclave pool.
message Cache {
// Type represents the type of enclave pool
......@@ -16,6 +18,8 @@ message Cache {
int64 size = 5;
// Created represents the creation time of the cache which is the number of seconds elapsed since January 1, 1970 UTC
int64 created = 6;
// Options is an optional field which can extend any type of data structure
google.protobuf.Any options = 7;
}
// EnclavePoolManager represents an enclave pool
......
package occlum
import (
"io/ioutil"
"os"
"path/filepath"
"time"
cache_metadata "github.com/alibaba/inclavare-containers/epm/pkg/metadata"
cache_manager "github.com/alibaba/inclavare-containers/epm/pkg/epm"
"github.com/alibaba/inclavare-containers/epm/pkg/epm-api/v1alpha1"
"github.com/alibaba/inclavare-containers/epm/pkg/epm/bundle-cache-pool/occlum/constants"
"github.com/alibaba/inclavare-containers/epm/pkg/epm/bundle-cache-pool/occlum/types"
"github.com/alibaba/inclavare-containers/epm/pkg/utils"
)
type BundleCach0Manager struct {
cache_manager.DefaultEnclavePool
}
func NewBundleCach0Manager(root string, metadata *cache_metadata.Metadata) *BundleCach0Manager {
return &BundleCach0Manager{
DefaultEnclavePool: cache_manager.DefaultEnclavePool{
Root: root,
Type: string(types.BundleCache0PoolType),
CacheMetadata: metadata,
}}
}
func (d *BundleCach0Manager) GetPoolType() string {
return d.Type
}
func (d *BundleCach0Manager) SaveCache(sourcePath string, cache *v1alpha1.Cache) error {
savePath, err := d.BuildCacheSavePath(d.Root, cache)
if err != nil {
return err
}
if err := os.RemoveAll(savePath); err != nil {
return nil
}
if err := os.MkdirAll(savePath, 0755); err != nil {
return err
}
sourceDirs := []string{"build/mount/"}
for _, dir := range sourceDirs {
srcDir := filepath.Join(sourcePath, dir)
destDir := filepath.Join(savePath, dir)
src, err := os.Stat(srcDir)
if err != nil {
return err
}
if err := os.MkdirAll(destDir, src.Mode()); err != nil {
return err
}
if err := utils.CopyDirectory(srcDir, destDir); err != nil {
return err
}
}
if err := ioutil.WriteFile(filepath.Join(savePath, constants.OcclumStatusFileName), []byte(types.ImageBuilt), 0644); err != nil {
return err
}
if err := ioutil.WriteFile(filepath.Join(savePath, constants.OcclumSGXModeFileName), []byte("HW"), 0644); err != nil {
return err
}
size, err := utils.DirSize(savePath)
if err != nil {
return err
}
cache.SavePath = savePath
cache.Size = size
cache.Created = time.Now().Unix()
return d.CacheMetadata.SaveCache(d.GetPoolType(), cache.ID, cache)
}
package occlum
import (
"io/ioutil"
"os"
"path/filepath"
"time"
cache_metadata "github.com/alibaba/inclavare-containers/epm/pkg/metadata"
cache_manager "github.com/alibaba/inclavare-containers/epm/pkg/epm"
"github.com/alibaba/inclavare-containers/epm/pkg/epm-api/v1alpha1"
"github.com/alibaba/inclavare-containers/epm/pkg/epm/bundle-cache-pool/occlum/constants"
"github.com/alibaba/inclavare-containers/epm/pkg/epm/bundle-cache-pool/occlum/types"
"github.com/alibaba/inclavare-containers/epm/pkg/utils"
)
type BundleCach1Manager struct {
cache_manager.DefaultEnclavePool
}
func NewBundleCach1Manager(root string, metadata *cache_metadata.Metadata) *BundleCach1Manager {
return &BundleCach1Manager{
DefaultEnclavePool: cache_manager.DefaultEnclavePool{
Root: root,
Type: string(types.BundleCache1PoolType),
CacheMetadata: metadata,
}}
}
func (d *BundleCach1Manager) GetPoolType() string {
return d.Type
}
func (d *BundleCach1Manager) SaveCache(sourcePath string, cache *v1alpha1.Cache) error {
savePath, err := d.BuildCacheSavePath(d.Root, cache)
if err != nil {
return err
}
if err := os.RemoveAll(savePath); err != nil {
return nil
}
if err := os.MkdirAll(savePath, 0755); err != nil {
return err
}
sourceDirs := []string{
"build/bin/",
"build/lib/",
}
sourceFiles := []string{
"build/Enclave.xml",
"build/Occlum.json",
"build/Occlum.json.protected",
}
for _, dir := range sourceDirs {
srcDir := filepath.Join(sourcePath, dir)
destDir := filepath.Join(savePath, dir)
src, err := os.Stat(srcDir)
if err != nil {
return err
}
if err := os.MkdirAll(destDir, src.Mode()); err != nil {
return err
}
if err := utils.CopyDirectory(srcDir, destDir); err != nil {
return err
}
}
for _, file := range sourceFiles {
if err := utils.CopyFile(filepath.Join(sourcePath, file), filepath.Join(savePath, file)); err != nil {
return err
}
}
if err := ioutil.WriteFile(filepath.Join(savePath, constants.OcclumStatusFileName), []byte(types.Built), 0644); err != nil {
return err
}
os.Remove(filepath.Join(savePath, "build/lib/libocclum-libos.signed.so"))
size, err := utils.DirSize(savePath)
if err != nil {
return err
}
cache.SavePath = savePath
cache.Size = size
cache.Created = time.Now().Unix()
return d.CacheMetadata.SaveCache(d.GetPoolType(), cache.ID, cache)
}
package occlum
import (
"io/ioutil"
"os"
"path/filepath"
"time"
cache_metadata "github.com/alibaba/inclavare-containers/epm/pkg/metadata"
cache_manager "github.com/alibaba/inclavare-containers/epm/pkg/epm"
"github.com/alibaba/inclavare-containers/epm/pkg/epm-api/v1alpha1"
"github.com/alibaba/inclavare-containers/epm/pkg/epm/bundle-cache-pool/occlum/constants"
"github.com/alibaba/inclavare-containers/epm/pkg/epm/bundle-cache-pool/occlum/types"
"github.com/alibaba/inclavare-containers/epm/pkg/utils"
)
type BundleCach2Manager struct {
cache_manager.DefaultEnclavePool
}
func NewBundleCach2Manager(root string, metadata *cache_metadata.Metadata) *BundleCach2Manager {
return &BundleCach2Manager{
DefaultEnclavePool: cache_manager.DefaultEnclavePool{
Root: root,
Type: string(types.BundleCache2PoolType),
CacheMetadata: metadata,
}}
}
func (d *BundleCach2Manager) GetPoolType() string {
return d.Type
}
func (d *BundleCach2Manager) SaveCache(sourcePath string, cache *v1alpha1.Cache) error {
savePath, err := d.BuildCacheSavePath(d.Root, cache)
if err != nil {
return err
}
if err := os.RemoveAll(savePath); err != nil {
return nil
}
if err := os.MkdirAll(savePath, 0755); err != nil {
return err
}
sourceFiles := []string{
"build/lib/libocclum-libos.signed.so",
}
for _, file := range sourceFiles {
srcFile := filepath.Join(sourcePath, file)
destFile :=