-
Notifications
You must be signed in to change notification settings - Fork 6
fix(OPENFRAM-007): 3 review findings in manager.go #351
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ import ( | |
|
|
||
| "github.com/flamingo-stack/openframe-cli/internal/cluster/models" | ||
| "github.com/flamingo-stack/openframe-cli/internal/shared/executor" | ||
| "github.com/pterm/pterm" | ||
| "k8s.io/client-go/rest" | ||
| ) | ||
|
|
||
|
|
@@ -68,7 +69,7 @@ func (m *K3dManager) CreateCluster(ctx context.Context, config models.ClusterCon | |
| // This must be done before cluster creation as it affects the Docker/WSL host | ||
| if err := m.increaseInotifyLimits(ctx); err != nil { | ||
| if m.verbose { | ||
| fmt.Printf("Warning: Could not increase inotify limits: %v\n", err) | ||
| pterm.Warning.Printf("Could not increase inotify limits: %v\n", err) | ||
| } | ||
| // Don't fail - cluster might still work if limits are already sufficient | ||
| } | ||
|
|
@@ -82,22 +83,22 @@ func (m *K3dManager) CreateCluster(ctx context.Context, config models.ClusterCon | |
|
|
||
| if m.verbose { | ||
| if configContent, err := os.ReadFile(configFile); err == nil { // #nosec G304 -- reads a temp config file this process just created | ||
| fmt.Printf("DEBUG: Config file content for %s:\n%s\n", config.Name, string(configContent)) | ||
| pterm.Debug.Printf("Config file content for %s:\n%s\n", config.Name, string(configContent)) | ||
| } | ||
| } | ||
|
|
||
| // Prepare kubeconfig directory before k3d operations (Windows/WSL and Linux CI) | ||
| if err := m.prepareKubeconfigDirectory(ctx); err != nil { | ||
| if m.verbose { | ||
| fmt.Printf("Warning: Could not prepare kubeconfig directory: %v\n", err) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π fmt.Printf DEBUG dump of config file bypasses pterm/--silent contract In π€ Prompt for AI agentsfix confidence: π‘ 85 medium β react π/π to teach the reviewer |
||
| pterm.Warning.Printf("Could not prepare kubeconfig directory: %v\n", err) | ||
| } | ||
| // Don't fail - k3d will create it, but log the warning | ||
| } | ||
|
|
||
| // Clean up any stale lock files that might prevent k3d from updating kubeconfig | ||
| if err := m.cleanupStaleLockFiles(ctx); err != nil { | ||
| if m.verbose { | ||
| fmt.Printf("Warning: Could not cleanup stale lock files: %v\n", err) | ||
| pterm.Warning.Printf("Could not cleanup stale lock files: %v\n", err) | ||
| } | ||
| // Don't fail - this is not critical | ||
| } | ||
|
|
@@ -122,7 +123,7 @@ func (m *K3dManager) CreateCluster(ctx context.Context, config models.ClusterCon | |
| // This is necessary because k3d creates ~/.kube/config with root ownership when run with sudo | ||
| if err := m.fixKubeconfigPermissions(ctx); err != nil { | ||
| if m.verbose { | ||
| fmt.Printf("Warning: Could not fix kubeconfig permissions: %v\n", err) | ||
| pterm.Warning.Printf("Could not fix kubeconfig permissions: %v\n", err) | ||
| } | ||
| // Don't fail - this is not critical, just log the warning | ||
| } | ||
|
|
@@ -131,7 +132,7 @@ func (m *K3dManager) CreateCluster(ctx context.Context, config models.ClusterCon | |
| // This is critical because lock files may have been created with root ownership | ||
| if err := m.cleanupStaleLockFiles(ctx); err != nil { | ||
| if m.verbose { | ||
| fmt.Printf("Warning: Could not cleanup lock files after permission fix: %v\n", err) | ||
| pterm.Warning.Printf("Could not cleanup lock files after permission fix: %v\n", err) | ||
| } | ||
| // Don't fail - this is not critical | ||
| } | ||
|
|
@@ -188,15 +189,15 @@ func (m *K3dManager) DeleteCluster(ctx context.Context, name string, clusterType | |
| // No Windows branch: the CLI forwards into WSL and runs as linux (see wsllauncher). | ||
| if force { | ||
| if m.verbose { | ||
| fmt.Printf("k3d delete failed, attempting direct Docker cleanup for cluster %s: %v\n", name, err) | ||
| pterm.Warning.Printf("k3d delete failed, attempting direct Docker cleanup for cluster %s: %v\n", name, err) | ||
| } | ||
| if cleanupErr := m.forceCleanupDockerContainers(ctx, name); cleanupErr != nil { | ||
| // Return original error if cleanup also fails | ||
| return models.NewClusterOperationError("delete", name, fmt.Errorf("failed to delete cluster %s (cleanup also failed: %w): %w", name, cleanupErr, err)) | ||
| } | ||
| // Cleanup succeeded, cluster is removed | ||
| if m.verbose { | ||
| fmt.Printf("β Cluster %s removed via direct Docker cleanup\n", name) | ||
| pterm.Success.Printf("Cluster %s removed via direct Docker cleanup\n", name) | ||
| } | ||
| return nil | ||
| } | ||
|
Comment on lines
189
to
203
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π fmt.Printf success/warning messages in DeleteCluster fallback path bypass pterm In π€ Prompt for AI agentsfix confidence: π‘ 80 medium β react π/π to teach the reviewer |
||
|
|
@@ -233,15 +234,15 @@ func (m *K3dManager) forceCleanupDockerContainers(ctx context.Context, clusterNa | |
| id = strings.TrimSpace(id) | ||
| if id != "" { | ||
| if _, rerr := m.executor.Execute(ctx, "docker", "rm", "-f", id); rerr != nil && m.verbose { | ||
| fmt.Printf("Warning: failed to remove container %s: %v\n", id, rerr) | ||
| pterm.Warning.Printf("failed to remove container %s: %v\n", id, rerr) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Also remove the network | ||
| if _, nerr := m.executor.Execute(ctx, "docker", "network", "rm", fmt.Sprintf("k3d-%s", clusterName)); nerr != nil && m.verbose { | ||
| fmt.Printf("Warning: failed to remove k3d network for %s: %v\n", clusterName, nerr) | ||
| pterm.Warning.Printf("failed to remove k3d network for %s: %v\n", clusterName, nerr) | ||
| } | ||
|
|
||
| return nil | ||
|
|
@@ -523,14 +524,14 @@ func (m *K3dManager) increaseInotifyLimitsFor(ctx context.Context, goos string) | |
| } | ||
|
|
||
| if m.verbose { | ||
| fmt.Printf("β Increased inotify limits in WSL (max_user_watches=%d, max_user_instances=%d)\n", | ||
| pterm.Success.Printf("Increased inotify limits in WSL (max_user_watches=%d, max_user_instances=%d)\n", | ||
| maxUserWatches, maxUserInstances) | ||
| } | ||
| default: // linux | ||
| // Skip the privileged write when the current limits already suffice. | ||
| if m.inotifyLimitsSufficient(ctx, maxUserWatches, maxUserInstances) { | ||
| if m.verbose { | ||
| fmt.Println("β inotify limits already sufficient") | ||
| pterm.Success.Println("inotify limits already sufficient") | ||
| } | ||
| return nil | ||
| } | ||
|
|
@@ -548,7 +549,7 @@ func (m *K3dManager) increaseInotifyLimitsFor(ctx context.Context, goos string) | |
| } | ||
|
|
||
| if m.verbose { | ||
| fmt.Printf("β Increased inotify limits (max_user_watches=%d, max_user_instances=%d)\n", | ||
| pterm.Success.Printf("Increased inotify limits (max_user_watches=%d, max_user_instances=%d)\n", | ||
| maxUserWatches, maxUserInstances) | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
𦩠π Raw fmt.Printf used for user-facing warnings in K3dManager.CreateCluster/DeleteCluster instead of pterm
In
CreateCluster, replacedfmt.Printf("Warning: ...")calls (inotify limits, kubeconfig directory prep, stale lock file cleanup, permission fix, post-permission lock cleanup) withpterm.Warning.Printf(...), dropping the redundant "Warning: " prefix sincepterm.Warningalready renders a warning-level prefix. Also applied the same substitution to the analogous warnings inforceCleanupDockerContainersandincreaseInotifyLimitsFor(container/network removal failures) and converted their verbose success messages (fmt.Printf("β ...")/fmt.Println("β ...")) topterm.Success.Printf/pterm.Success.Printlnfor consistency with the pterm-based UI contract; added thegithub.com/pterm/ptermimport.π€ Prompt for AI agents
fix confidence: π‘ 88 medium β react π/π to teach the reviewer