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

Fix DiffEngineResourceState #1391

Merged
merged 1 commit into from Aug 14, 2020
Merged

Conversation

lukebfox
Copy link
Member

@lukebfox lukebfox commented Aug 9, 2020

Following on from the welcome changes in #697 it seems the vpc resources are a bit broken downstream and one of the issues originates here.

DiffEngineResourceState is the base state class for custom resources utilising the new diff engine. When deploying (or planning) a deployment of this type of resource the diff engine gets initialised with

diff_engine = self.setup_diff_engine(config=defn.config)

The issue is that defn.config here is a ResourceOptions subclass instance. Eventually a diff gets constructed with this object when it requires a dict
config: Dict[str, Any],

and chaos soon ensues, causing the following error (nixops-aws vpc example) deploying affected resources.

Traceback (most recent call last):
  File "/home/lukebfox/.cache/pypoetry/virtualenvs/nixops-aws-dVwxRzVJ-py3.7/bin/nixops", line 33, in <module>
    sys.exit(load_entry_point('nixops', 'console_scripts', 'nixops')())
  File "/home/lukebfox/.cache/pypoetry/virtualenvs/nixops-aws-dVwxRzVJ-py3.7/src/nixops/nixops/__main__.py", line 710, in main
    args.op(args)
  File "/home/lukebfox/.cache/pypoetry/virtualenvs/nixops-aws-dVwxRzVJ-py3.7/src/nixops/nixops/script_defs.py", line 637, in op_deploy
    max_concurrent_activate=args.max_concurrent_activate,
  File "/home/lukebfox/.cache/pypoetry/virtualenvs/nixops-aws-dVwxRzVJ-py3.7/src/nixops/nixops/deployment.py", line 1458, in deploy
    self.run_with_notify("deploy", lambda: self._deploy(**kwargs))
  File "/home/lukebfox/.cache/pypoetry/virtualenvs/nixops-aws-dVwxRzVJ-py3.7/src/nixops/nixops/deployment.py", line 1447, in run_with_notify
    f()
  File "/home/lukebfox/.cache/pypoetry/virtualenvs/nixops-aws-dVwxRzVJ-py3.7/src/nixops/nixops/deployment.py", line 1458, in <lambda>
    self.run_with_notify("deploy", lambda: self._deploy(**kwargs))
  File "/home/lukebfox/.cache/pypoetry/virtualenvs/nixops-aws-dVwxRzVJ-py3.7/src/nixops/nixops/deployment.py", line 1364, in _deploy
    worker_fun=worker,
  File "/home/lukebfox/.cache/pypoetry/virtualenvs/nixops-aws-dVwxRzVJ-py3.7/src/nixops/nixops/parallel.py", line 106, in run_tasks
    raise list(exceptions.values())[0]
  File "/home/lukebfox/.cache/pypoetry/virtualenvs/nixops-aws-dVwxRzVJ-py3.7/src/nixops/nixops/parallel.py", line 70, in thread_fun
    work_result = (worker_fun(t), None, t.name)
  File "/home/lukebfox/.cache/pypoetry/virtualenvs/nixops-aws-dVwxRzVJ-py3.7/src/nixops/nixops/deployment.py", line 1319, in worker
    allow_recreate=allow_recreate,
  File "/home/lukebfox/.cache/pypoetry/virtualenvs/nixops-aws-dVwxRzVJ-py3.7/src/nixops/nixops/resources/__init__.py", line 348, in create
    for handler in diff_engine.plan():
  File "/home/lukebfox/.cache/pypoetry/virtualenvs/nixops-aws-dVwxRzVJ-py3.7/src/nixops/nixops/diff.py", line 99, in plan
    keys = list(self._state.keys()) + list(self._definition.keys())
AttributeError: 'VpcOptions' object has no attribute 'keys'

It's a simple fix, and I'd like to get this merged because I'm using the diff engine in a nixops plugin I am writing for hetzner cloud.
Thanks!

@AmineChikhaoui
Copy link
Member

This might have been introduced with the refactorings following the mypy type checking improvements as iirc defn.config used to be a simple dict before.

@adisbladis adisbladis merged commit 6bed6e7 into NixOS:master Aug 14, 2020
@lukebfox lukebfox deleted the fix-diff-engine branch August 14, 2020 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants