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

Allow kadet inventory function to return a lazy inventory #848

Open
ramaro opened this issue Sep 8, 2022 · 4 comments
Open

Allow kadet inventory function to return a lazy inventory #848

ramaro opened this issue Sep 8, 2022 · 4 comments
Assignees
Labels
enhancement enhancement to an existing feature Stale

Comments

@ramaro
Copy link
Member

ramaro commented Sep 8, 2022

Since the move to the external kadet package, the default inventory function is now strict e.g. if an attribute key is not found the root, it will raise KeyError.
This brings back the original 'lazy' behavior by allowing to call inventory(lazy=True) in the kadet input type

@ramaro ramaro added the enhancement enhancement to an existing feature label Sep 8, 2022
@ramaro ramaro self-assigned this Sep 8, 2022
@Moep90
Copy link
Contributor

Moep90 commented Sep 9, 2022

Using 0.31.0rc0 I now get

My adoption can be found here: Moep90/kapitan-reference@0fb8bab

$ kapitan compile
Rendered inventory (0.25s)
Unknown (Non-Kapitan) Error occurred
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/home/linuxbrew/.linuxbrew/opt/python@3.7/lib/python3.7/multiprocessing/pool.py", line 121, in worker
    result = (True, func(*args, **kwds))
  File "/home/danny/.env3_kapitan/lib/python3.7/site-packages/kapitan-0.31.0rc0-py3.7.egg/kapitan/targets.py", line 466, in compile_target
    input_compiler.compile_obj(comp_obj, ext_vars, **kwargs)
  File "/home/danny/.env3_kapitan/lib/python3.7/site-packages/kapitan-0.31.0rc0-py3.7.egg/kapitan/inputs/base.py", line 56, in compile_obj
    self.compile_input_path(input_path, comp_obj, ext_vars, **kwargs)
  File "/home/danny/.env3_kapitan/lib/python3.7/site-packages/kapitan-0.31.0rc0-py3.7.egg/kapitan/inputs/base.py", line 78, in compile_input_path
    **kwargs,
  File "/home/danny/.env3_kapitan/lib/python3.7/site-packages/kapitan-0.31.0rc0-py3.7.egg/kapitan/inputs/kadet.py", line 129, in compile_file
    output_obj = kadet_module.main(input_params)
  File "/home/danny/github-repos/kapitan-reference/components/generators/kubernetes/__init__.py", line 1402, in main
    return globals()[function](input_params)
  File "/home/danny/github-repos/kapitan-reference/components/generators/kubernetes/__init__.py", line 1386, in generate_manifests
    component_manifests = generate_component_manifests(input_params)
  File "/home/danny/github-repos/kapitan-reference/components/generators/kubernetes/__init__.py", line 1267, in generate_component_manifests
    workload = Workload(name=name, component=component)
  File "/home/danny/.env3_kapitan/lib/python3.7/site-packages/kadet/__init__.py", line 44, in __init__
    self.body()
  File "/home/danny/github-repos/kapitan-reference/components/generators/kubernetes/__init__.py", line 755, in body
    workload.add_volume_claims(component.volume_claims)
  File "/home/danny/github-repos/kapitan-reference/components/generators/kubernetes/__init__.py", line 54, in add_volume_claims
    self.root.spec.volumeClaimTemplates += [value]
  File "box/box.py", line 286, in box.box.Box.__iadd__
box.exceptions.BoxTypeError: Box can only merge two boxes or a box and a dictionary.
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/danny/.env3_kapitan/lib/python3.7/site-packages/kapitan-0.31.0rc0-py3.7.egg/kapitan/targets.py", line 134, in compile_targets
    [p.get() for p in pool.imap_unordered(worker, target_objs) if p]
  File "/home/danny/.env3_kapitan/lib/python3.7/site-packages/kapitan-0.31.0rc0-py3.7.egg/kapitan/targets.py", line 134, in <listcomp>
    [p.get() for p in pool.imap_unordered(worker, target_objs) if p]
  File "/home/linuxbrew/.linuxbrew/opt/python@3.7/lib/python3.7/multiprocessing/pool.py", line 748, in next
    raise value
box.exceptions.BoxTypeError: Box can only merge two boxes or a box and a dictionary.


Box can only merge two boxes or a box and a dictionary.

@ramaro
Copy link
Member Author

ramaro commented Sep 9, 2022

@Moep90 is this using a particular version of generators?

@Moep90
Copy link
Contributor

Moep90 commented Sep 16, 2022

From my perspective it can be resolved.

Inventory is still more strict. But in a fair amount I guess.
Actions for kapitan-reference can be found here:
kapicorp/kapitan-reference#127 --> Still not finished but this is just an effort question.

@github-actions
Copy link

github-actions bot commented Oct 5, 2023

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement enhancement to an existing feature Stale
Projects
None yet
Development

No branches or pull requests

2 participants