我有 Java 开发背景,而且对 JavaScript/TypeScript 还很陌生。
是否有标准方法来管理和保留 JavaScript/TypeScript 中错误的原因?
我的目的是当我将一个 Error 包装到另一个 Error 中时获得完整的堆栈跟踪;有点像 Java 异常堆栈跟踪:
Message of exception 1
...
Caused by: Message of exception 2
...
Caused by: Message of the root exception
Run Code Online (Sandbox Code Playgroud)
我尝试了这段代码,但err1没有保留以下参考err2:
// CODE
try {
try {
throw new Error("Error no2");
} catch (err2) {
console.log("========================================");
console.log(err2);
throw new Error("Error no1");
}
} catch (err1) {
console.log("========================================");
console.log(err1);
}
Run Code Online (Sandbox Code Playgroud)
// CONSOLE OUTPUT
$ node test.ts
========================================
Error: Error no2
at …Run Code Online (Sandbox Code Playgroud) 我是Kubernetes的新手,正在尝试了解一些安全性知识。
我的问题是关于运行容器的用户的组ID(= gid)。
我使用以下官方示例创建了一个Pod:https : //kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod
apiVersion: v1
kind: Pod
metadata:
name: security-context-demo
spec:
securityContext:
runAsUser: 1000
fsGroup: 2000
volumes:
- name: sec-ctx-vol
emptyDir: {}
containers:
- name: sec-ctx-demo
image: gcr.io/google-samples/node-hello:1.0
volumeMounts:
- name: sec-ctx-vol
mountPath: /data/demo
securityContext:
allowPrivilegeEscalation: false
Run Code Online (Sandbox Code Playgroud)
他们在文档中说:
在配置文件中,runAsUser字段指定对于Pod中的任何容器,第一个进程以用户ID 1000运行。所述 fsGroup字段指定组ID 2000与所有相关 的波德容器。组ID 2000还与/ data / demo上安装的卷以及在该卷中创建的任何文件关联。
因此,我进入了容器:
kubectl exec -it security-context-demo -- sh
Run Code Online (Sandbox Code Playgroud)
我看到第一个进程(即使用PID 1的进程)正在以用户1000 => OK运行,这就是我所期望的行为。
$ ps -f -p 1
UID PID PPID C STIME TTY …Run Code Online (Sandbox Code Playgroud) file-permissions userid security-context user-permissions kubernetes