Skip to content

OCPERT-368: Replace GitHub token with Github app for Jira Notificator#1059

Closed
tomasdavidorg wants to merge 3 commits into
openshift:mainfrom
tomasdavidorg:OCPERT-368_notificator
Closed

OCPERT-368: Replace GitHub token with Github app for Jira Notificator#1059
tomasdavidorg wants to merge 3 commits into
openshift:mainfrom
tomasdavidorg:OCPERT-368_notificator

Conversation

@tomasdavidorg

@tomasdavidorg tomasdavidorg commented May 29, 2026

Copy link
Copy Markdown
Contributor

rh-pre-commit.version: 2.4.0
rh-pre-commit.check-secrets: ENABLED

https://redhat.atlassian.net/browse/OCPERT-368

Should be merged together with openshift/release#79905

Summary by CodeRabbit

  • New Features

    • GitHub integration now supports GitHub App authentication with separate reader and writer app configurations.
  • Chores

    • Updated GitHub credential configuration to use app IDs and private keys via environment variables.

rh-pre-commit.version: 2.4.0
rh-pre-commit.check-secrets: ENABLED
@tomasdavidorg tomasdavidorg requested a review from LuboTerifaj May 29, 2026 13:31
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label May 29, 2026
@openshift-ci-robot

openshift-ci-robot commented May 29, 2026

Copy link
Copy Markdown

@tomasdavidorg: This pull request references OCPERT-368 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the sub-task to target the "5.0.0" version, but no target version was set.

Details

In response to this:

rh-pre-commit.version: 2.4.0
rh-pre-commit.check-secrets: ENABLED

https://redhat.atlassian.net/browse/OCPERT-368

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown

Walkthrough

This pull request migrates NotificationService pre-merge verification from GITHUB_TOKEN authentication to GitHub App authentication. New configuration constants are defined, a GitHubApp abstraction is introduced to manage app authentication and installation-scoped client creation, and NotificationService is updated to initialize and use that abstraction during pre-merge verification workflows.

Changes

GitHub App Authentication for Pre-Merge Verification

Layer / File(s) Summary
GitHub App configuration constants
oar/core/const.py
Four new environment variable name constants added for GitHub App reader and writer IDs and private keys.
GitHub App authentication abstraction
oar/core/github_app.py
GitHubApp class handles private key normalization (raw PEM or filesystem path), constructs PyGithub Auth.AppAuth and GithubIntegration, and exposes client_for_repo(owner, repo) to retrieve installation-scoped clients.
NotificationService integration with GitHub App
oar/notificator/jira_notificator.py
Imports updated to use GitHubApp and reader env var constants. Added _init_github_app() helper to construct GitHubApp from environment with exception handling. Added _github_client_for_repo(org, repo) helper to fetch installation-scoped clients and log unavailability. Modified is_pre_merge_verified() to skip verification when GitHub App reader credentials are missing and to use per-repository clients fetched via the helper instead of a global token.
Test validation for missing GitHub App credentials
tests/test_jira_notificator.py
Updated test_is_pre_merge_verified scenario to verify that verification is skipped when NotificationService._github_app is unavailable, replacing the prior GITHUB_TOKEN credential absence check.

🎯 3 (Moderate) | ⏱️ ~20 minutes


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 1 warning)

Check name Status Explanation Resolution
No-Sensitive-Data-In-Logs ❌ Error Line 94 uses logger.exception() which logs full stack traces including local variables (app_id, private_key), exposing the GitHub App private key - a sensitive credential. Replace logger.exception() with logger.exception("Failed to initialize GitHub App Reader") but only log status/type without exposing secrets, or use logger.debug/error without full traceback context for sensitive credential initialization.
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (13 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: replacing GitHub token authentication with GitHub App authentication in the Jira Notificator module.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed The custom check for Ginkgo test name stability is not applicable to this PR. The repository is Python-based using unittest, not Go with Ginkgo. No Ginkgo tests exist in this codebase.
Test Structure And Quality ✅ Passed The custom check specifies "Ginkgo test code" review requirements, but this PR contains only Python unittest tests (using TestCase), not Go/Ginkgo tests. The check is not applicable.
Microshift Test Compatibility ✅ Passed This PR contains only Python code (constants, classes, and unit tests). No Ginkgo e2e tests are added, so the MicroShift compatibility check does not apply.
Single Node Openshift (Sno) Test Compatibility ✅ Passed PR adds no new Ginkgo e2e tests—only Python unit tests for Jira notificator. Check only applies to Ginkgo e2e tests, so it is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed PR contains only Python application code (GitHub App auth, Jira notifications), not K8s manifests, operators, or controllers. No scheduling constraints introduced.
Ote Binary Stdout Contract ✅ Passed PR adds GitHub App constants and class with no stdout writes. Modified jira_notificator uses logging, not print. No violations of OTE Binary Stdout Contract.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed Check is not applicable: PR contains only Python code with Python unit tests, no Ginkgo e2e tests. The check is designed specifically for Ginkgo e2e test additions.
No-Weak-Crypto ✅ Passed No weak cryptography (MD5, SHA1, DES, RC4, 3DES, Blowfish, ECB), custom crypto implementations, or insecure secret comparisons found in modified files.
Container-Privileges ✅ Passed PR contains no container/Kubernetes manifest file changes. Modified files are Python source and test files only; check is not applicable.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci Bot requested review from barboras7 and cardelearht May 29, 2026 13:31
@openshift-ci

openshift-ci Bot commented May 29, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign tomasdavidorg for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@oar/core/github_app.py`:
- Around line 19-22: The code probes private_key with
Path(private_key).is_file(), which can raise OSError when private_key contains
raw PEM text; change the logic in github_app.py to first detect PEM input (e.g.,
private_key.strip().startswith("-----BEGIN")) and treat that as the key content,
otherwise create key_path = Path(private_key).expanduser() and safely call
key_path.is_file() (optionally wrapped in try/except) and read_text() if
present; update the variables referenced (private_key, key_path, key) and the
initialization code that uses them.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 162830bc-9bb2-41a8-b976-a17817486565

📥 Commits

Reviewing files that changed from the base of the PR and between ee30ced and 8566fcd.

📒 Files selected for processing (4)
  • oar/core/const.py
  • oar/core/github_app.py
  • oar/notificator/jira_notificator.py
  • tests/test_jira_notificator.py

Comment thread oar/core/github_app.py Outdated
rh-pre-commit.version: 2.4.0
rh-pre-commit.check-secrets: ENABLED
rh-pre-commit.version: 2.4.0
rh-pre-commit.check-secrets: ENABLED
@openshift-ci

openshift-ci Bot commented May 29, 2026

Copy link
Copy Markdown

@tomasdavidorg: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@tomasdavidorg

Copy link
Copy Markdown
Contributor Author

@coderabbitai help

@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue comments.

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai rate limit to show your current review rate limit status.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
  • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
  • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai emit path instructions to emit generated path-specific review instructions for this repository.
  • @coderabbitai resolve merge conflict to automatically resolve merge conflicts.
  • @coderabbitai autofix to automatically fix issues identified in unresolved review comments.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai generate configuration to create a PR that adds the current resolved configuration as .coderabbit.yaml (or show it if already present).
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

@tomasdavidorg

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown
✅ Actions performed

Full review triggered.

@tomasdavidorg

Copy link
Copy Markdown
Contributor Author

New PR is opened #1060

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants