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 parse yaml error with python3.8 #1079

Merged
merged 1 commit into from
Apr 21, 2020

Conversation

Carlangueitor
Copy link
Contributor

Proposed changes

In python 3.8 changing the keys of a dict during iteration of the dict itself can raise RuntimeErrors, specifically I got this error in plan while triying to add a Helm Chart:

  pulumi:pulumi:Stack (monitoring-staging):                                                                                                                                                                      
    error: Program failed with an unhandled exception:                                                                                                                                                           
    error: Traceback (most recent call last):                                                                                                                                                                    
      File "/home/charly/.pulumi/bin/pulumi-language-python-exec", line 85, in <module>                                                                                                                          
        loop.run_until_complete(coro)                                                                                                                                                                            
      File "/usr/lib/python3.8/asyncio/base_events.py", line 612, in run_until_complete                                                                                            
        return future.result()                                                                                                                                                     
      File "/usr/lib/python3.8/site-packages/pulumi/output.py", line 155, in run                                                                                                   
        value = await self._future                                                                                                                                                 
      File "/usr/lib/python3.8/site-packages/pulumi/runtime/stack.py", line 81, in run_in_stack                                                                                    
        await run_pulumi_func(lambda: Stack(func))                                                                                                                                 
      File "/usr/lib/python3.8/site-packages/pulumi/runtime/stack.py", line 50, in run_pulumi_func                                                                                 
        await RPC_MANAGER.rpcs.pop()                                                                                                                                               
      File "/usr/lib/python3.8/site-packages/pulumi/runtime/rpc_manager.py", line 67, in rpc_wrapper                                                                               
        result = await rpc                                                                                                                                                         
      File "/usr/lib/python3.8/site-packages/pulumi/runtime/resource.py", line 440, in do_register_resource_outputs                                                                
        serialized_props = await rpc.serialize_properties(outputs, {})                                                                                                             
      File "/usr/lib/python3.8/site-packages/pulumi/runtime/rpc.py", line 68, in serialize_properties                                                                              
        result = await serialize_property(v, deps, input_transformer)                                                                                                              
      File "/usr/lib/python3.8/site-packages/pulumi/runtime/rpc.py", line 173, in serialize_property                                                                               
        value = await serialize_property(output.future(), deps, input_transformer)                                                                                                 
      File "/usr/lib/python3.8/site-packages/pulumi/runtime/rpc.py", line 159, in serialize_property                                                                               
        future_return = await asyncio.ensure_future(awaitable)                                                                                                                     
      File "/usr/lib/python3.8/site-packages/pulumi/output.py", line 340, in gather_futures                                                                                        
        return await asyncio.gather(*value_futures)                                                                                                                                
      File "/usr/lib/python3.8/site-packages/pulumi/output.py", line 114, in get_value                                                                                             
        val = await self._future                                                                                                                                                   
      File "/usr/lib/python3.8/site-packages/pulumi/output.py", line 186, in run                                                                                                   
        return await transformed.future(with_unknowns=True)                                                                                                                        
      File "/usr/lib/python3.8/site-packages/pulumi/output.py", line 114, in get_value                                                                                             
        val = await self._future                                                                                                                                                   
      File "/usr/lib/python3.8/site-packages/pulumi/output.py", line 114, in get_value                                                                                             
        val = await self._future                                                                                                                                                   
      File "/usr/lib/python3.8/site-packages/pulumi/output.py", line 155, in run                                                                                                   
        value = await self._future                                                                                                                                                 
      File "/usr/lib/python3.8/site-packages/pulumi/output.py", line 176, in run                                                                                                   
        transformed: Input[U] = func(value)                                                                                                                                        
      File "/usr/lib/python3.8/site-packages/pulumi_kubernetes/helm/v2/helm.py", line 362, in <lambda>                                                                             
        lambda objects: _parse_yaml_document(objects, opts, config.transformations))                                                                                               
      File "/usr/lib/python3.8/site-packages/pulumi_kubernetes/yaml.py", line 122, in _parse_yaml_document                                                                         
        file_objects = _parse_yaml_object(obj, opts, transformations, resource_prefix)                                                                                             
      File "/usr/lib/python3.8/site-packages/pulumi_kubernetes/yaml.py", line 177, in _parse_yaml_object
        for key in obj:
    RuntimeError: dictionary keys changed during iteration

A fix for this is iterate over a copy of the keys instead of iterate the dict itself.

Related issues (optional)

@lukehoban lukehoban requested a review from lblackstone April 21, 2020 03:30
Copy link
Member

@lblackstone lblackstone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thanks for the fix!

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.

2 participants