Hi there- trying to run a kubernetes job with a ve...
# ask-metaflow
a
Hi there- trying to run a kubernetes job with a very simple
helloworld.py
, but it's getting hung up on
Task is starting (Pod is pending, Container is waiting - ContainerCreating)...
. The metaflow-ui is working on my cluster, and I can monitor jobs in the UI. Running the job locally also works. Trying to understand how to debug the k8s setup.
python helloworld.py logs 37/end
shows "No Tasks found at the given path -- either none exist or none have started yet", and I'm not entirely sure what the path is to test that my setup is working properly. I've also tried using the
@kubernetes
decorator, but the results are the same. Any advice?
Copy code
❯ python helloworld.py run --with kubernetes
Metaflow 2.7.12 executing ParameterFlow for user:username
Validating your flow...
    The graph looks good!
Running pylint...
    Pylint is happy!
2023-03-25 07:35:49.938 Workflow starting (run-id 37):
2023-03-25 07:35:50.418 [37/start/68 (pid 2055946)] Task is starting.
2023-03-25 07:35:51.522 [37/start/68 (pid 2055946)] [pod t-2fs2s-p2xjh] Task is starting (Pod is pending)...
2023-03-25 07:36:03.694 [37/start/68 (pid 2055946)] [pod t-2fs2s-p2xjh] Task is starting (Pod is pending, Container is waiting - ContainerCreating)...
2023-03-25 07:37:52.445 [37/start/68 (pid 2055946)] Kubernetes error:
2023-03-25 07:37:52.445 [37/start/68 (pid 2055946)] Error (exit code 1). This could be a transient error. Use @retry to retry.
2023-03-25 07:37:52.587 [37/start/68 (pid 2055946)] 
2023-03-25 07:37:54.148 [37/start/68 (pid 2055946)] Task failed.
2023-03-25 07:37:54.558 Workflow failed.
2023-03-25 07:37:54.558 Terminating 0 active tasks...
2023-03-25 07:37:54.558 Flushing logs...
    Step failure:
    Step start (task-id 68) failed.
helloworld.py
Copy code
from metaflow import FlowSpec, step


class HelloFlow(FlowSpec):
    """
    A flow where Metaflow prints 'Hi'.
    Run this flow to validate that Metaflow is installed correctly.
    """

    @step
    def start(self):
        print("HelloFlow is starting.")
        self.next(self.hello)

    @step
    def hello(self):
        print("Metaflow says: Hi!")
        self.next(self.end)

    @step
    def end(self):
        print("HelloFlow is all done.")


if __name__ == "__main__":
    HelloFlow()
1
u
Can you check 37/start?
a
Same thing
Copy code
python hello.py logs 37/start
Metaflow 2.7.12 executing HelloFlow for user:username
    Invalid command:
    No Tasks found at the given path -- either none exist or none have started yet

Metaflow 2.7.12 executing HelloFlow for user:username
    Invalid command:
    No Tasks found at the given path -- either none exist or none have started yet
u
Easiest way to debug would be to inspect the pod directly (
t-2fs2s-p2xjh
)
u
e.g.
kubectl get pods --all-namespaces | grep t-2fs2s-p2xjh
This will let you know the k8s namespace
u
then
kubectl describe pod -n NAMESPACE
,
kubectl logs t-2fs2s-p2xjh -n NAMESPACE
, etc
a
Ah, ok - so it looks like it it doesn't like my S3 credentials?
Copy code
❯ kubectl logs t-2fs2s-p2xjh -n metaflow
Setting up task environment.
Downloading code package...
fatal error: Unable to locate credentials
Downloading code package...
fatal error: Unable to locate credentials
Downloading code package...
fatal error: Unable to locate credentials
Downloading code package...
fatal error: Unable to locate credentials
Downloading code package...
fatal error: Unable to locate credentials
Downloading code package...
fatal error: Unable to locate credentials
Failed to download code package from <s3://metaflow-sandbox/metaflow/HelloFlow/data/30/3053e0326438eb7ecdde591f9fd6fa6efb822884> after 6 tries. Exiting...
My metaflow config looks like below. We are using a S3 compatible store, but maybe the setup needs to be different for Wasabi?
Copy code
❯ cat /home/username/.metaflowconfig/config.json

{
    "METAFLOW_DEFAULT_METADATA": "service",
    "METAFLOW_KUBERNETES_NAMESPACE": "metaflow",
    "METAFLOW_KUBERNETES_SERVICE_ACCOUNT": "default",
    "METAFLOW_SERVICE_INTERNAL_URL": "<http://metaflow-service.companyname.com>",
    "METAFLOW_SERVICE_URL": "<http://metaflow-service.companyname.com>",
    "METAFLOW_S3_ENDPOINT_URL": "<https://s3.us-west-1.wasabisys.com>",
    "AWS_DEFAULT_REGION": "us-west-1",
    "AWS_ACCESS_KEY_ID": "<ACCESS_KEY_REDACTED>",
    "AWS_SECRET_ACCESS_KEY": "<SECRET_CCESS_KEY_REDACTED>",
    "METAFLOW_DEFAULT_DATASTORE": "s3",
    "METAFLOW_DATASTORE_SYSROOT_S3": "<s3://metaflow-sandbox/metaflow>",
}
Actually I can see data is being logged in the S3 store for each run. This path exists, for example and there are logs.
Copy code
<s3://metaflow-sandbox/metaflow/HelloFlow/37/start/>
u
AWS_SECRET_ACCESS_KEY
in the config json is never propagated to Kubernetes pods. When you first start the job (from local terminal), MF will write some initial bookkeeping info (pre kubernetes job submission). That is what you are seeing in s3. This means that your local env has sufficient perms to write to Wasabi (but it did not come from the config json).
✔️ 1
u
We also need a way for the Kubernetes pods to have perms to access Wasabi.
AWS_ACCESS_KEY_ID
is not propagated from config.json.
u
You can inject adhoc env vars using the
@environment
decorator
a
Alright. I'll take a look at this. Thanks!
Using the decorator worked. Will look into the pod credentials.
u
Recommend looking at https://docs.metaflow.org/api/step-decorators/kubernetes (secrets). You may not even need environment decorator, with that.
👍 1