Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions core-services/_hack/validate-core-services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ function validate_required_files() {
for required in OWNERS README.md; do
local required_path="$service_path/$required"
if [[ ! -s "$required_path" ]]; then
echo "[ERROR] $required file not found: $required_path"
echo "[ERROR] All core services should have $required file"
echo "ERROR: $required file not found: $required_path"
echo "ERROR: All core services should have $required file"
return 1
fi
done
Expand All @@ -19,7 +19,7 @@ function validate_required_files() {

to_validate="$1"
if [[ ! -d "$to_validate" ]]; then
echo "[ERROR] Directory not found: $to_validate"
echo "ERROR: Directory not found: $to_validate"
echo "Usage: validate-core-services.sh DIRECTORY"
exit 1
fi
Expand Down
8 changes: 4 additions & 4 deletions hack/validate-ci-operator-config-filename.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,24 @@ def main():
errors = []

if not os.path.isdir(args.config_dir):
errors.append(f"[ERROR] {args.config_dir} directory doesn't exist.")
errors.append(f"ERROR: {args.config_dir} directory doesn't exist.")

for root, _, files in os.walk(args.config_dir):
for name in files:
if name.endswith(".yml"):
print(f"[ERROR] Only .yaml extensions are allowed, not .yml as in {root_path}/{name}")
print(f"ERROR: Only .yaml extensions are allowed, not .yml as in {root_path}/{name}")
sys.exit(1)
if name.endswith(".yaml"):
root_path = os.path.relpath(root, args.config_dir)
filename, _ = os.path.splitext(name)
try:
org, repo = os.path.split(root_path)
except ValueError:
print(f"[ERROR] Folder structure is not in $config_dir/$org/$repo/ format for file {root_path}/{name}")
print(f"ERROR: Folder structure is not in $config_dir/$org/$repo/ format for file {root_path}/{name}")
sys.exit(1)

if not filename.startswith(f"{org}-{repo}-"):
errors.append(f"[ERROR] File '{args.config_dir}/{root}/{name}' name should have '{org}-{repo}-$branch.yaml' format")
errors.append(f"ERROR: File '{args.config_dir}/{root}/{name}' name should have '{org}-{repo}-$branch.yaml' format")

if errors:
print("\n".join(errors))
Expand Down
8 changes: 4 additions & 4 deletions hack/validate-config-sharding.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ base_dir="$( dirname "${BASH_SOURCE[0]}" )/../"

if ! config-shard-validator --release-repo-dir="${base_dir}" > "${workdir}/output" 2>&1; then
cat << EOF
[ERROR] This check enforces that configuration YAML files will be uploaded automatically
[ERROR] as they change. You are adding a file that is not covered by the automatic upload.
[ERROR] Contact an administrator to resolve this issue.
ERROR: This check enforces that configuration YAML files will be uploaded automatically
ERROR: as they change. You are adding a file that is not covered by the automatic upload.
ERROR: Contact an administrator to resolve this issue.

[ERROR] The following errors were found:
ERROR: The following errors were found:

EOF
cat "${workdir}/output"
Expand Down
12 changes: 6 additions & 6 deletions hack/validate-generated-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ ci-operator-prowgen --from-dir "${ci_operator_dir}/config" --to-dir "${workdir}/

if ! diff -Naupr "${ci_operator_dir}/jobs/" "${workdir}/ci-operator/jobs/"> "${workdir}/diff"; then
cat << EOF
[ERROR] This check enforces that Prow Job configuration YAML files are generated
[ERROR] correctly. We have automation in place that generates these configs and
[ERROR] new changes to these job configurations should occur from a re-generation.
ERROR: This check enforces that Prow Job configuration YAML files are generated
ERROR: correctly. We have automation in place that generates these configs and
ERROR: new changes to these job configurations should occur from a re-generation.

[ERROR] Run the following command to re-generate the Prow jobs:
[ERROR] $ docker run -it -v \$(pwd)/ci-operator:/ci-operator:z registry.svc.ci.openshift.org/ci/ci-operator-prowgen:latest --from-dir /ci-operator/config/ --to-dir /ci-operator/jobs
ERROR: Run the following command to re-generate the Prow jobs:
ERROR: $ docker run -it -v \$(pwd)/ci-operator:/ci-operator:z registry.svc.ci.openshift.org/ci/ci-operator-prowgen:latest --from-dir /ci-operator/config/ --to-dir /ci-operator/jobs

[ERROR] The following errors were found:
ERROR: The following errors were found:

EOF
cat "${workdir}/diff"
Expand Down
28 changes: 14 additions & 14 deletions hack/validate-owners.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ false_pos=$(comm -23 <(echo "$WHITELIST") <(echo "$no_owners"))

if [[ "$false_neg" ]]; then
cat << EOF
[ERROR] This check enforces that component configuration files are accompanied by OWNERS
[ERROR] files so that the appropriate team is able to self-service further configuration
[ERROR] change pull requests.
ERROR: This check enforces that component configuration files are accompanied by OWNERS
ERROR: files so that the appropriate team is able to self-service further configuration
ERROR: change pull requests.

[ERROR] Run the following script to fetch OWNERS files from the component repositories:
ERROR: Run the following script to fetch OWNERS files from the component repositories:

[ERROR] $ ci-operator/populate-owners.sh
ERROR: $ ci-operator/populate-owners.sh

[ERROR] Please note that the script populates *all* ci-operator subdirectories, and it
[ERROR] takes a long time to execute (tens of minutes). If the target repository does not
[ERROR] contain an OWNERS file, it will need to be created manually.
ERROR: Please note that the script populates *all* ci-operator subdirectories, and it
ERROR: takes a long time to execute (tens of minutes). If the target repository does not
ERROR: contain an OWNERS file, it will need to be created manually.

[ERROR] The following component config directories do not have OWNERS files:
ERROR: The following component config directories do not have OWNERS files:

$false_neg

Expand All @@ -46,12 +46,12 @@ fi

if [[ "$false_pos" ]]; then
cat << EOF
[ERROR] Directory that was previously whitelisted as not containing
[ERROR] an OWNERS file is now containing the file, so it no longer
[ERROR] needs to be whitelisted. Please remove the appropriate line
[ERROR] from hack/validate-owners.sh script.
ERROR: Directory that was previously whitelisted as not containing
ERROR: an OWNERS file is now containing the file, so it no longer
ERROR: needs to be whitelisted. Please remove the appropriate line
ERROR: from hack/validate-owners.sh script.

[ERROR] Directories to be removed from whitelist:
ERROR: Directories to be removed from whitelist:

$false_pos
EOF
Expand Down
12 changes: 6 additions & 6 deletions hack/validate-prow-job-ordering.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ cp -r "${jobs_dir}" "${workdir}"

if ! diff -Naupr -I '^[[:space:]]*#.*' "${workdir}/jobs" "${jobs_dir}"> "${workdir}/diff"; then
cat << EOF
[ERROR] This check enforces Prow Job configuration YAML file format (ordering,
[ERROR] linebreaks, indentation) to be consistent over the whole repository. We have
[ERROR] automation in place that manipulates these configs and consistent formatting
ERROR: This check enforces Prow Job configuration YAML file format (ordering,
ERROR: linebreaks, indentation) to be consistent over the whole repository. We have
ERROR: automation in place that manipulates these configs and consistent formatting
[ERORR] helps reviewing the changes the automation does.

[ERROR] Run the following command to re-format the Prow jobs:
[ERROR] $ docker run -it -v \$(pwd)/ci-operator/jobs:/jobs:z registry.svc.ci.openshift.org/ci/determinize-prow-jobs:latest --prow-jobs-dir /jobs
ERROR: Run the following command to re-format the Prow jobs:
ERROR: $ docker run -it -v \$(pwd)/ci-operator/jobs:/jobs:z registry.svc.ci.openshift.org/ci/determinize-prow-jobs:latest --prow-jobs-dir /jobs

[ERROR] The following errors were found:
ERROR: The following errors were found:

EOF
cat "${workdir}/diff"
Expand Down
40 changes: 20 additions & 20 deletions hack/validate-prow-job-semantics.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def main():
for root, _, files in os.walk(JOBS_DIR):
for filename in files:
if filename.endswith(".yml"):
print(f"[ERROR] Only .yaml extensions are allowed, not .yml as in {root}/{filename}")
print(f"ERROR: Only .yaml extensions are allowed, not .yml as in {root}/{filename}")
failed = True
if not filename.endswith('.yaml'):
continue
Expand All @@ -41,24 +41,24 @@ def validate_filename(path):
org_dir, repo_dir = parse_org_repo(path)
base = os.path.basename(path)
if not base.startswith("{}-{}-".format(org_dir, repo_dir)):
print("[ERROR] {}: expected filename to start with {}-{}".format(path, org_dir, repo_dir))
print("ERROR: {}: expected filename to start with {}-{}".format(path, org_dir, repo_dir))
return False

job_type = base[base.rfind("-")+1:-len(".yaml")]
if job_type not in ["periodics", "postsubmits", "presubmits"]:
print("[ERROR] {}: expected filename to end with a job type".format(path))
print("ERROR: {}: expected filename to end with a job type".format(path))
return False

if job_type == "periodics":
branch = base[len("{}-{}-".format(org_dir, repo_dir)):-len("-{}.yaml".format(job_type))]
if branch == "":
if base != "{}-{}-{}.yaml".format(org_dir, repo_dir, job_type):
print("[ERROR] {}: Invalid formatting in filename: expected filename format $org-$repo-periodics.yaml".format(path))
print("ERROR: {}: Invalid formatting in filename: expected filename format $org-$repo-periodics.yaml".format(path))
return False
else:
branch = base[len("{}-{}-".format(org_dir, repo_dir)):-len("-{}.yaml".format(job_type))]
if branch == "":
print("[ERROR] {}: Invalid formatting in filename: expected filename format org-repo-branch-(pre|post)submits.yaml".format(path))
print("ERROR: {}: Invalid formatting in filename: expected filename format org-repo-branch-(pre|post)submits.yaml".format(path))
return False

return True
Expand All @@ -67,13 +67,13 @@ def validate_file_structure(path):
with open(path) as f:
data = yaml.load(f)
if len(data) != 1:
print("[ERROR] {}: file contains more than one type of job".format(path))
print("ERROR: {}: file contains more than one type of job".format(path))
return False
if next(iter(data.keys())) == 'periodics':
return True
data = next(iter(data.values()))
if len(data) != 1:
print("[ERROR] {}: file contains jobs for more than one repo".format(path))
print("ERROR: {}: file contains jobs for more than one repo".format(path))
return False

return True
Expand All @@ -83,12 +83,12 @@ def validate_job_repo(path, data):
if "presubmits" in data:
for org_repo in data["presubmits"]:
if org_repo != "{}/{}".format(org, repo):
print("[ERROR] {}: file defines jobs for {}, but is only allowed to contain jobs for {}/{}".format(path, org_repo, org, repo))
print("ERROR: {}: file defines jobs for {}, but is only allowed to contain jobs for {}/{}".format(path, org_repo, org, repo))
return False
if "postsubmits" in data:
for org_repo in data["postsubmits"]:
if org_repo != "{}/{}".format(org, repo):
print("[ERROR] {}: file defines jobs for {}, but is only allowed to contain jobs for {}/{}".format(path, org_repo, org, repo))
print("ERROR: {}: file defines jobs for {}, but is only allowed to contain jobs for {}/{}".format(path, org_repo, org, repo))
return False

return True
Expand Down Expand Up @@ -128,7 +128,7 @@ def validate_names(path, data):
if "branches" in job:
for branch_name in job["branches"]:
if "_" in branch_name:
print("[ERROR] {}: job {} branches with underscores are not allowed: {}".format(path, job["name"], branch_name))
print("ERROR: {}: job {} branches with underscores are not allowed: {}".format(path, job["name"], branch_name))
branch = make_regex_filename_label(job["branches"][0])

prefix = "pull"
Expand All @@ -142,23 +142,23 @@ def validate_names(path, data):

valid_name = "{}-ci-{}-{}-{}".format(prefix, repo.replace("/", "-"), branch, target)
if job["name"] != valid_name:
print("[ERROR] {}: ci-operator job {} should be named {}".format(path, job["name"], valid_name))
print("ERROR: {}: ci-operator job {} should be named {}".format(path, job["name"], valid_name))
out = False

if job_type == "presubmits":
valid_context = "ci/prow/{}".format(target)
if job["context"] != valid_context:
print("[ERROR] {}: ci-operator job {} should have context {}".format(path, job["name"], valid_context))
print("ERROR: {}: ci-operator job {} should have context {}".format(path, job["name"], valid_context))
out = False

valid_rerun_command = "/test {}".format(target)
if job["rerun_command"] != valid_rerun_command:
print("[ERROR] {}: ci-operator job {} should have rerun_command {}".format(path, job["name"], valid_rerun_command))
print("ERROR: {}: ci-operator job {} should have rerun_command {}".format(path, job["name"], valid_rerun_command))
out = False

valid_trigger = r"(?m)^/test( | .* ){},?($|\s.*)".format(target)
if job["trigger"] != valid_trigger:
print("[ERROR] {}: ci-operator job {} should have trigger {}".format(path, job["name"], valid_trigger))
print("ERROR: {}: ci-operator job {} should have trigger {}".format(path, job["name"], valid_trigger))
out = False

return out
Expand All @@ -182,7 +182,7 @@ def validate_sharding(path, data):

file_branch = os.path.basename(path)[len("{}-".format(repo.replace("/", "-"))):-len("-{}.yaml".format(job_type))]
if file_branch != branch:
print("[ERROR] {}: job {} runs on branch {}, not {} so it should be in file {}".format(path, job["name"], branch, file_branch, path.replace(file_branch, branch)))
print("ERROR: {}: job {} runs on branch {}, not {} so it should be in file {}".format(path, job["name"], branch, file_branch, path.replace(file_branch, branch)))
out = False

return out
Expand All @@ -199,7 +199,7 @@ def validate_pod_name(path, data):
continue

if job["spec"]["containers"][0]["name"] != "":
print("[ERROR] {}: ci-operator job {} should not set a pod name".format(path, job["name"]))
print("ERROR: {}: ci-operator job {} should not set a pod name".format(path, job["name"]))
out = False
continue

Expand Down Expand Up @@ -235,7 +235,7 @@ def validate_ci_op_args(path, data):
found = True

if not found:
print("[ERROR] {}: job {} needs to set the {} flag for ci-operator".format(path, job["name"], needed_arg))
print("ERROR: {}: job {} needs to set the {} flag for ci-operator".format(path, job["name"], needed_arg))
out = False

return out
Expand All @@ -252,7 +252,7 @@ def validate_image_pull(path, data):
continue

if job["spec"]["containers"][0]["imagePullPolicy"] != "Always":
print("[ERROR] {}: ci-operator job {} should set the pod's image pull policy to always".format(path, job["name"]))
print("ERROR: {}: ci-operator job {} should set the pod's image pull policy to always".format(path, job["name"]))
out = False
continue

Expand All @@ -277,11 +277,11 @@ def validate_resources(path, data):
bad_ci_op_resources = resources != {"requests": {"cpu": "10m"}}
null_cpu_request = resources.get("requests", {}).get("cpu", "") == ""
if ci_op_job and bad_ci_op_resources:
print("[ERROR] {}: ci-operator job {} should set the pod's CPU requests and limits to {}".format(path, job["name"], resources))
print("ERROR: {}: ci-operator job {} should set the pod's CPU requests and limits to {}".format(path, job["name"], resources))
out = False
continue
elif null_cpu_request:
print("[ERROR] {}: ci-operator job {} should set the pod's CPU requests".format(path, job["name"]))
print("ERROR: {}: ci-operator job {} should set the pod's CPU requests".format(path, job["name"]))
out = False
continue

Expand Down
4 changes: 2 additions & 2 deletions tools/applyconfig/applyconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ func apply(path, user string, dry bool) error {
cmd := exec.Command("oc", args...)
if output, err := cmd.CombinedOutput(); err != nil {
if _, ok := err.(*exec.ExitError); ok {
fmt.Printf("[ERROR] oc %s: failed to apply\n%s\n", strings.Join(args, " "), string(output))
fmt.Printf("ERROR: oc %s: failed to apply\n%s\n", strings.Join(args, " "), string(output))
} else {
fmt.Printf("[ERROR] oc %s: failed to execute: %v\n", strings.Join(args, " "), err)
fmt.Printf("ERROR: oc %s: failed to execute: %v\n", strings.Join(args, " "), err)
}
return fmt.Errorf("failed to apply config")
}
Expand Down