Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Deadline: instance data overwrite fix #3214

Merged

Conversation

antirotor
Copy link
Member

@antirotor antirotor commented May 19, 2022

Bug description

submission of publishing job to deadline had a serious bug for some quite time: It is creating new instances based on stuff that is being rendered. For this it is using some skeleton data that are part of every newly created instance.

When the instance was being created, it copy() the skeleton data but that is only shallow copy. Anything that was modifying data on newly created instance edited them in skeleton data too, influencing all other newly created instances.

Test case:

from copy import copy


skeleton = {
   "name": "A",
   "families": []
}

new_instance_names = ["B", "C", "D"]

new_instances = []
for new_name in new_instance_names:
    new_instance = copy(skeleton)
    new_instance["name"] = new_name
    if new_name == "C":
        new_instance["families"].append("FOO")
    new_instances.append(new_instance)

for instance in new_instances:
    print(f"{instance['name']}")
    print(f"{instance['families']}")
    print("-" * 10)

This will result in:

B
['FOO']
----------
C
['FOO']
----------
D
['FOO']
----------

All instances have FOO even if we expect ony C instance to have it.

This PR is solving it by changing copy() to deepcopy()

@antirotor antirotor added type: bug Something isn't working module: Deadline AWS Deadline related features labels May 19, 2022
@antirotor antirotor self-assigned this May 19, 2022
Copy link
Collaborator

@BigRoy BigRoy left a comment

Choose a reason for hiding this comment

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

This is definitely much safer!

Copy link
Member

@m-u-r-p-h-y m-u-r-p-h-y left a comment

Choose a reason for hiding this comment

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

B
[]
----------
C
['FOO']
----------
D
[]
----------

@antirotor antirotor merged commit 91ac69f into develop May 20, 2022
@antirotor antirotor deleted the bugfix/instance-data-overwrite-on-deadline-submission branch May 20, 2022 07:54
antirotor added a commit that referenced this pull request May 20, 2022
Deadline: instance data overwrite - backport #3214
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
module: Deadline AWS Deadline related features type: bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants