bazelbuild / rules_k8s

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

Fix Bazel incompatible changes #248

Open laurentlb opened 5 years ago

laurentlb commented 5 years ago

I'd like to be able to build rules_k8s with --all_incompatible_changes: bazel test --all_incompatible_changes //...

It may not be possible to fix every issue now due to transitive dependencies, but we should try to fix the issues from this repository.

nlopezgi commented 5 years ago

Hi @laurentlb , same as for rules_docker, happy to help you review any PRs you send to fix as many issues as possible in this repo.

terinjokes commented 5 years ago

After fetching the fix from a0bbf543ac0eedec1ec699ca3d9b4e7bf1749aaf, I'm still running into an error when --all_imcompatible_changes is passed:

        File "/home/terin/.cache/bazel/_bazel_terin/2f6659f6d922032bbf4cf20ebfd5ecd5/external/io_bazel_rules_k8s/k8s/object.bzl", line 118, in ctx.runfiles
                list(ctx.attr.resolver.default_runfil...)
type 'depset' is not iterable. Use the `to_list()` method to get a list. Use --incompatible_depset_is_not_iterable=false to temporarily disable this check.

Looks like changing a handful of list(.files) to .files.to_list() resolved this error for me.

laurentlb commented 5 years ago

There are still issues with these flags:

laurentlb commented 5 years ago

We plan to fix some of these flags soon in Bazel.

nlopezgi commented 5 years ago

Thanks for the reminder, we'll schedule to make changes to fix next week.

laurentlb commented 5 years ago

--incompatible_disallow_dict_plus is now enabled in Bazel at head.

smukherj1 commented 5 years ago

Going to work on --incompatible_disallow_dict_plus

smukherj1 commented 5 years ago

I tried to fix as many other issues I could find by trying to update external repositories for incompatible flags other than disallow_dict_plus. It seems some work is going to be needed in rules_grpc to fix some of the other errors. I wasn't able to update com_goole_protobuf because I get

ERROR: /usr/local/google/home/suvanjan/.cache/bazel/_bazel_suvanjan/a1bcb3b63a242c66f0c6010821551247/external/com_google_protobuf/BUILD:632:1: Compiling Java headers external/com_google_protobuf/libprotobuf_java_util-hjar.jar (6 files) failed (Exit 1) turbine_direct.linux failed: error executing command external/bazel_tools/tools/jdk/turbine_direct.linux --output bazel-out/k8-fastbuild/bin/external/com_google_protobuf/libprotobuf_java_util-hjar.jar --output_deps ... (remaining 32 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
external/com_google_protobuf/java/util/src/main/java/com/google/protobuf/util/Durations.java:45: error: symbol not found com.google.errorprone.annotations.CanIgnoreReturnValue
import com.google.errorprone.annotations.CanIgnoreReturnValue;

I was able to fix --incompatible_disallow_dict_plus so I'm going to submit a PR to fix rules_k8s at bazel head

laurentlb commented 5 years ago

From the latest CI run: https://buildkite.com/bazel/bazelisk-plus-incompatible-flags/builds/28#866e8cd5-7e69-46bf-a8d0-4ec6e9188937

Migration is needed for the following flags:

Updating the dependencies should help.

brandjon commented 5 years ago

For --incompatible_remove_old_python_version_api, it looks like despite your recent change to update the declared version of rules_python to bazelbuild/rules_python@965d4b4a63e6462204ae671d7c3f02b25da37941, the actual version that ends up being used is bazelbuild/rules_python@e6399b601e2f72f74e5aa635993d69166784dde1, according to the resolved workspace dump (--experimental_repository_resolved_file=...). There must be another dependency on a project using an older version of rules_python that takes precedence...

(BTW, that change didn't update the date comment on the line.)

brandjon commented 5 years ago

I filed the following issues for fixing some transitive deps to update their dep on rules_python and subpar:

I also sent #289 to workaround these issues for rules_k8s in the meantime.

laurentlb commented 5 years ago

Can you provide an update for --incompatible_depset_is_not_iterable, ---incompatible_depset_union and --incompatible_disable_deprecated_attr_params?

For incompatible_disable_deprecated_attr_params, try to update protobuf to 3.7.1 (like here: https://github.com/bazelbuild/rules_closure/pull/344).

smukherj1 commented 5 years ago

@laurentlb Planning to take a look at this the coming week

nlopezgi commented 5 years ago

incompatible_depset_is_not_iterable fixed in https://github.com/bazelbuild/rules_k8s/pull/301 incompatible_disable_deprecated_attr_params fixed in https://github.com/bazelbuild/rules_k8s/pull/302 incompatible_depset_union @alex1545 double checked and we dont have any longer any code that needs depset union.

laurentlb commented 5 years ago

According to: https://buildkite.com/bazel/bazelisk-plus-incompatible-flags/builds/76#a4fadda7-58b8-4ac7-ab07-7629354f95c2

The command: bazel build --incompatible_depset_union -- ... -//images/gcloud-bazel:gcloud_push -//images/gcloud-bazel:gcloud_installer -//images/gcloud-bazel:gcloud_install -//images/gcloud-bazel:gcloud-layer fails.

The error in jsonnet should disappear by updating the dependencies.

laurentlb commented 5 years ago

It's still failing with --incompatible_depset_union: https://buildkite.com/bazel/bazelisk-plus-incompatible-flags/builds/88#632fb0e6-5a09-4494-b8de-ef76f08a3b1d

ERROR: /var/lib/buildkite-agent/builds/bk-docker-dv7p/bazel-downstream-projects/rules_k8s/examples/hellogrpc/BUILD:77:1: in jsonnet_to_json rule //examples/hellogrpc:deployment:
--
  | Traceback (most recent call last):
  | File "/var/lib/buildkite-agent/builds/bk-docker-dv7p/bazel-downstream-projects/rules_k8s/examples/hellogrpc/BUILD", line 77
  | jsonnet_to_json(name = 'deployment')
  | File "/home/bazel/.cache/bazel/_bazel_bazel/8ca20fbca05d9076804e38817b0a59ca/external/io_bazel_rules_jsonnet/jsonnet/jsonnet.bzl", line 228, in _jsonnet_to_json_impl
  | transitive_data += dep.data_runfiles.files