Skip to content

Added logs command and integrated it into the CLI structure.#108

Merged
LorenzoTettamanti merged 1 commit intoCortexFlow:feature/clifrom
PranavVerma-droid:feature/cli
Jun 21, 2025
Merged

Added logs command and integrated it into the CLI structure.#108
LorenzoTettamanti merged 1 commit intoCortexFlow:feature/clifrom
PranavVerma-droid:feature/cli

Conversation

@PranavVerma-droid
Copy link
Collaborator

This pull request adds a new logs feature to the CLI tool, allowing users to get logs for specific services, components, or all pods in a namespace. The updates involve adding logic to interact with Kubernetes using kubectl commands and incorporating the new feature into the CLI framework.

New logs feature implementation:

  • cli/src/logs.rs: A detailed implementation for the logs_command function was added, which retrieves logs through kubectl. It features helper functions for validating namespaces, retrieving pods based on service or component labels, and fetching logs for individual pods. A new Component enum was created to represent control-plane and data-plane components.

Integration into CLI framework:

  • cli/src/main.rs:
    • The new logs module and command were registered in the CLI structure.
    • A LogsArgs struct was added to define arguments for the logs command, including service, component, and namespace.
    • The logs_command function was integrated into the CLI argument parser, allowing the execution of the logs command.
    • Imports were updated to include the logs module and its related command.

These updates improve the functionality of the CLI tool by giving users the ability to retrieve detailed logs directly from their Kubernetes cluster.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request introduces a new logs feature into the CLI tool, enabling users to retrieve logs from Kubernetes pods filtered by service or component. Key changes include:

  • Adding the new logs module and integrating it into the CLI command parser.
  • Implementing helper functions to validate namespaces, list pods by service/component, and fetch pod logs.
  • Creating a new Component enum to distinguish between control-plane and data-plane components.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
cli/src/mod.rs Added logs module registration.
cli/src/main.rs Registered logs command and defined LogsArgs for argument parsing.
cli/src/logs.rs Implemented the logs_command function and supporting helper functions to retrieve and display Kubernetes logs.

Comment on lines +139 to +142

// intersection
service_pods.into_iter()
.filter(|pod| component_pods.contains(pod))
Copy link

Copilot AI Jun 20, 2025

Choose a reason for hiding this comment

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

Consider optimizing the intersection of pods by converting one of the pod lists (e.g., component_pods) into a HashSet to reduce the time complexity from O(n²) to O(n).

Suggested change
// intersection
service_pods.into_iter()
.filter(|pod| component_pods.contains(pod))
let component_pods_set: HashSet<_> = component_pods.into_iter().collect();
// intersection
service_pods.into_iter()
.filter(|pod| component_pods_set.contains(pod))

Copilot uses AI. Check for mistakes.
Copy link
Member

@LorenzoTettamanti LorenzoTettamanti left a comment

Choose a reason for hiding this comment

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

Hi Pranav, great work so far. Merging the changes🚀

@LorenzoTettamanti LorenzoTettamanti merged commit 70ae38e into CortexFlow:feature/cli Jun 21, 2025
3 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cortexflow cli CLI related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants