Isobel Jones
12/01/2021, 11:01 AMFailed to load and execute Flow's environment: AssertionError(None)
. Trying to access private github repo for first time. Have set the github token. Running on gke
flow.storage = GitHub(
repo="Infrastructure/prefect", # name of repo
path="_cfg/server/hello.py", # location of flow file in repo
base_url="<https://github.private-repo.com/>"
)
we are setting the env variable which contains the tokenAnna Geller
Isobel Jones
12/01/2021, 11:09 AM# prefect diagnostics
{
"config_overrides": {},
"env_vars": [
"PREFECT__CONTEXT__SECRETS__GITHUB_ACCESS_TOKEN",
"PREFECT__CLOUD__API",
"PREFECT__BACKEND",
"PREFECT__LOGGING__LEVEL",
"PREFECT__CLOUD__AGENT__AGENT_ADDRESS",
"PREFECT__CLOUD__AGENT__LABELS"
],
"system_information": {
"platform": "Linux-5.4.120+-x86_64-with-debian-11.1",
"prefect_backend": "server",
"prefect_version": "0.15.7",
"python_version": "3.7.12"
}
}
Anna Geller
Anna Geller
from prefect import Flow
from prefect.storage import GitHub
flow = Flow(
"github-flow",
GitHub(
repo="org/repo", # name of repo
path="flows/my_flow.py", # location of flow file in repo
access_token_secret="GITHUB_ACCESS_TOKEN" # name of personal access token secret
)
)
You can see more GitHub examples incl. KubernetesRun here: https://github.com/anna-geller/packaging-prefect-flows/tree/master/flowsLuca Rovinetti
12/01/2021, 11:25 AMaccess_token_secret=
cannot be used. I am going to try to switch to the git storageLuca Rovinetti
12/01/2021, 1:21 PMAnna Geller
Luca Rovinetti
12/01/2021, 1:49 PMAnna Geller
export PREFECT__CLOUD__USE_LOCAL_SECRETS=true
export PREFECT__CONTEXT__SECRETS__GITHUB_ACCESS_TOKEN=xyz
Anna Geller
flow.storage = Git(git_token_secret_name="GITHUB_ACCESS_TOKEN", ...)
Luca Rovinetti
12/01/2021, 2:40 PM- name: PREFECT__CLOUD__USE_LOCAL_SECRETS
value: "true"
- name: PREFECT__CONTEXT__SECRETS__GITHUB_ACCESS_TOKEN
valueFrom:
secretKeyRef:
key: access_token
name: github
it returns
Failed to load and execute Flow's environment: ValueError('Local Secret "GITHUB_ACCESS_TOKEN" was not found.')
I also executed the diagnostics command on the agent container:
prefect diagnostics
{
"config_overrides": {},
"env_vars": [
"PREFECT__CLOUD__API",
"PREFECT__CLOUD__AGENT__LABELS",
"PREFECT__CLOUD__USE_LOCAL_SECRETS",
"PREFECT__CONTEXT__SECRETS__GITHUB_ACCESS_TOKEN",
"PREFECT__CLOUD__AGENT__AGENT_ADDRESS",
"PREFECT__BACKEND"
],
"system_information": {
"platform": "Linux-5.4.120+-x86_64-with-debian-11.1",
"prefect_backend": "server",
"prefect_version": "0.15.7",
"python_version": "3.7.12"
}
}
Luca Rovinetti
12/01/2021, 2:46 PMAnna Geller
Luca Rovinetti
12/01/2021, 2:53 PMflow.storage = Git(
repo="github_org/github_repo_name",
flow_path="_cfg/server/git_storage.py",
repo_host="<http://github.private_domain.com|github.private_domain.com>",
git_token_secret_name="GITHUB_ACCESS_TOKEN"
)
Anna Geller
Luca Rovinetti
12/01/2021, 2:54 PMLuca Rovinetti
12/01/2021, 3:04 PMLuca Rovinetti
12/02/2021, 10:17 AMgithub
)
2. Configure a config map containing the env vars you mentioned ( prefecttoml
) defining the job template:
job.yml: |
apiVersion: batch/v1
kind: Job
spec:
template:
spec:
containers:
- name: flow
env:
- name: PREFECT__CLOUD__USE_LOCAL_SECRETS
value: "true"
- name: PREFECT__CONTEXT__SECRETS__GITHUB_ACCESS_TOKEN
valueFrom:
secretKeyRef:
name: github
key: access_token
3. set the
agent:
jobTemplateFilePath: "/root/.prefect/job.yml"
4. edit the deloyment to mount the config map as volume in the agent container (NOT supported by the helm ):
kubectl get deployments -n prefect prefect-agent -o yaml
...
volumeMounts:
- mountPath: /root/.prefect/
name: config
readOnly: true
...
volumes:
- configMap:
defaultMode: 420
name: prefecttoml
name: config
...
Luca Rovinetti
12/02/2021, 10:32 AMFailed to retrieve task state with error: ClientError([{'message': 'Expected type UUID!, found ""; Could not parse UUID: ', 'locations': [{'line': 2, 'column': 5}], 'path': ['get_or_create_task_run_info'], 'extensions': {'code': 'INTERNAL_SERVER_ERROR', 'exception': {'message': 'Expected type UUID!, found ""; Could not parse UUID: '}}}])
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/prefect/engine/cloud/task_runner.py", line 157, in initialize_run
map_index=context.get("map_index"),
File "/usr/local/lib/python3.7/site-packages/prefect/client/client.py", line 1798, in get_task_run_info
result = self.graphql(mutation) # type: Any
File "/usr/local/lib/python3.7/site-packages/prefect/client/client.py", line 569, in graphql
raise ClientError(result["errors"])
prefect.exceptions.ClientError: [{'message': 'Expected type UUID!, found ""; Could not parse UUID: ', 'locations': [{'line': 2, 'column': 5}], 'path': ['get_or_create_task_run_info'], 'extensions': {'code': 'INTERNAL_SERVER_ERROR', 'exception': {'message': 'Expected type UUID!, found ""; Could not parse UUID: '}}}]
Anna Geller
Luca Rovinetti
12/02/2021, 11:29 AM