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

rshm_repository: reduce execution time when changed == False #458

Merged

Conversation

giovannisciortino
Copy link
Contributor

SUMMARY

This PR reduce of about 50% the execution time of this module when the module doesn't change the state of RHSM repositories.

Fixes #452

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

rhsm_repository

ADDITIONAL INFORMATION

This module execute the command subscription-manager two times:

  1. Executing "subscription-manager repos --list" to identify enabled/disabled repositories before execute any change
  2. Executing "subscription-manager repos " to enable/disable repositories and change the state of enabled/disabled repositories

The execution of subscription-manager command in some condition is slow (it can take about 40 seconds)
Before this PR, this module call subscription-manager always two times also when there aren't changes.
After this PR, this module skip the second execution of subscription-manager when there aren't changes.

Before PR

$ time ansible all -i /tmp/tmp -m rhsm_repository -a 'name=codeready-builder-for-rhel-8-x86_64-rpms'
...
    "changed": false,
...
    "results": [
        "Repository 'codeready-builder-for-rhel-8-x86_64-rpms' is enabled for this system."
    ]
}
real	1m31,856s
user	0m15,253s
sys	0m0,885s

After PR

$ time ansible all -i /tmp/tmp -m rhsm_repository -a 'name=codeready-builder-for-rhel-8-x86_64-rpms'
...
    "changed": false,
...
    "results": [
        "Repository 'codeready-builder-for-rhel-8-x86_64-rpms' is enabled for this system."
    ]
}
real	0m43,459s
user	0m7,632s
sys	0m0,498s

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added affects_2.10 bug This issue/PR relates to a bug module module owner_pr PR created by owner/maintainer labels Jun 4, 2020
@pabelanger
Copy link

recheck

1 similar comment
@pabelanger
Copy link

recheck

Copy link
Contributor

@Andersson007 Andersson007 left a comment

Choose a reason for hiding this comment

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

@ansibullbot ansibullbot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR and removed community_review labels Jun 9, 2020
@giovannisciortino
Copy link
Contributor Author

I added the "changelog fragment". Thanks for the review

@Andersson007 Andersson007 merged commit 7bdd78b into ansible-collections:master Jun 11, 2020
@Andersson007
Copy link
Contributor

@giovannisciortino thanks for the contribution!

@Andersson007
Copy link
Contributor

merged #458 into master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug module module needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR owner_pr PR created by owner/maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rhsm_repository is really slow
4 participants