Skip to content

Commit 59e4399

Browse files
yroblataskbot
andauthored
fix: remove tokencache from vmcp (#2799)
It is not currently used and adds complexity Co-authored-by: taskbot <[email protected]>
1 parent 80ebee6 commit 59e4399

19 files changed

+2
-936
lines changed

cmd/thv-operator/api/v1alpha1/virtualmcpserver_types.go

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ type VirtualMCPServerSpec struct {
3434
// +optional
3535
CompositeToolRefs []CompositeToolDefinitionRef `json:"compositeToolRefs,omitempty"`
3636

37-
// TokenCache configures token caching behavior
38-
// +optional
39-
TokenCache *TokenCacheConfig `json:"tokenCache,omitempty"`
40-
4137
// Operational defines operational settings like timeouts and health checks
4238
// +optional
4339
Operational *OperationalConfig `json:"operational,omitempty"`
@@ -283,64 +279,6 @@ type ErrorHandling struct {
283279
RetryDelay string `json:"retryDelay,omitempty"`
284280
}
285281

286-
// TokenCacheConfig configures token caching behavior
287-
type TokenCacheConfig struct {
288-
// Provider defines the cache provider type
289-
// +kubebuilder:validation:Enum=memory;redis
290-
// +kubebuilder:default=memory
291-
// +optional
292-
Provider string `json:"provider,omitempty"`
293-
294-
// Memory configures in-memory token caching
295-
// Only used when Provider is "memory"
296-
// +optional
297-
Memory *MemoryCacheConfig `json:"memory,omitempty"`
298-
299-
// Redis configures Redis token caching
300-
// Only used when Provider is "redis"
301-
// +optional
302-
Redis *RedisCacheConfig `json:"redis,omitempty"`
303-
}
304-
305-
// MemoryCacheConfig configures in-memory token caching
306-
type MemoryCacheConfig struct {
307-
// MaxEntries is the maximum number of cache entries
308-
// +kubebuilder:default=1000
309-
// +optional
310-
MaxEntries int `json:"maxEntries,omitempty"`
311-
312-
// TTLOffset is the duration before token expiry to refresh
313-
// +kubebuilder:default="5m"
314-
// +optional
315-
TTLOffset string `json:"ttlOffset,omitempty"`
316-
}
317-
318-
// RedisCacheConfig configures Redis token caching
319-
type RedisCacheConfig struct {
320-
// Address is the Redis server address
321-
// +kubebuilder:validation:Required
322-
Address string `json:"address"`
323-
324-
// DB is the Redis database number
325-
// +kubebuilder:default=0
326-
// +optional
327-
DB int `json:"db,omitempty"`
328-
329-
// KeyPrefix is the prefix for cache keys
330-
// +kubebuilder:default="vmcp:tokens:"
331-
// +optional
332-
KeyPrefix string `json:"keyPrefix,omitempty"`
333-
334-
// PasswordRef references a secret containing the Redis password
335-
// +optional
336-
PasswordRef *SecretKeyRef `json:"passwordRef,omitempty"`
337-
338-
// TLS enables TLS for Redis connections
339-
// +kubebuilder:default=false
340-
// +optional
341-
TLS bool `json:"tls,omitempty"`
342-
}
343-
344282
// OperationalConfig defines operational settings
345283
type OperationalConfig struct {
346284
// Timeouts configures timeout settings

cmd/thv-operator/api/v1alpha1/virtualmcpserver_types_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,13 @@ func TestVirtualMCPServerDefaultValues(t *testing.T) {
147147
Aggregation: &AggregationConfig{
148148
ConflictResolution: "", // Should default to "prefix"
149149
},
150-
TokenCache: &TokenCacheConfig{
151-
Provider: "", // Should default to "memory"
152-
},
153150
},
154151
}
155152

156153
// These defaults are enforced by kubebuilder markers
157154
// but we document expected values here
158155
assert.NotNil(t, vmcp.Spec.OutgoingAuth)
159156
assert.NotNil(t, vmcp.Spec.Aggregation)
160-
assert.NotNil(t, vmcp.Spec.TokenCache)
161157
}
162158

163159
func TestVirtualMCPServerNamespaceIsolation(t *testing.T) {

cmd/thv-operator/api/v1alpha1/virtualmcpserver_webhook.go

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,6 @@ func (r *VirtualMCPServer) Validate() error {
7474
}
7575
}
7676

77-
// Validate TokenCache configuration
78-
if r.Spec.TokenCache != nil {
79-
if err := r.validateTokenCache(); err != nil {
80-
return err
81-
}
82-
}
83-
8477
return nil
8578
}
8679

