Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commits settings.DEFAULT_EXECUTION_ENVIRONMENTS updates into the database #10206

Conversation

tchellomello
Copy link
Contributor

@tchellomello tchellomello commented May 17, 2021

SUMMARY

Fixes: ansible/awx-operator#256

cc: @shanemcd

Cannot update execution environment version in place by updating the AWX spec via awx-operator. For example, consider the scenario below:

spec:
  tower_ee_images:
    - image: registry.tatu.home/ansible/awx-ee:0.1.0
      name: My Custom Execution Environment

image

The expectation would be once you modify the AWX spec to the version below, the EE should reflect this change once the awx-operator finishes its reconciliation.

After:

spec:
  tower_ee_images:
    - image: registry.tatu.home/ansible/awx-ee:0.2.0
      name: My Custom Execution Environment

image

-- deployment got updated
- args:
        - receptor
        - --config
        - /etc/receptor.conf
        image: registry.tatu.home/ansible/awx-ee:0.2.0
        imagePullPolicy: IfNotPresent
        name: awx-devel-ee-ee

Besides the awx-operator updated the YAML deployment as expected, the change did not hit the database.

awx=# select * from main_executionenvironment;
 id |    created    |   modified    | description |     image      | managed_by_tower | created_by_id | credential_id | modified_by_id | organization_id |      name      | pull 
----+---------------+---------------+-------------+----------------+------------------+---------------+---------------+----------------+-----------------+----------------+------
  1 | 2021-05-11 15.| 2021-05-11 15.|             | registry.tatu..| t                |             1 |               |              1 |                 | My Custom Exec.| 
    |.:24:02.674302.|.:24:02.674327.|             |.home/ansible/a.|                  |               |               |                |                 |.ution Environm.| 
    |.+00           |.+00           |             |.wx-ee:0.1.0    |                  |               |               |                |                 |.ent            | 
(1 row)
ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME
  • API
AWX VERSION
devel
ADDITIONAL INFORMATION

Quick proof of concept

>>> settings.DEFAULT_EXECUTION_ENVIRONMENTS
[{'name': 'My Custom Execution Environment', 'image': 'registry.tatu.home/ansible/awx-ee:0.2.0'}]
>>> [a.name for a in  ExecutionEnvironment.objects.all()]
['My Custom Execution Environment']
>>> [a.image for a in  ExecutionEnvironment.objects.all()]
['registry.tatu.home/ansible/awx-ee:0.2.0']

*** updating to new but keeping name 
>>> _, created = ExecutionEnvironment.objects.update_or_create(name='My Custom Execution Environment', defaults={'image': 'registry.tatu.home/ansible/awx-ee:0.3.0', 'managed_by_tower': True})
>>> [a.name for a in  ExecutionEnvironment.objects.all()]
['My Custom Execution Environment']
>>> [a.image for a in  ExecutionEnvironment.objects.all()]
['registry.tatu.home/ansible/awx-ee:0.3.0']

*** adding a new name
>>> _, created = ExecutionEnvironment.objects.update_or_create(name='My Custom Execution Environment2', defaults={'image': 'registry.tatu.home/ansible/awx-ee:0.3.0', 'managed_by_tower': True})
>>> [a.name for a in  ExecutionEnvironment.objects.all()]
['My Custom Execution Environment2', 'My Custom Execution Environment']
>>> [a.image for a in  ExecutionEnvironment.objects.all()]
['registry.tatu.home/ansible/awx-ee:0.3.0', 'registry.tatu.home/ansible/awx-ee:0.3.0']

@tchellomello tchellomello changed the title update_or_create EE via settings.DEFAULT_EXECUTION_ENVIRONMENTS Commits settings.DEFAULT_EXECUTION_ENVIRONMENTS changes into the database May 17, 2021
@tchellomello tchellomello changed the title Commits settings.DEFAULT_EXECUTION_ENVIRONMENTS changes into the database Commits settings.DEFAULT_EXECUTION_ENVIRONMENTS updates into the database May 17, 2021
@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

Copy link
Member

@rooftopcellist rooftopcellist left a comment

Choose a reason for hiding this comment

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

This looks good to me. We will still get back the "created" var we expect and if settings.DEFAULT_EXECUTION_ENVIRONMENTS is updated (for example via the spec var of an awx-operator deployment), it will be created upon re-deployment.

@rooftopcellist
Copy link
Member

regate

Copy link
Member

@shanemcd shanemcd left a comment

Choose a reason for hiding this comment

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

Works for now, but jfyi this might change even more with the stuff @rebeccahhh will be starting this sprint. We're discussing the possibility moving this logic out of create_preload_datae

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded (gate pipeline).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot update execution environment version in place
4 participants