Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Component Names Collide with Jsonnet Libraries #274

Open
srueg opened this issue Jan 6, 2021 · 0 comments
Open

Component Names Collide with Jsonnet Libraries #274

srueg opened this issue Jan 6, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@srueg
Copy link
Contributor

srueg commented Jan 6, 2021

If a component has the same name as a Jsonnet library which is included (by any other component), the paths in vendor/ collide and therefore either the component is not included correctly, or the Jsonnet library can't be used with a relative import. Since kube-prometheus uses relative imports everywhere, it will break if we have a component named grafana.
Jsonnet-bundler just print a warning and skips the colliding symlink:

WARN: cannot link 'github.com/brancz/kubernetes-grafana/grafana' to '/app/data/vendor/grafana', because package '../dependencies/grafana' already uses that name. The absolute import still works

Steps to Reproduce the Problem

  1. Create a component called component-grafana
  2. Compile a cluster which installs a component with a dependency on kube-prometheus (i.e. synsights-metrics)

Actual Behavior

Compilation fails:

Jsonnet error: failed to compile /app/data/vendor/spks-monitoring/component/main.jsonnet:
 RUNTIME ERROR: couldn't open import "grafana/grafana.libsonnet": [Errno 2] No such file or directory: '/app/data/vendor/kube-prometheus/grafana/grafana.libsonnet'
	/app/data/vendor/kube-prometheus/kube-prometheus.libsonnet:5:2-36	thunk <import>
	/app/data/vendor/spks-monitoring/component/rules.libsonnet:62:4-54	thunk <kp>
	/app/data/vendor/spks-monitoring/component/rules.libsonnet:88:31-33	object <anonymous>
	During manifestation

Expected Behavior

The compilation is successful.

Ideas

  1. Forbid using component names which collide with library names.
    Leads to bad UX and might break in the future if new libraries are included.
  2. Prefix all components in vendor/ with component-.
    Would require to change the compile input_paths of all components. We could introduce a helper variable like parameters._component (analog to `_instance) to make it easier.
    Benefit: the names would match the actual git repo names.
  3. Always use absolute imports in Jsonnet.
    Might not be possible to control in upstream projects (i.e. kube-prometheus).
@srueg srueg added the bug Something isn't working label Jan 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant