fix: 295: Shell access to a SHM mounted workload#421
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
Walkthrough
ChangesService status and shell handling
Estimated code review effort: 3 (Moderate) | ~15–30 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cluster/kube/client.go (1)
1098-1105: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueSimplify the loop and limit variable scope.
You can make the loop slightly more idiomatic by iterating over the values directly and using a short variable declaration (
:=) inside theifstatement to avoid declaringpersistentin the outer scope.♻️ Proposed refactor
- persistent := false - for i := range svc.Resources.Storage { - attrVal := svc.Resources.Storage[i].Attributes.Find(sdl.StorageAttributePersistent) - if persistent, _ = attrVal.AsBool(); persistent { + for _, storage := range svc.Resources.Storage { + attrVal := storage.Attributes.Find(sdl.StorageAttributePersistent) + if persistent, _ := attrVal.AsBool(); persistent { isDeployment = false break }🤖 Prompt for 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. In `@cluster/kube/client.go` around lines 1098 - 1105, Update the loop over svc.Resources.Storage to iterate over storage values directly, and declare persistent with := inside the if condition alongside the attribute lookup and boolean conversion. Remove the outer persistent declaration while preserving the existing isDeployment update and break behavior.
🤖 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.
Nitpick comments:
In `@cluster/kube/client.go`:
- Around line 1098-1105: Update the loop over svc.Resources.Storage to iterate
over storage values directly, and declare persistent with := inside the if
condition alongside the attribute lookup and boolean conversion. Remove the
outer persistent declaration while preserving the existing isDeployment update
and break behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 6a0e8a96-9902-4c60-92c2-8b181d209793
📒 Files selected for processing (3)
cluster/kube/client.gocluster/kube/client_test.gogateway/rest/router.go
#295) This commit addresses two critical issues in the Akash provider: 1. StatefulSet Detection Fix: - Fixed incorrect logic in ServiceStatus that was checking for any mounted storage instead of persistent storage to determine workload type - The bug caused services with RAM volumes to incorrectly attempt StatefulSet operations, resulting in "statefulsets.apps not found" errors - Now correctly checks storage.Attributes.Find(sdl.StorageAttributePersistent) to match the deployment creation logic 2. WebSocket Error Handling in lease-shell: - Fixed improper error handling when ServiceStatus fails during shell operations - Previously used http.Error() on WebSocket connections, causing protocol violations - Now properly uses WebSocket writer with LeaseShellCodeFailure and logs errors - Prevents silent failures and improves debugging for shell access issues Added comprehensive unit tests for StatefulSet detection logic covering: - Services with persistent storage (should use StatefulSet) - Services with non-persistent storage (should use Deployment) - Services with no storage (should use Deployment) These fixes ensure proper workload type detection and improve error visibility for lease-shell operations, resolving issues with shell access to deployments using RAM volumes. Co-Authored-By: Zach Taylor <zctaylor.work@gmail.com>
2d7f499 to
2e6fd08
Compare
Closes akash-network/support#295
Rebased version of #310 onto current
main. The original PR conflicted becausemainmigrated its API imports fromgithub.com/akash-network/akash-api/github.com/akash-network/nodetopkg.akt.dev/go; the changes here are ported to the new packages (rtypes,attrtypes,pkg.akt.dev/go/sdl) and the tests were adjusted for the currentServiceStatusfield types (int32) and the StatefulSetCurrentReplicasfield.This addresses an issue with the provider when attempting to SSH to a lease with a shared memory mount. It also corrects a websocket protocol violation on error (encountered while debugging the SHM issue). The core issue was that when the lease-shell command attempted to connect, it would try to do so on a StatefulSet due to detecting a volume on the deployment. Having it follow the convention of the
Deploy()function lets it connect to the deployment properly.1. StatefulSet Detection Fix
ServiceStatusthat was checking for any mounted storage instead of persistent storage to determine workload type.statefulsets.apps not founderrors.storage.Attributes.Find(sdl.StorageAttributePersistent)to match the deployment creation logic.2. WebSocket Error Handling in lease-shell
ServiceStatusfails during shell operations.http.Error()on WebSocket connections, causing protocol violations.LeaseShellCodeFailureand logs errors.Tests
Added unit tests for StatefulSet detection logic covering: