gnuthought / ansible-role-openshift-provision

Provision OpenShift resources with Ansible
21 stars 19 forks source link

CronJobs are required to have annotations defined #53

Open vinny-sabatini opened 4 years ago

vinny-sabatini commented 4 years ago

The openshift-provision role fails if you try to manage a CronJob that does not have any annotations.

This was tested against an OpenShift 3.11 cluster, and the CronJob we were trying to manage was defined as a Jinja template.

Here is the error log into this issue:
Traceback (most recent call last):
    File "/tmp/ansible_phgzaB/ansible_module_openshift_provision.py", line 1536, in run_module
        provisioner.provision()
    File "/tmp/ansible_phgzaB/ansible_module_openshift_provision.py", line 1401, in provision
        patch = self.compare_resource(current_resource)
    File "/tmp/ansible_phgzaB/ansible_module_openshift_provision.py", line 1275, in compare_resource
        config = self.normalize_resource(compare_to)
    File "/tmp/ansible_phgzaB/ansible_module_openshift_provision.py", line 1145, in normalize_resource
        normalize_resource_method(resource)
    File "/tmp/ansible_phgzaB/ansible_module_openshift_provision.py", line 1196, in normalize_resource_CronJob
        normalize_CronJob_V1beta1(resource)
    File "/tmp/ansible_phgzaB/ansible_module_openshift_provision.py", line 501, in normalize_CronJob_V1beta1
        normalize_CronJobSpec_V1beta1(cron_job['spec'])
    File "/tmp/ansible_phgzaB/ansible_module_openshift_provision.py", line 507, in normalize_CronJobSpec_V1beta1
        normalize_JobTemplateSpec_V1beta1(spec['jobTemplate'])
    File "/tmp/ansible_phgzaB/ansible_module_openshift_provision.py", line 661, in normalize_JobTemplateSpec_V1beta1
        normalize_ObjectMeta_V1(spec['metadata'])
    File "/tmp/ansible_phgzaB/ansible_module_openshift_provision.py", line 733, in normalize_ObjectMeta_V1
        'annotations': {}
    File "/tmp/ansible_phgzaB/ansible_module_openshift_provision.py", line 234, in set_dict_defaults
        if k not in d:
    TypeError: argument of type 'NoneType' is not iterable
realnedsanders commented 4 years ago

This should be fixed with PR #54. I carefully considered the implications of making changes to the set_dict_defaults function. After reading the 69 or so references, I think this is an acceptable change to make.