bazelbuild / rules_k8s

This repository contains rules for interacting with Kubernetes configurations / clusters.
Apache License 2.0
291 stars 136 forks source link

.apply target returns exit code 1 #666

Open dkryptr opened 3 years ago

dkryptr commented 3 years ago

Our automated deploy pipeline checks the exit code of our bazel run deploy commands to confirm if the deploy succeeded. When upgrading from 0.4 to 0.6 we noticed our deploy stage failing. We tested versions 0.4, 0.5 and 0.6. This is a regression in versions 0.5 and 0.6. They return exit code 1 when the command appears to succeed.

Here's an example BUILD file followed by the commands I used to test:

BUILD file

py3_image(
    name = "docker_image",
    srcs = glob(["*.py"]),
    base = "@python_3_8//image",
    main = "main.py",
    deps = [
        requirement("boto3"),
    ],
)

k8s_object(
    name = "k8s_deploy",
    cluster = "cluster",
    images = {
        "image:{BUILD_TIMESTAMP}": "//path/to/docker/target:docker_image",
    },
    kind = "deployment",
    substitutions = {
        "%(BUILD_TIMESTAMP)": "{BUILD_TIMESTAMP}",
    },
    template = ":deployment.yaml",
)

With version 0.4 of the rules:

bazel run //path/to/target:k8s_deploy.apply
echo $?
# 0

With version 0.5 and 0.6 of the rules:

bazel run //path/to/target:k8s_deploy.apply
echo $?
# 1