# Buggy code
def update_parameters(self, client):
    self.spec = client.create_swarm_spec(
        snapshot_interval=self.snapshot_interval,
        task_history_retention_limit=self.task_history_retention_limit,
        keep_old_snapshots=self.keep_old_snapshots,
        log_entries_for_slow_followers=self.log_entries_for_slow_followers,
        heartbeat_tick=self.heartbeat_tick,
        election_tick=self.election_tick,
        dispatcher_heartbeat_period=self.dispatcher_heartbeat_period,
        node_cert_expiry=self.node_cert_expiry,
        name=self.name,
        labels=self.labels,
        signing_ca_cert=self.signing_ca_cert,
        signing_ca_key=self.signing_ca_key,
        ca_force_rotate=self.ca_force_rotate,
        autolock_managers=self.autolock_managers,
        log_driver=self.log_driver,
    )


# Traceback (nKeyError)
fatal: [node-01]: FAILED! => {"changed": false, "module_stderr": "Shared connection to node-01 closed.\r\n", "module_stdout": "/usr/lib/python2.7/site-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.24.1) or chardet (2.2.1) doesn't match a supported version!\r\n  RequestsDependencyWarning)\r\nTraceback (most recent call last):\r\n  File \"/root/.ansible/tmp/ansible-tmp-1548156057.5468266-261250085584743/AnsiballZ_docker_swarm.py\", line 113, in <module>\r\n    _ansiballz_main()\r\n  File \"/root/.ansible/tmp/ansible-tmp-1548156057.5468266-261250085584743/AnsiballZ_docker_swarm.py\", line 105, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/root/.ansible/tmp/ansible-tmp-1548156057.5468266-261250085584743/AnsiballZ_docker_swarm.py\", line 48, in invoke_module\r\n    imp.load_module('__main__', mod, module, MOD_DESC)\r\n  File \"/tmp/ansible_docker_swarm_payload_2QlvP8/__main__.py\", line 535, in <module>\r\n  File \"/tmp/ansible_docker_swarm_payload_2QlvP8/__main__.py\", line 530, in main\r\n  File \"/tmp/ansible_docker_swarm_payload_2QlvP8/__main__.py\", line 310, in __call__\r\n  File \"/tmp/ansible_docker_swarm_payload_2QlvP8/__main__.py\", line 333, in init_swarm\r\n  File \"/tmp/ansible_docker_swarm_payload_2QlvP8/__main__.py\", line 390, in __update_swarm\r\n  File \"/tmp/ansible_docker_swarm_payload_2QlvP8/__main__.py\", line 376, in __update_spec\r\nKeyError: 'Labels'\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

# Fixed code
def update_parameters(self, client):
    params = dict(
        snapshot_interval=self.snapshot_interval,
        task_history_retention_limit=self.task_history_retention_limit,
        keep_old_snapshots=self.keep_old_snapshots,
        log_entries_for_slow_followers=self.log_entries_for_slow_followers,
        heartbeat_tick=self.heartbeat_tick,
        election_tick=self.election_tick,
        dispatcher_heartbeat_period=self.dispatcher_heartbeat_period,
        node_cert_expiry=self.node_cert_expiry,
        name=self.name,
        signing_ca_cert=self.signing_ca_cert,
        signing_ca_key=self.signing_ca_key,
        ca_force_rotate=self.ca_force_rotate,
        autolock_managers=self.autolock_managers,
        log_driver=self.log_driver,
    )
    if self.labels:
        params["labels"] = self.labels
    self.spec = client.create_swarm_spec(**params)