Skip to content

Commit

Permalink
Fix periodic runs of tekton workflows. (kubeflow#697)
Browse files Browse the repository at this point in the history
* Fix periodic runs of tekton workflows.

* Periodic runs aren't associated with a repository/commit; so we shouldn't
  try to substitute into the pipelineruns.

* Add exception handling so we keep going if a workflow has an exception.

* Fix: kubeflow#696

* Fix some whitespace in apps-cd/README.md
  • Loading branch information
jlewi authored Jun 19, 2020
1 parent 6a87346 commit ae1798a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 26 deletions.
1 change: 0 additions & 1 deletion apps-cd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ This is a Kubeflow cluster (v0.6.2) and we rely on that to configure certain thi

```
kustomize build pipelines/overlays/prod | kubectl --context=kf-releasing apply -f -
```
## Developer Guide

Expand Down
23 changes: 15 additions & 8 deletions py/kubeflow/testing/run_e2e_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import uuid
import subprocess
import sys
import traceback
import yaml

# The name of the command line argument for workflows for the var
Expand Down Expand Up @@ -372,14 +373,20 @@ def run(args, file_handler): # pylint: disable=too-many-statements,too-many-bran
else:
pull_revision = "master"
logging.info("Adding Tekton pipeline %s", w.name)
pipeline_runner = tekton_client.PipelineRunner(
w.tekton_params,
w.kwargs.get(TEST_TARGET_ARG_NAME, w.name),
w.tekton_run,
args.bucket,
repo_owner,
repo_name,
pull_revision)
try:
pipeline_runner = tekton_client.PipelineRunner(
w.tekton_params,
w.kwargs.get(TEST_TARGET_ARG_NAME, w.name),
w.tekton_run,
args.bucket,
repo_owner,
repo_name,
pull_revision)
except (FileNotFoundError, ValueError) as e:
logging.error("Error when starting Tekton workflow:%s\n Exception %s;\n"
"stacktrace:\n%s",
w.tekton_run, e, traceback.format_exc())
continue
if w.tekton_teardown:
logging.info("Appending teardown process for Tekton pipeline %s",
w.name)
Expand Down
41 changes: 24 additions & 17 deletions py/kubeflow/testing/tekton_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def get_namespaced_custom_object_with_retries(namespace, name):
# and GCS path when running multiple workflows from the same prow test.
# Can this be done in the Pipeline and Task resources by appending
# unique subdirectories to the paths?
def load_tekton_run(params, test_target_name, tekton_run,
def load_tekton_run(params, test_target_name, tekton_run, # pylint: disable=too-many-branches
bucket, repo_owner, repo_under_test, pull_revision):
"""Load Tekton configs and override information from Prow.
Args:
Expand Down Expand Up @@ -179,22 +179,29 @@ def load_tekton_run(params, test_target_name, tekton_run,
{"name": "url", "value": repo_url},
{"name": "revision", "value": pull_revision},
]
foundRepo = False
for resource in config["spec"].get("resources", []):
if resource.get("resourceSpec", {}).get("type", "") != "git":
pass
for param in resource.get("resourceSpec", {}).get("params", []):
if param.get("name", "") != "url":
continue
if param.get("value", "") == repo_url:
foundRepo = True
resource["resourceSpec"]["params"] = replacing_param
break
if not foundRepo:
raise ValueError(("The TektonPipelineRun is missing a pipeline git "
"resource that matches the repo being tested by "
"prow. The pipeline parameters must include "
"a git resource whose URL is {0}".format(repo_url)))

job_type = os.getenv("JOB_TYPE", "").lower()

if job_type in ["presubmit", "postsubmit"]:
logging.info("Job is type %s; looking for url %s", job_type, repo_url)
foundRepo = False
for resource in config["spec"].get("resources", []):
if resource.get("resourceSpec", {}).get("type", "") != "git":
pass
for param in resource.get("resourceSpec", {}).get("params", []):
if param.get("name", "") != "url":
continue
if param.get("value", "") == repo_url:
foundRepo = True
resource["resourceSpec"]["params"] = replacing_param
break
if not foundRepo:
raise ValueError(("The TektonPipelineRun is missing a pipeline git "
"resource that matches the repo being tested by "
"prow. The pipeline parameters must include "
"a git resource whose URL is {0}".format(repo_url)))
else:
logging.info("Job is type %s; not looking for repo", job_type)

return config

Expand Down

0 comments on commit ae1798a

Please sign in to comment.