@@ -355,39 +348,3 @@ func validateStepErrorHandling(toolIndex, stepIndex int, step WorkflowStep) erro
355348

356349
return nil
357350
}
358-
359-
// validateTokenCache validates token cache configuration
360-
func (r *VirtualMCPServer) validateTokenCache() error {
361-
cache := r.Spec.TokenCache
362-
363-
// Validate provider
364-
if cache.Provider != "" {
365-
validProviders := map[string]bool{
366-
"memory": true,
367-
"redis": true,
368-
}
369-
if !validProviders[cache.Provider] {
370-
return fmt.Errorf("spec.tokenCache.provider must be memory or redis")
371-
}
372-
}
373-
374-
// Validate provider-specific configuration
375-
if cache.Provider == "redis" || (cache.Provider == "" && cache.Redis != nil) {
376-
if cache.Redis == nil {
377-
return fmt.Errorf("spec.tokenCache.redis is required when provider is redis")
378-
}
379-
if cache.Redis.Address == "" {
380-
return fmt.Errorf("spec.tokenCache.redis.address is required")
381-
}
382-
if cache.Redis.PasswordRef != nil {
383-
if cache.Redis.PasswordRef.Name == "" {
384-
return fmt.Errorf("spec.tokenCache.redis.passwordRef.name is required when passwordRef is specified")
385-
}
386-
if cache.Redis.PasswordRef.Key == "" {
387-
return fmt.Errorf("spec.tokenCache.redis.passwordRef.key is required when passwordRef is specified")
388-
}
389-
}
390-
}
391-
392-
return nil
393-
}

cmd/thv-operator/api/v1alpha1/virtualmcpserver_webhook_test.go

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -369,67 +369,6 @@ func TestVirtualMCPServerValidate(t *testing.T) {
369369
wantErr: true,
370370
errMsg: "spec.compositeTools[0].steps[1].id \"step1\" is duplicated",
371371
},
372-
{
373-
name: "valid token cache - memory",
374-
vmcp: &VirtualMCPServer{
375-
Spec: VirtualMCPServerSpec{
376-
GroupRef: GroupRef{Name: "test-group"},
377-
TokenCache: &TokenCacheConfig{
378-
Provider: "memory",
379-
Memory: &MemoryCacheConfig{
380-
MaxEntries: 1000,
381-
},
382-
},
383-
},
384-
},
385-
wantErr: false,
386-
},
387-
{
388-
name: "valid token cache - redis with password",
389-
vmcp: &VirtualMCPServer{
390-
Spec: VirtualMCPServerSpec{
391-
GroupRef: GroupRef{Name: "test-group"},
392-
TokenCache: &TokenCacheConfig{
393-
Provider: "redis",
394-
Redis: &RedisCacheConfig{
395-
Address: "redis:6379",
396-
PasswordRef: &SecretKeyRef{
397-
Name: "redis-secret",
398-
Key: "password",
399-
},
400-
},
401-
},
402-
},
403-
},
404-
wantErr: false,
405-
},
406-
{
407-
name: "invalid token cache - redis without address",
408-
vmcp: &VirtualMCPServer{
409-
Spec: VirtualMCPServerSpec{
410-
GroupRef: GroupRef{Name: "test-group"},
411-
TokenCache: &TokenCacheConfig{
412-
Provider: "redis",
413-
Redis: &RedisCacheConfig{},
414-
},
415-
},
416-
},
417-
wantErr: true,
418-
errMsg: "spec.tokenCache.redis.address is required",
419-
},
420-
{
421-
name: "invalid token cache - invalid provider",
422-
vmcp: &VirtualMCPServer{
423-
Spec: VirtualMCPServerSpec{
424-
GroupRef: GroupRef{Name: "test-group"},
425-
TokenCache: &TokenCacheConfig{
426-
Provider: "invalid",
427-
},
428-
},
429-
},
430-
wantErr: true,
431-
errMsg: "spec.tokenCache.provider must be memory or redis",
432-
},
433372
}
434373

435374
for _, tt := range tests {

cmd/thv-operator/api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 0 additions & 65 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)