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

Add optional provider label support #277

Merged
merged 11 commits into from
May 1, 2024
Merged

Conversation

rplevka
Copy link
Member

@rplevka rplevka commented Mar 18, 2024

Extend broker's AnsibleTower and Container provider functionality to pass labels to be set to the spawned resources.
It accepts a string of comma-separated label values.
Broker then uses awxkit session to resolve their id's (required for the job /launch payload) and eventually creates the non-existing labels.

User is required to have granted permissions for creating new labels (if that's even a thing) on AAP.

Plan is to implement the labeling functionality to all providers that have support of labels, e.g.
https://docs.docker.com/config/labels-custom-metadata/

example usage:

# ansible tower provider
$ broker execute deploy-rhel --provider-labels foo=bar,baz

translates to:
Selection_674
(AAP labels are single string items)

# container provider with additional labels configured in the nick:

nick:

  rhel8_docker:
    container_host: "ubi8:latest"
    environment:
      BUILD_URL: "https://intergalactic.planetary/planetary/intergalactic"
    provider_labels:
      nick_label_1: myval1
      nick_label_2: myval2


$ broker checkout --nick rhel8_docker --provider-labls cli1=val1,nick_label_2=overriden_by_cli_param
[INFO 240418 14:13:37] Using provider Container to checkout
[INFO 240418 14:13:45] Host: 97c993636de8

translates to:

$ docker inspect 97c993636de8
...
            "Labels": {
                "architecture": "x86_64",
                "broker.jenkins.url": "",
                "broker.nick_label_1": "myval1",
                "broker.nick_label_2": "myval2",
                "broker.origin": "broker_cli:rplevka",
               ...
...

@rplevka rplevka marked this pull request as draft March 18, 2024 22:10
@JacobCallahan JacobCallahan changed the base branch from master to 0.5 March 19, 2024 17:11
@rplevka rplevka marked this pull request as ready for review April 3, 2024 11:24
@rplevka rplevka changed the title Draft: added optional label support Add optional provider label support Apr 3, 2024
@rplevka rplevka marked this pull request as draft April 3, 2024 11:27
@rplevka rplevka force-pushed the labelz branch 2 times, most recently from 6897512 to d04c1d7 Compare April 18, 2024 11:52
@rplevka rplevka self-assigned this Apr 18, 2024
@rplevka rplevka marked this pull request as ready for review April 18, 2024 12:04
Copy link
Member

@JacobCallahan JacobCallahan left a comment

Choose a reason for hiding this comment

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

Can you add a functional test each for tower and containers?
I think we can just skip beaker for now since I'm not sure that labels are a thing there (and it is much less commonly used).

Also, how well are these labels recovered after a sync?

broker/commands.py Show resolved Hide resolved
broker/commands.py Outdated Show resolved Hide resolved
broker/commands.py Show resolved Hide resolved
broker/providers/ansible_tower.py Show resolved Hide resolved
broker/providers/ansible_tower.py Outdated Show resolved Hide resolved
@rplevka rplevka force-pushed the labelz branch 3 times, most recently from b605076 to 191c9de Compare April 22, 2024 13:50
Copy link
Member

@JacobCallahan JacobCallahan left a comment

Choose a reason for hiding this comment

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

Just a few more things. Can you also resolve the merge conflicts?

broker/providers/ansible_tower.py Outdated Show resolved Hide resolved
broker/providers/ansible_tower.py Outdated Show resolved Hide resolved
tests/functional/test_satlab.py Outdated Show resolved Hide resolved
@rplevka rplevka force-pushed the labelz branch 4 times, most recently from ebfceba to 83185c5 Compare April 25, 2024 08:27
pyproject.toml Outdated Show resolved Hide resolved
@JacobCallahan JacobCallahan merged commit 7bab4ff into SatelliteQE:0.5 May 1, 2024
4 checks passed
JacobCallahan pushed a commit that referenced this pull request May 29, 2024
* added optional label support

* provider/container - support labels, skip envars as labels

* label formatting logic moved to commands.py

* labels arg renamed to provider-labels

* labels - AT provider - fix label value parsing

* add provider_label support to execute command

* fix provider_labels parsing for container provider

* provider_labels are nested for AT provider

* append label asserts to test_container_e2e

* Add parsing of eventual settings.provider_labels for AT, Container providers

* add e2e provider_labels fn test for AA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants