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

Revert "Creating the pod package." #1379

Merged
merged 1 commit into from
Feb 25, 2025
Merged

Conversation

ybettan
Copy link
Member

@ybettan ybettan commented Feb 24, 2025

Reverts #1375

Summary by CodeRabbit

  • Refactor
    • Streamlined pod management operations to enhance reliability and maintainability.
  • Chores
    • Removed deprecated implementations to simplify the codebase.
  • Tests
    • Expanded test coverage to verify the improved management and lifecycle operations.

These updates improve internal efficiency and robustness without altering the user-facing functionality.

Copy link

coderabbitai bot commented Feb 24, 2025

Walkthrough

This PR refactors the MIC reconciliation logic by replacing the old ImagePuller interface with a new pullPodManager interface. The micReconciler and its helper methods and tests have been updated accordingly: the imagePullerAPI field is removed and replaced with podHelper, with corresponding changes throughout the code. New methods and mocks for managing pull pods have been introduced, while outdated files providing ImagePuller implementations and tests have been removed.

Changes

File(s) Change Summary
internal/controllers/mic_reconciler.go Replaced imagePullerAPI with podHelper of type pullPodManager. Updated NewMICReconciler, Reconcile, and related helper methods to invoke new methods (listImagesPullPods, deletePod, createPullPod, getPullPodForImage).
internal/controllers/mic_reconciler_test.go Updated tests by replacing mockImagePuller with mockPodHelper. Adjusted method calls and added new test cases to cover the functionality of the newly introduced pullPodManager methods.
internal/controllers/mock_mic_reconciler.go Added new mock implementation (MockpullPodManager) including methods for creating, deleting, listing, and retrieving pull pods.
internal/pod/... Removed files: mock_pod.go, pod.go, pod_test.go, and suite_test.go—eliminating the previous ImagePuller implementation and its associated tests.

Sequence Diagram(s)

sequenceDiagram
    participant MICReconciler
    participant pullPodManager
    participant KubernetesAPI

    MICReconciler->>pullPodManager: listImagesPullPods(ctx, micObj)
    pullPodManager->>KubernetesAPI: List pull pods
    KubernetesAPI-->>pullPodManager: Return pod data
    pullPodManager-->>MICReconciler: Return pod list
Loading

Possibly related PRs

Suggested labels

approved, lgtm

Suggested reviewers

  • TomerNewman
  • yevgeny-shnaidman

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 953f7b6 and 343436e.

📒 Files selected for processing (7)
  • internal/controllers/mic_reconciler.go (7 hunks)
  • internal/controllers/mic_reconciler_test.go (8 hunks)
  • internal/controllers/mock_mic_reconciler.go (2 hunks)
  • internal/pod/mock_pod.go (0 hunks)
  • internal/pod/pod.go (0 hunks)
  • internal/pod/pod_test.go (0 hunks)
  • internal/pod/suite_test.go (0 hunks)
💤 Files with no reviewable changes (4)
  • internal/pod/suite_test.go
  • internal/pod/mock_pod.go
  • internal/pod/pod_test.go
  • internal/pod/pod.go
🔇 Additional comments (37)
internal/controllers/mic_reconciler_test.go (16)

7-7: New imports for reflection and diff comparison
These imports are standard for test assertions and comparisons.

Also applies to: 9-9, 19-19


26-26: Introducing mockPodHelper field
Using the new MockpullPodManager is consistent with the refactored approach.

Also applies to: 33-33, 38-38


54-57: Using listImagesPullPods in the test
This correctly verifies both error and success paths for pod listing.


95-100: Additional fields in the struct
This setup streamlines test dependencies for status updates and pod management.


135-139: Verifying the removal of pods not present in MIC spec
Creating the test pod and then calling deletePod matches the updated logic.

Also applies to: 144-144


152-165: Handling failed pod with build/sign config
Updating image status to NeedsBuilding and deleting the pod is aligned with the new workflow.


172-184: Handling failed pod without build/sign config
Marking it in the status and deleting the pod is correct.


191-204: Handling succeeded pod
Setting the status to ImageExists and removing the pod is logically correct.


312-319: Defining test fields for MBSC and MIC
No issues; these fields ensure full coverage of helper methods.


352-353: Expecting creation of a new pull pod
This covers the scenario where no existing pull pod is found.


362-362: Expecting an existing pull pod
This test ensures no new pod is created if one already exists.


400-400: Minor blank line change
No structural impact.


401-448: Describe("listImagesPullPods") test block
Covers success and error flows comprehensively.


450-488: Describe("deletePod") test block
Thoroughly tests deletion behaviors and edge cases.


490-522: Describe("getPullPodForImage") test block
Ensures correct pod selection for a given image.


524-585: Describe("createPullPod") test block
Validates the generated pod fields and creation logic.

internal/controllers/mic_reconciler.go (19)

29-29: Import metav1
This supports the new metadata references.


36-43: New constants for MIC reconciler
Defining these constants ensures consistent labeling for pods.


48-48: podHelper field
Replaces the old imagePuller approach with pullPodManager.


51-53: Initialize podHelper
Constructing a new pullPodManager aligns with the refactored design.


56-56: Assign podHelper into the reconciler
Maintains a clean separation for pod operations.


79-79: Invoke listImagesPullPods
Replaces the previous image pulling interface with the new manager method.


109-113: New fields in micReconcilerHelperImpl
Defines the dependencies needed for status updates and pod handling.


117-117: Injecting pullPodHelper into micReconcilerHelperImpl
Consistent with the new modular design for handling pull pods.

Also applies to: 122-126


140-140: Extract image label
Fetches the image identifier from the new label key.


173-173: Delete pod call
Relies on the new pullPodManager.deletePod method.


215-216: Create pull pod if none exist
Properly checks for an existing pod before creating a new one.


234-234: Generate mock for pullPodManager
Ensures consistent mocking for the new interface.


235-240: pullPodManager interface definition
Clearly defines the necessary methods for pull pod lifecycle management.


242-245: pullPodManagerImpl struct
Holds dependencies for client interactions.


247-252: Factory function newPullPodManager
Returns the concrete manager for pull pods.


254-269: listImagesPullPods implementation
Lists pods with matching labels and namespace, returning them or an error.


271-281: deletePod implementation
Handles deletion timestamps and gracefully ignores not found errors.


283-321: createPullPod implementation
Constructs a minimal pod for pulling images, sets controller reference, and creates it.


323-330: getPullPodForImage implementation
Performs a linear search by label, returning the first match.

internal/controllers/mock_mic_reconciler.go (2)

6-6: Updated comment for mock generation
Reflects the newly introduced pullPodManager interface.


85-164: New MockpullPodManager implementation
Provides mocks for listing, deleting, creating, and fetching pull pods by image.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR 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 summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

openshift-ci bot commented Feb 24, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ybettan

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

The pull request process is described here

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

Copy link

netlify bot commented Feb 24, 2025

Deploy Preview for openshift-kmm ready!

Name Link
🔨 Latest commit 343436e
🔍 Latest deploy log https://app.netlify.com/sites/openshift-kmm/deploys/67bcde5158d284000816f2df
😎 Deploy Preview https://deploy-preview-1379--openshift-kmm.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@yevgeny-shnaidman
Copy link
Member

/lgtm

@yevgeny-shnaidman
Copy link
Member

/retest

@openshift-merge-bot openshift-merge-bot bot merged commit b9c7d94 into main Feb 25, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants