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

Migrate pre-main-check-users-map to Github action #9768

Closed
4 tasks
Tracked by #10076
Sawthis opened this issue Jan 25, 2024 · 4 comments
Closed
4 tasks
Tracked by #10076

Migrate pre-main-check-users-map to Github action #9768

Sawthis opened this issue Jan 25, 2024 · 4 comments
Labels
area/ci Issues or PRs related to CI related topics

Comments

@Sawthis
Copy link
Contributor

Sawthis commented Jan 25, 2024

Description

Create a Cloud Run service that will generate a file in Google Cloud Firestore containing Slack user mappings. Below is the relevant code snippet that demonstrates the function:

from slack_sdk import WebClient
from slack_sdk.errors import SlackApiError

with open('/etc/slack-secret/common-slack-bot-token-test', encoding='utf-8') as token_file:
    slack_bot_token = token_file.readline()

slack_client = WebClient(token=slack_bot_token)

def get_slack_user_mapping():
    '''Fetches Slack users and returns a mapping of real names to Slack IDs'''
    try:
        users = {}
        cursor = None
        while True:
            response = slack_client.users_list(cursor=cursor)
            for member in response['members']:
                real_name = member.get('real_name')
                slack_id = member.get('id')
                if real_name and slack_id:
                    users[real_name] = slack_id
            cursor = response['response_metadata'].get('next_cursor')
            if not cursor:
                break
        return users
    except SlackApiError as e:
        print(LogEntry(
            severity="ERROR",
            message=f"Error fetching Slack users: {e.response['error']}",
            **prepare_log_fields(),
        ))
        return {}

The Cloud Run service should be configured to:

  • Work with a scheduler to ensure regular updates.
  • Respond to triggers from other Cloud Run services, allowing it to be invoked on demand or periodically.

Additionally, modify the SlackMessageSender Cloud Run / GitHub-webhook-gateway Cloud Run to:

  • Use the file stored in Firestore to identify users.

If a user is not found, the application should invoke the above Cloud Run service to reload the file and confirm it has completed the operation.

  • This can be verified by comparing the number of lines, words, or characters in the fetched file.
    • If the new file contains more content, it indicates a successful reload.
    • If not, the system should wait until the Cloud Run service completes its task, considering potential rate limits.

Reasons

Migration out from Prow.

Acceptance Criteria

  • The functionality is executed on the internal GitHub.
  • The pre-main-check-users-map Prow job is removed.
  • Create a slackusermapping-cloudrun service to pass the file to Google Cloud Firestore.
  • Modify the SlackMessageSender Cloud Run / GitHub-webhook-gateway Cloud Run to use the file from Google Cloud Firestore.

Attachments

#9470

@Sawthis Sawthis added the area/ci Issues or PRs related to CI related topics label Jan 25, 2024
Copy link

This issue has been automatically marked as stale due to the lack of recent activity. It will soon be closed if no further activity occurs.
Thank you for your contributions.

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 26, 2024
Copy link

github-actions bot commented Apr 2, 2024

This issue has been automatically closed due to the lack of recent activity.
/lifecycle rotten

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 2, 2024
@kyma-bot kyma-bot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Apr 2, 2024
@Sawthis Sawthis removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Apr 10, 2024
@Sawthis Sawthis reopened this Apr 10, 2024
@akiioto
Copy link
Contributor

akiioto commented Oct 22, 2024

#12121

@Sawthis
Copy link
Contributor Author

Sawthis commented Feb 21, 2025

#12718

@Sawthis Sawthis closed this as not planned Won't fix, can't repro, duplicate, stale Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ci Issues or PRs related to CI related topics
Projects
None yet
Development

No branches or pull requests

3 participants