Open Adam-D-Lewis opened 1 year ago
The error indicates that the user wasn't found, which is expected, but NWC assumes that the "workflows.argoproj.io/creator-preferred-username" is set on the workflow which it seems is not the case. At a minimum, we should check if that label is there and return a better error message if not. However, NWC should support workflows being submitted via Hera so that needs to be corrected. I can't access the NWC logs to see what NWC is getting passed as an input however (Argo Workflows adds some labels so I want to see the workflow after that happens before I can debug).
Workaround for the time being is to disable Nebari Workflow Controller in the nebari config yaml.
argo_workflows:
enabled: true
nebari_workflow_controller:
enabled: false
I've confirmed that the error goes away and hera/argo is functional after disabling NWC
As I see it, there are at least three ways ways of submitting Argo-Workflows now:
Submitting workflows via Hera-Workflows has always required the user to copy and paste their ARGO_TOKEN
from the Argo UI. The difference now is that the user's JupyterLab server already has an ARGO_TOKEN
set based on which keycloak group they are a member of (analyst
, developer
, admin
). The "default" ARGO_TOKEN
needs to be replaced by your personal ARGO_TOKEN
and things should work:
import os
from urllib.parse import urljoin
from hera.workflows import Workflow, script
from hera.shared import global_config
def authenticate():
namespace = os.environ["ARGO_NAMESPACE"]
if not namespace:
namespace = "dev"
token = "Bearer v2:ey....." # <-- copied from Argo UI
if token.startswith("Bearer"):
token = token.split(" ")[-1]
base_href = os.environ["ARGO_BASE_HREF"]
if not base_href.endswith("/"):
base_href += "/"
server = f"https://{os.environ['ARGO_SERVER']}"
host = urljoin(server, base_href)
global_config.host = host
global_config.token = token
global_config.namespace = namespace
return global_config
authenticate()
with Workflow(
generate_name="hello-world-",
entrypoint="hello",
arguments={"s": "world"},
) as w:
hello()
w.create()
One workaround that doesn't require you to copy over your ARGO_TOKEN
would be explicitly set your creator-preferred-username
label on the workflow as follows:
import os
from urllib.parse import urljoin
from hera.workflows import Workflow, script
from hera.shared import global_config
def sanitize_label(s: str) -> str:
s = s.lower()
pattern = r"[^A-Za-z0-9]"
return re.sub(pattern, lambda x: "-" + hex(ord(x.group()))[2:], s)
def authenticate():
namespace = os.environ["ARGO_NAMESPACE"]
if not namespace:
namespace = "dev"
token = os.environ["ARGO_TOKEN"]
if token.startswith("Bearer"):
token = token.split(" ")[-1]
base_href = os.environ["ARGO_BASE_HREF"]
if not base_href.endswith("/"):
base_href += "/"
server = f"https://{os.environ['ARGO_SERVER']}"
host = urljoin(server, base_href)
global_config.host = host
global_config.token = token
global_config.namespace = namespace
return global_config
authenticate()
labels = {
"workflows.argoproj.io/creator-preferred-username": sanitize_label("eeriksen@quansight.com")
}
with Workflow(
generate_name="hello-world-",
entrypoint="hello",
arguments={"s": "world"},
labels=labels,
) as w:
hello()
w.create()
The long-term solution is to generate personalized Argo tokens for each user and add them to as env vars on the user's JupyterLab pod. This has been captured in this issue.
One workaround that doesn't require you to copy over your ARGO_TOKEN would be explicitly set your creator-preferred-username label on the workflow as follows:
Allowing users to set their own creator-preferred-username is a vulnerability since now users can claim to be any user they want and have those files mounted. I'll open an issue to correct that.
The following script throws an error.
The error thrown is
Unwrangling hera a bit via
shows me that what is submitted is