diff options
author | Jeff Bradberry <jeff.bradberry@gmail.com> | 2021-06-14 20:17:55 +0200 |
---|---|---|
committer | Shane McDonald <me@shanemcd.com> | 2021-06-16 21:41:09 +0200 |
commit | 85bb4e976f02112592bc9b36cedb43005517dd83 (patch) | |
tree | 217b3e7e8ea5a80a1b2aa14526d73c13dd532214 | |
parent | Add yamllint to dev dependencies (diff) | |
download | awx-85bb4e976f02112592bc9b36cedb43005517dd83.tar.xz awx-85bb4e976f02112592bc9b36cedb43005517dd83.zip |
Execution environments are meaningless for workflows
so, remove them from the API endpoints for workflows. Also, tear out
the WFJT.execution_environment step in the resolver. If we want that
to be a thing, it ought to be a .default_environment instead.
-rw-r--r-- | awx/api/serializers.py | 17 | ||||
-rw-r--r-- | awx/main/models/mixins.py | 7 | ||||
-rw-r--r-- | awx/main/models/workflow.py | 3 |
3 files changed, 14 insertions, 13 deletions
diff --git a/awx/api/serializers.py b/awx/api/serializers.py index 1f0f127fc9..12799e0d94 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -729,11 +729,12 @@ class UnifiedJobTemplateSerializer(BaseSerializer): if self.is_detail_view: resolved_ee = obj.resolve_execution_environment() - summary_fields['resolved_environment'] = { - field: getattr(resolved_ee, field, None) - for field in SUMMARIZABLE_FK_FIELDS['execution_environment'] - if getattr(resolved_ee, field, None) is not None - } + if resolved_ee is not None: + summary_fields['resolved_environment'] = { + field: getattr(resolved_ee, field, None) + for field in SUMMARIZABLE_FK_FIELDS['execution_environment'] + if getattr(resolved_ee, field, None) is not None + } return summary_fields @@ -3425,6 +3426,7 @@ class WorkflowJobTemplateSerializer(JobTemplateMixin, LabelsListMixin, UnifiedJo 'ask_limit_on_launch', 'webhook_service', 'webhook_credential', + '-execution_environment', ) def get_related(self, obj): @@ -3451,6 +3453,7 @@ class WorkflowJobTemplateSerializer(JobTemplateMixin, LabelsListMixin, UnifiedJo survey_spec=self.reverse('api:workflow_job_template_survey_spec', kwargs={'pk': obj.pk}), copy=self.reverse('api:workflow_job_template_copy', kwargs={'pk': obj.pk}), ) + res.pop('execution_environment', None) # EEs aren't meaningful for workflows if obj.organization: res['organization'] = self.reverse('api:organization_detail', kwargs={'pk': obj.organization.pk}) if obj.webhook_credential_id: @@ -3502,6 +3505,7 @@ class WorkflowJobSerializer(LabelsListMixin, UnifiedJobSerializer): 'allow_simultaneous', 'job_template', 'is_sliced_job', + '-execution_environment', '-execution_node', '-event_processing_finished', '-controller_node', @@ -3515,6 +3519,7 @@ class WorkflowJobSerializer(LabelsListMixin, UnifiedJobSerializer): def get_related(self, obj): res = super(WorkflowJobSerializer, self).get_related(obj) + res.pop('execution_environment', None) # EEs aren't meaningful for workflows if obj.workflow_job_template: res['workflow_job_template'] = self.reverse('api:workflow_job_template_detail', kwargs={'pk': obj.workflow_job_template.pk}) res['notifications'] = self.reverse('api:workflow_job_notifications_list', kwargs={'pk': obj.pk}) @@ -3539,7 +3544,7 @@ class WorkflowJobSerializer(LabelsListMixin, UnifiedJobSerializer): class WorkflowJobListSerializer(WorkflowJobSerializer, UnifiedJobListSerializer): class Meta: - fields = ('*', '-execution_node', '-controller_node') + fields = ('*', '-execution_environment', '-execution_node', '-controller_node') class WorkflowJobCancelSerializer(WorkflowJobSerializer): diff --git a/awx/main/models/mixins.py b/awx/main/models/mixins.py index 7f929c757d..45a3cae885 100644 --- a/awx/main/models/mixins.py +++ b/awx/main/models/mixins.py @@ -471,13 +471,6 @@ class ExecutionEnvironmentMixin(models.Model): template = getattr(self, 'unified_job_template', None) if template is not None and template.execution_environment is not None: return template.execution_environment - wf_node = getattr(self, 'unified_job_node', None) - while wf_node is not None: - wf_template = wf_node.workflow_job.workflow_job_template - # NOTE: sliced workflow_jobs have a null workflow_job_template - if wf_template and wf_template.execution_environment is not None: - return wf_template.execution_environment - wf_node = getattr(wf_node.workflow_job, 'unified_job_node', None) if getattr(self, 'project_id', None) and self.project.default_environment is not None: return self.project.default_environment if getattr(self, 'organization_id', None) and self.organization.default_environment is not None: diff --git a/awx/main/models/workflow.py b/awx/main/models/workflow.py index 463a98f805..b254ee41c8 100644 --- a/awx/main/models/workflow.py +++ b/awx/main/models/workflow.py @@ -595,6 +595,9 @@ class WorkflowJobTemplate(UnifiedJobTemplate, WorkflowJobOptions, SurveyJobTempl def _get_related_jobs(self): return WorkflowJob.objects.filter(workflow_job_template=self) + def resolve_execution_environment(self): + return None # EEs are not meaningful for workflows + class WorkflowJob(UnifiedJob, WorkflowJobOptions, SurveyJobMixin, JobNotificationMixin, WebhookMixin): class Meta: |