Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to v1beta1 and embedded image #21

Closed
wants to merge 5 commits into from

Conversation

phisco
Copy link
Collaborator

@phisco phisco commented Aug 22, 2023

No description provided.

phisco added 4 commits August 22, 2023 09:48
Signed-off-by: Philippe Scorsolini <[email protected]>
Signed-off-by: Philippe Scorsolini <[email protected]>
Signed-off-by: Philippe Scorsolini <[email protected]>
@phisco
Copy link
Collaborator Author

phisco commented Aug 22, 2023

Currently hitting the following error while trying to run an example image similar to the one described in #1: cannot start spark: [function-runtime-oci spark --max-stdio-bytes=104857600 --image-tar-ball=/function-runtime-oci/function.tgz]: fork/exec /usr/local/bin/function-runtime-oci: invalid argument.
Still need to dig further into the spark run method.

NetworkPolicyRunner NetworkPolicy = "Runner"
// NetworkPolicyIsolated runs the container without network access. The default.
NetworkPolicyIsolated NetworkPolicy = "Isolated"
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can drop all this config, and just rely on the resource limits (and network access) of the "outer" container (i.e. the Kubernetes pod that runs this Function).

Signed-off-by: Philippe Scorsolini <[email protected]>
@phisco
Copy link
Collaborator Author

phisco commented Aug 23, 2023

I added some logs and tried forcing the root user as suggested @negz, but still nothing:

xfn xfn 2023-08-23T11:53:17Z    DEBUG   function-runtime-oci    CAP_SETUID and CAP_SETGID are available
xfn xfn 2023-08-23T11:53:17Z    DEBUG   function-runtime-oci    root UID and GID in function's user namespace   {"uid": 100000, "gid": 100000}
xfn xfn 2023-08-23T11:53:17Z    DEBUG   function-runtime-oci    image tarball copied to cache   {"src": "function.tgz", "path": "/function-runtime-oci-cache/function.tgz"}
xfn xfn 2023-08-23T11:53:17Z    DEBUG   function-runtime-oci    Listening       {"network": "tcp", "address": "0.0.0.0:1234"}
xfn xfn 2023-08-23T11:53:27Z    DEBUG   function-runtime-oci    Running function        {"request": "desired:{composite:{resource:{fields:{key:\"something\"  value:{string_value:\"something\"}}}}}"}
xfn xfn 2023-08-23T11:53:27Z    DEBUG   function-runtime-oci    Running command {"command": "/usr/local/bin/function-runtime-oci spark --max-stdio-bytes=104857600 --image-tar-ball=/function-runtime-oci-cache/function.tgz"}
xfn xfn 2023-08-23T11:53:27Z    DEBUG   function-runtime-oci    Setting UID and GID mappings    {"uid": 100000, "gid": 100000}
xfn xfn 2023-08-23T11:53:27Z    DEBUG   function-runtime-oci    Starting command        {"command": "/usr/local/bin/function-runtime-oci spark --max-stdio-bytes=104857600 --image-tar-ball=/function-runtime-oci-cache/function.tgz"}

And still get:

grpcurl -plaintext -d @ localhost:1234 apiextensions.fn.proto.v1beta1.FunctionRunnerService.RunFunction <<EOM                                                                                                                           66 ↵
{
  "desired": {
    "composite": {
      "resource": {
        "something": "something"
      }
    }
  }
}
EOM
ERROR:
  Code: Unknown
  Message: cannot start spark: [function-runtime-oci spark --max-stdio-bytes=104857600 --image-tar-ball=/function-runtime-oci-cache/function.tgz]: fork/exec /usr/local/bin/function-runtime-oci: invalid argument

I'm currently deploying the following pod and then connecting to it via kubectl port-forward xfn 1234:1234:

apiVersion: v1
kind: Pod
metadata:
  labels:
    run: xfn
  name: xfn
spec:
  containers:
  - image: phisco/function-runtime-oci-example:v0.0.20
    imagePullPolicy: Always
    name: xfn
    args:
    - -d
    ports:
    - containerPort: 1234
    securityContext:
      privileged: true
      runAsUser: 0
    volumeMounts:
    - mountPath: /function-runtime-oci-cache
      name: xfn-cache
  volumes:
  - name: xfn-cache
    emptyDir:
      sizeLimit: 1Gi
  restartPolicy: Always

The image I'm using is built on top of the one from this PR:

ARG VERSION=latest
FROM phisco/function-runtime-oci:${VERSION}
ARG IMAGE_TARBALL

COPY ${IMAGE_TARBALL} /

ENV IMAGE_TARBALL=${IMAGE_TARBALL}
USER root
$ VERSION=v0.0.20; docker build --build-arg IMAGE_TARBALL=function.tgz --build-arg VERSION=${VERSION} -t phisco/function-runtime-oci-example:${VERSION} .

providing as function.tgz the compressed tarball of the image built from:

FROM alpine:3.18
RUN apk add --no-cache jq
ENTRYPOINT ["/bin/sh", "-c", "jq '.desired.composite.resource.labels |= {\"labelizer.xfn.crossplane.io/processed\": \"true\"} + .'"]

@phisco phisco closed this Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants