diff --git a/extensions/controllers/sandboxclaim_controller.go b/extensions/controllers/sandboxclaim_controller.go index 8c0da5c..d3f9c07 100644 --- a/extensions/controllers/sandboxclaim_controller.go +++ b/extensions/controllers/sandboxclaim_controller.go @@ -1177,7 +1177,7 @@ func (r *SandboxClaimReconciler) sandboxFromStatus(ctx context.Context, claim *e // still owned by the warm pool means an adoption is half-finished, which this // completes. func (r *SandboxClaimReconciler) sandboxFromClaimMetadata(ctx context.Context, claim *extensionsv1beta1.SandboxClaim) (*v1beta1.Sandbox, error) { - sbName := assignedSandboxName(claim) + sbName := claim.Annotations[extensionsv1beta1.AssignedSandboxNameAnnotation] if sbName == "" { return nil, nil } @@ -1898,11 +1898,6 @@ func validateVolumeClaimTemplates(vcts []v1beta1.PersistentVolumeClaimTemplate) return nil } -// assignedSandboxName reads the assigned-sandbox annotation. -func assignedSandboxName(claim *extensionsv1beta1.SandboxClaim) string { - return claim.Annotations[extensionsv1beta1.AssignedSandboxNameAnnotation] -} - // warmPoolRefIndexer indexes SandboxClaims by spec.warmPoolRef.name. func warmPoolRefIndexer(rawObj client.Object) []string { claim, ok := rawObj.(*extensionsv1beta1.SandboxClaim) diff --git a/internal/lifecycle/expiry.go b/internal/lifecycle/expiry.go index e8ab257..0e18c5a 100644 --- a/internal/lifecycle/expiry.go +++ b/internal/lifecycle/expiry.go @@ -42,11 +42,6 @@ func TimeLeft(now time.Time, shutdownTime *metav1.Time, ttlSecondsAfterFinished return false, expireAt.Sub(now) } -// needsCleanup reports whether ttl-after-finished cleanup applies. -func needsCleanup(ttlSecondsAfterFinished *int32, finishedCondition *metav1.Condition) bool { - return ttlSecondsAfterFinished != nil && finishedCondition != nil -} - // finishedTime returns the finish timestamp encoded in the terminal condition. func finishedTime(finishedCondition *metav1.Condition) *time.Time { if finishedCondition == nil || finishedCondition.LastTransitionTime.IsZero() { @@ -64,7 +59,7 @@ func expireAtFor(shutdownTime *metav1.Time, ttlSecondsAfterFinished *int32, fini expireAt = &shutdownAt } - if !needsCleanup(ttlSecondsAfterFinished, finishedCondition) { + if ttlSecondsAfterFinished == nil || finishedCondition == nil { return expireAt } diff --git a/pkg/e2bcompat/http.go b/pkg/e2bcompat/http.go index ce9de5e..82169f9 100644 --- a/pkg/e2bcompat/http.go +++ b/pkg/e2bcompat/http.go @@ -3,8 +3,6 @@ package e2bcompat import ( "encoding/json" "net/http" - - "k8s.io/apiserver/pkg/storage/names" ) const ( @@ -17,13 +15,6 @@ const ( namePrefix = "e2b-" ) -// generateName returns a fresh Kubernetes-safe name for a compat claim. e2b -// clients do not name their sandboxes; the identity a caller sees back is the -// node-assigned claim id, not this name. -func generateName() string { - return names.SimpleNameGenerator.GenerateName(namePrefix) -} - // writeJSON writes v as the response body with the given status. func writeJSON(w http.ResponseWriter, status int, v any) { w.Header().Set("Content-Type", "application/json") diff --git a/pkg/e2bcompat/server.go b/pkg/e2bcompat/server.go index 81ea6b4..e7c12db 100644 --- a/pkg/e2bcompat/server.go +++ b/pkg/e2bcompat/server.go @@ -30,6 +30,7 @@ import ( "github.com/go-logr/logr" k8serrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apiserver/pkg/storage/names" sandboxv1beta1 "github.com/cocoonstack/sandbox-operator/api/v1beta1" "github.com/cocoonstack/sandbox-operator/pkg/scale" @@ -196,7 +197,7 @@ func (s *Server) createSandbox(w http.ResponseWriter, r *http.Request) { return } - name := generateName() + name := names.SimpleNameGenerator.GenerateName(namePrefix) pool := scale.PoolKey{ Template: req.TemplateID, Net: netFor(req.AllowInternetAccess),