alibaba / funcraft

(have) Fun with Serverless(API Gateway & Function Compute)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

使用fun local invoke查看内存使用时文件不存在

cgqdlh opened this issue · comments

➜  ls
index.py  template.yml

➜  cat index.py
# -*- coding: utf-8 -*-
import logging

# if you open the initializer feature, please implement the initializer function, as below:
# def initializer(context):
#   logger = logging.getLogger()
#   logger.info('initializing')

def handler(event, context):
  logger = logging.getLogger()
  logger.info('hello world')
  return 'hello world'

➜  cat template.yml
ROSTemplateFormatVersion: '2015-09-01'
Transform: 'Aliyun::Serverless-2018-04-03'
Resources:
  py-event:
    Type: 'Aliyun::Serverless::Service'
    Properties:
      Description: 'helloworld'
    py-event:
      Type: 'Aliyun::Serverless::Function'
      Properties:
        Handler: index.handler
        Runtime: python3
        CodeUri: './'

➜  fun --version
3.6.21
➜  fun local invoke py-event/py-event
using template: template.yml
skip pulling image aliyunfc/runtime-python3.6:1.9.13...
cat: /sys/fs/cgroup/memory/memory.limit_in_bytes: No such file or directory
/var/fc/runtime/python3/mock: line 38: / 1024 / 1024: syntax error: operand expected (error token is "/ 1024 / 1024")
/var/fc/runtime/python3/mock: line 40: [: 15716: unary operator expected
FunctionCompute python3 runtime inited.
FC Invoke Start RequestId: e4a83191-3b10-44ef-ac86-4a3d860f084c
2021-04-16T13:54:48.098Z e4a83191-3b10-44ef-ac86-4a3d860f084c [INFO] hello world
FC Invoke End RequestId: e4a83191-3b10-44ef-ac86-4a3d860f084c
hello worldcat: /sys/fs/cgroup/memory/memory.usage_in_bytes: No such file or directory
/var/fc/runtime/python3/mock: line 132: / 1024 / 1024: syntax error: operand expected (error token is "/ 1024 / 1024")


RequestId: e4a83191-3b10-44ef-ac86-4a3d860f084c          Billed Duration: 16 ms          Memory Size:  MB        Max Memory Used:  MB

已经解决

问题原因是我用的archlinux是纯cgroup v2 相关内核文档 而函数计算统计内存使用的是cgroup v1方式

我的电脑由于systemd驱动cgroup,systemd对cgroup支持三种模式查看详情,,设置内核参数改用v1和v2混用模式
systemd.unified_cgroup_hierarchy=no取消仅使用cgroup v2
systemd.legacy_systemd_cgroup_controller取消仅使用cgroup v1