Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions extensions/controllers/sandboxclaim_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 1 addition & 6 deletions internal/lifecycle/expiry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
}

Expand Down
9 changes: 0 additions & 9 deletions pkg/e2bcompat/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package e2bcompat
import (
"encoding/json"
"net/http"

"k8s.io/apiserver/pkg/storage/names"
)

const (
Expand All @@ -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")
Expand Down
3 changes: 2 additions & 1 deletion pkg/e2bcompat/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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),
Expand Down