Skip to content

Commit dc566e1

Browse files
committed
removed wrapper and reverted path marshall directly
Signed-off-by: Sanskarzz <sanskar.gur@gmail.com>
1 parent f96d0af commit dc566e1

2 files changed

Lines changed: 4 additions & 40 deletions

File tree

cmd/thv-operator/controllers/virtualmcpserver_vmcpconfig.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,9 @@ func (r *VirtualMCPServerReconciler) ensureVmcpConfigConfigMap(
8282
}
8383

8484
// Marshal the serializable Config to YAML for storage in ConfigMap.
85-
// RateLimiting is a top-level VirtualMCPServer spec field, not part of
86-
// spec.config, so add it only when writing the runtime ConfigMap.
8785
// Note: gopkg.in/yaml.v3 produces deterministic output by sorting map keys alphabetically.
8886
// This ensures stable checksums for triggering pod rollouts only when content actually changes.
89-
vmcpConfigYAML, err := yaml.Marshal(vmcpConfigMapConfig{
90-
Config: *config,
91-
RateLimiting: vmcp.Spec.RateLimiting,
92-
})
87+
vmcpConfigYAML, err := yaml.Marshal(config)
9388
if err != nil {
9489
return fmt.Errorf("failed to marshal vmcp config: %w", err)
9590
}
@@ -135,12 +130,6 @@ func (r *VirtualMCPServerReconciler) ensureVmcpConfigConfigMap(
135130
return nil
136131
}
137132

138-
type vmcpConfigMapConfig struct {
139-
vmcpconfig.Config `yaml:",inline"`
140-
141-
RateLimiting *mcpv1beta1.RateLimitConfig `yaml:"rateLimiting,omitempty"`
142-
}
143-
144133
// populateOptimizerEmbeddingService wires the EmbeddingServer URL into the optimizer
145134
// config and emits warnings for non-recommended configurations.
146135
//

cmd/thv-operator/controllers/virtualmcpserver_vmcpconfig_test.go

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -459,25 +459,6 @@ func TestEnsureVmcpConfigConfigMap(t *testing.T) {
459459
},
460460
Spec: mcpv1beta1.VirtualMCPServerSpec{
461461
GroupRef: &mcpv1beta1.MCPGroupRef{Name: "test-group"},
462-
SessionStorage: &mcpv1beta1.SessionStorageConfig{
463-
Provider: mcpv1beta1.SessionStorageProviderRedis,
464-
Address: "redis.default.svc.cluster.local:6379",
465-
},
466-
RateLimiting: &mcpv1beta1.RateLimitConfig{
467-
PerUser: &mcpv1beta1.RateLimitBucket{
468-
MaxTokens: 2,
469-
RefillPeriod: metav1.Duration{Duration: time.Minute},
470-
},
471-
Tools: []mcpv1beta1.ToolRateLimitConfig{
472-
{
473-
Name: "backend_a_echo",
474-
Shared: &mcpv1beta1.RateLimitBucket{
475-
MaxTokens: 5,
476-
RefillPeriod: metav1.Duration{Duration: time.Minute},
477-
},
478-
},
479-
},
480-
},
481462
},
482463
}
483464

@@ -527,16 +508,10 @@ func TestEnsureVmcpConfigConfigMap(t *testing.T) {
527508
assert.Contains(t, cm.Data, "config.yaml")
528509
assert.NotEmpty(t, cm.Annotations["toolhive.stacklok.dev/content-checksum"])
529510

530-
var cfg vmcpConfigMapConfig
511+
var cfg vmcpconfig.Config
531512
require.NoError(t, yaml.Unmarshal([]byte(cm.Data["config.yaml"]), &cfg))
532-
require.NotNil(t, cfg.RateLimiting, "runtime config must include spec.rateLimiting")
533-
534-
require.NotNil(t, cfg.RateLimiting.PerUser)
535-
assert.EqualValues(t, 2, cfg.RateLimiting.PerUser.MaxTokens)
536-
require.Len(t, cfg.RateLimiting.Tools, 1)
537-
assert.Equal(t, "backend_a_echo", cfg.RateLimiting.Tools[0].Name)
538-
require.NotNil(t, cfg.RateLimiting.Tools[0].Shared)
539-
assert.EqualValues(t, 5, cfg.RateLimiting.Tools[0].Shared.MaxTokens)
513+
assert.Equal(t, "test-vmcp", cfg.Name)
514+
assert.Equal(t, "test-group", cfg.Group)
540515
}
541516

542517
// TestSetAuthConfigConditions tests that auth config conditions reflect the current state

0 commit comments

Comments
 (0)