Skip to content

Commit

Permalink
Initial minimal hooking up of JT EEs to jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanCoding authored and jbradberry committed Oct 6, 2020
1 parent 7c7f534 commit 88956ac
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion awx/main/models/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def _get_unified_job_class(cls):
def _get_unified_job_field_names(cls):
return set(f.name for f in JobOptions._meta.fields) | set(
['name', 'description', 'organization', 'survey_passwords', 'labels', 'credentials',
'job_slice_number', 'job_slice_count']
'job_slice_number', 'job_slice_count', 'execution_environment']
)

@property
Expand Down
37 changes: 18 additions & 19 deletions awx/main/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,18 @@ def get_path_to(self, *args):
return os.path.abspath(os.path.join(os.path.dirname(__file__), *args))

def build_execution_environment_params(self, instance):
params = {}
if getattr(instance, 'execution_environment', None):
# TODO: process heirarchy, JT-project-org, maybe here
# or maybe in create_unified_job
logger.info('using custom image {}'.format(instance.execution_environment.image))
image = instance.execution_environment.image
else:
logger.info('using default image')
image = settings.AWX_EXECUTION_ENVIRONMENT_DEFAULT_IMAGE
params = {
"container_image": image,
"process_isolation": True
}
if settings.AWX_PROOT_SHOW_PATHS:
params['container_volume_mounts'] = []
for this_path in settings.AWX_PROOT_SHOW_PATHS:
Expand Down Expand Up @@ -1970,15 +1981,6 @@ def final_run_hook(self, job, status, private_data_dir, fact_modification_times,
if inventory is not None:
update_inventory_computed_fields.delay(inventory.id)

def build_execution_environment_params(self, instance):
params = super(RunJob, self).build_execution_environment_params(instance)
params.update({
"container_image": settings.AWX_EXECUTION_ENVIRONMENT_DEFAULT_IMAGE,
"process_isolation": True
})
return params



@task(queue=get_local_queuename)
class RunProjectUpdate(BaseTask):
Expand Down Expand Up @@ -2464,8 +2466,6 @@ def build_execution_environment_params(self, instance):
params = super(RunProjectUpdate, self).build_execution_environment_params(instance)
project_path = instance.get_project_path(check_if_exists=False)
cache_path = instance.get_cache_path()
params['process_isolation'] = True
params['container_image'] = settings.AWX_EXECUTION_ENVIRONMENT_DEFAULT_IMAGE
params.setdefault('container_volume_mounts', [])
params['container_volume_mounts'].extend([
f"{project_path}:{project_path}:Z",
Expand Down Expand Up @@ -2500,6 +2500,9 @@ def build_private_data(self, inventory_update, private_data_dir):
injector = InventorySource.injectors[inventory_update.source]()
return injector.build_private_data(inventory_update, private_data_dir)

def build_execution_environment_params(self, inventory_update):
return {} # TODO: containerize inventory updates

def build_env(self, inventory_update, private_data_dir, isolated, private_data_files=None):
"""Build environment dictionary for inventory import.
Expand Down Expand Up @@ -2918,13 +2921,6 @@ def final_run_hook(self, adhoc_job, status, private_data_dir, fact_modification_
if isolated_manager_instance:
isolated_manager_instance.cleanup()

def build_execution_environment_params(self, instance):
execution_environment_params = {
"container_image": settings.AWX_EXECUTION_ENVIRONMENT_DEFAULT_IMAGE,
"process_isolation": True
}
return execution_environment_params


@task(queue=get_local_queuename)
class RunSystemJob(BaseTask):
Expand All @@ -2933,6 +2929,9 @@ class RunSystemJob(BaseTask):
event_model = SystemJobEvent
event_data_key = 'system_job_id'

def build_execution_environment_params(self, system_job):
return {}

def build_args(self, system_job, private_data_dir, passwords):
args = ['awx-manage', system_job.job_type]
try:
Expand Down

0 comments on commit 88956ac

Please sign in to comment.