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

⚡ slack-usergroups: performance fix #4800

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

chassing
Copy link
Member

@chassing chassing commented Dec 17, 2024

Don't download the complete git repo file list.

slack-usergroups uses just the root level (.) OWNERS file but downloads a list of all files from the git repos. clusterimagesets has more than 31000 files, get_repository_tree receives the file catalog in 100 chunks. In total, ~310 HTTP requests, and each takes 1 second.

This fix reduces the runtime of a reconciliation loop by 6 minutes.

@chassing chassing self-assigned this Dec 17, 2024
Copy link
Contributor

@esron esron left a comment

Choose a reason for hiding this comment

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

LGTM

repo_tree = self._git_cli.get_repository_tree(ref=self._ref)
owner_files = [item for item in repo_tree if item["name"] == "OWNERS"]
else:
owner_files = [{"path": "OWNERS"}]
Copy link
Contributor

Choose a reason for hiding this comment

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

what happens if there is no such file? Won't we raise an exception later?

Copy link
Member Author

@chassing chassing Dec 18, 2024

Choose a reason for hiding this comment

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

I thought the same, but gitlab_api and github_api ignore any missing files. Nevertheless, I've added a warning in 1508ec and fixed an attribute error a long the way

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.

3 participants