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

feat(windows): Create standalone daemon for non-k8s orchestration #1385

Draft
wants to merge 64 commits into
base: main
Choose a base branch
from

Conversation

BeegiiK
Copy link
Contributor

@BeegiiK BeegiiK commented Feb 24, 2025

Description

Please provide a brief description of the changes made in this pull request.

Related Issue

If this pull request is related to any issue, please mention it here. Additionally, make sure that the issue is assigned to you before submitting this pull request.

Checklist

  • I have read the contributing documentation.
  • I signed and signed-off the commits (git commit -S -s ...). See this documentation on signing commits.
  • I have correctly attributed the author(s) of the code.
  • I have tested the changes locally.
  • I have followed the project's style guidelines.
  • I have updated the documentation, if necessary.
  • I have added tests, if applicable.

Screenshots (if applicable) or Testing Completed

Please add any relevant screenshots or GIFs to showcase the changes made.

Additional Notes

Add any additional notes or context about the pull request here.


Please refer to the CONTRIBUTING.md file for more information on how to contribute to this project.

@BeegiiK BeegiiK changed the title Create standalone daemon for non-k8s orchestration feat(windows): Create standalone daemon for non-k8s orchestration Feb 28, 2025
@BeegiiK BeegiiK self-assigned this Feb 28, 2025
@rbtr rbtr requested a review from Copilot February 28, 2025 16:59
Copy link

@Copilot 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.

PR Overview

This PR introduces a standalone daemon for non-K8s orchestration. Key changes include:

  • Adding a standalone cache implementation with its corresponding test.
  • Implementing a new standalone daemon in the cmd package.
  • Introducing a BootstrapManager to initialize and start the daemon in non-Kubernetes environments.

Reviewed Changes

File Description
pkg/controllers/cache/standalone_cache_test.go Adds tests for standalone cache functionality
cmd/standalone_daemon.go Implements a new standalone daemon for Retina orchestration
cmd/bootstrap_manager.go Introduces a bootstrap manager to bootstrap the daemon
pkg/controllers/cache/standalone_cache.go Implements cache logic used by the standalone daemon
cmd/standard/daemon.go Updates daemon configuration and startup to integrate new behavior
cmd/root.go Updates CLI to use the new BootstrapManager instead of the daemon directly

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

cmd/bootstrap_manager.go:43

  • [nitpick] Consider using the logger for output instead of fmt.Printf to maintain consistent logging and potentially capture log levels and context.
fmt.Printf("Bootstrapping Retina")

@BeegiiK BeegiiK force-pushed the issues/1365 branch 4 times, most recently from 0294bba to a9efcc5 Compare March 25, 2025 16:32
Comment on lines 37 to 125
func TestAddPod(t *testing.T) {
if _, err := log.SetupZapLogger(log.GetDefaultLogOpts()); err != nil {
t.Fatalf("Failed to setup logger: %v", err)
}
cache := NewStandaloneCache()

emptyPodInfo := cache.GetPod(ip)
if emptyPodInfo != nil {
t.Fatalf("Expected nil, got %v", emptyPodInfo)
}

cache.ProcessPodInfo(ip, defaultInfo)
podInfo := cache.GetPod(ip)

if podInfo == nil {
t.Fatalf("Expected pod info, got nil")
}
assert.Equal(t, podInfo.Name, name)
assert.Equal(t, podInfo.Namespace, namespace)
}

func TestDeletePod(t *testing.T) {
if _, err := log.SetupZapLogger(log.GetDefaultLogOpts()); err != nil {
t.Fatalf("Failed to setup logger: %v", err)
}
cache := NewStandaloneCache()

// Add pod
cache.ProcessPodInfo(ip, defaultInfo)
podInfo := cache.GetPod(ip)
if podInfo == nil {
t.Fatalf("Expected pod info, got nil")
}

// Attempt to delete pod not in cache
cache.ProcessPodInfo("9.9.9.9", nil)
podInfo1 := cache.GetPod(ip)
if podInfo1 == nil {
t.Fatalf("Expected pod info, got nil")
}

// Delete pod
cache.ProcessPodInfo(ip, nil)
deletedPodInfo := cache.GetPod(ip)
if deletedPodInfo != nil {
t.Fatalf("Expected nil, got %v", deletedPodInfo)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

these tests seems to be testing ProcessPodInfo. Consider adding to a single function TestProcessPodInfo and use table driven tests to test several behaviors of the method (https://dave.cheney.net/2019/05/07/prefer-table-driven-tests)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants