hostinfo: detect AWS Lambda as a container.
AWS Lambda uses Docker containers but does not have the string "docker" in its /proc/1/cgroup. Infer AWS Lambda via the environment variables it sets. Signed-off-by: Denton Gentry <dgentry@tailscale.com>pull/2123/head
parent
cc6ab0a70f
commit
3c1a73d370
|
@ -62,6 +62,9 @@ func osVersionLinux() string {
|
||||||
if inKnative() {
|
if inKnative() {
|
||||||
attrBuf.WriteString("; env=kn")
|
attrBuf.WriteString("; env=kn")
|
||||||
}
|
}
|
||||||
|
if inAwsLambda() {
|
||||||
|
attrBuf.WriteString("; env=lm")
|
||||||
|
}
|
||||||
attr := attrBuf.String()
|
attr := attrBuf.String()
|
||||||
|
|
||||||
id := m["ID"]
|
id := m["ID"]
|
||||||
|
@ -121,3 +124,14 @@ func inKnative() bool {
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func inAwsLambda() bool {
|
||||||
|
// https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html
|
||||||
|
if os.Getenv("AWS_LAMBDA_FUNCTION_NAME") != "" &&
|
||||||
|
os.Getenv("AWS_LAMBDA_FUNCTION_VERSION") != "" &&
|
||||||
|
os.Getenv("AWS_LAMBDA_INITIALIZATION_TYPE") != "" &&
|
||||||
|
os.Getenv("AWS_LAMBDA_RUNTIME_API") != "" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue