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

Periodic chatops proxy sync #4565

Merged
merged 15 commits into from
Jun 24, 2024
Merged

Conversation

Konstantinov-Innokentii
Copy link
Member

@Konstantinov-Innokentii Konstantinov-Innokentii commented Jun 20, 2024

Adds a pediodic job to sync tenants with chatops-proxy. Register request will behave as upsert, allowing us to backfill new tenant's columns: stack_id and stack_slug. Upsert is not merged on chatops-proxy, so that's why task handling 409 status on /tenants/register request.
On top of that, I did small refactoring and introduced a new register_oncall_tenant func, which receives org as an argument to not to write register_tenant(org.uuid, org.stack_id, org.stack_slug,.....) every time.
Part of https://github.com/grafana/oncall-gateway/issues/247
Need to be merged after #4559.

@Konstantinov-Innokentii Konstantinov-Innokentii requested a review from a team as a code owner June 20, 2024 08:03
@Konstantinov-Innokentii Konstantinov-Innokentii added pr:no public docs Added to a PR that does not require public documentation updates release:ignore PR will not be added to release notes labels Jun 20, 2024
try:
register_oncall_tenant(org)
except ChatopsProxyAPIException as api_exc:
# TODO: once tenants upsert api is released, remove this check
Copy link
Contributor

Choose a reason for hiding this comment

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

saw a similar comment here in #4559. What is the upsert API?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's change on chatops-proxy which make tenants/register update tenant with stack_id and cluster slug instead of returning 409 on conflict

SERVICE_TYPE_ONCALL,
stack_id,
)
register_oncall_tenant(org)
except Exception as e:
Copy link
Contributor

Choose a reason for hiding this comment

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

down below in the call to register_oncall_tenant_async.apply_async, aren't you missing the new stack_slug kwarg to pass in?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, nice catch

def uninstall_slack(stack_id: int, grafana_user_id: int) -> bool:
"""
uninstall_slack uninstalls slack integration from chatops-proxy and returns bool indicating if it was removed.
If such installation does not exist - returns True as well.s
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
If such installation does not exist - returns True as well.s
If such installation does not exist - returns True as well.

)
return False

return removed is True
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't removed always a boolean? what about returning return removed?

# Conflicts:
#	engine/apps/chatops_proxy/tasks.py
#	engine/apps/chatops_proxy/utils.py
#	engine/apps/slack/views.py
#	engine/apps/user_management/models/organization.py
@Konstantinov-Innokentii Konstantinov-Innokentii added this pull request to the merge queue Jun 23, 2024
@Konstantinov-Innokentii Konstantinov-Innokentii removed this pull request from the merge queue due to a manual request Jun 23, 2024
@Konstantinov-Innokentii Konstantinov-Innokentii added this pull request to the merge queue Jun 24, 2024
Merged via the queue into dev with commit 48b7eca Jun 24, 2024
21 checks passed
@Konstantinov-Innokentii Konstantinov-Innokentii deleted the peridic_chatops_proxy_sync branch June 24, 2024 04:44
@iskhakov iskhakov changed the title Peridic chatops proxy sync Periodic chatops proxy sync Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:no public docs Added to a PR that does not require public documentation updates release:ignore PR will not be added to release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants