Files
cozystack/internal/gpu/controller/setup_test.go
Aleksei Sviridkin ef53ba9070 fix(gpu): keep template device names and marks within API limits
A VMI name can be a 253-character DNS subdomain, and worker VMIs
named after Cluster API machines do grow long. Carried as a label
value it fails the 63-character limit, and with a suffix appended it
fails the name limit, so the webhook could not create the template
device at all. The mark is now a plain "true", and a name too long
for the suffix is shortened with a hash of the full VMI name.

The device-reference parser also refused nothing after the JSON list,
so a malformed annotation could pass as valid.

Fixes: a11737a2dd ("feat(gpu): fix the shared GPU keys, settings and binding contract")

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-10-20 15:42:36 +03:00

32 lines
931 B
Go

/*
Copyright 2026 The Cozystack Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package controller
import (
"testing"
"github.com/cozystack/cozystack/internal/gpu"
)
// Setup may be called before any reconciler exists: it must succeed and
// touch nothing, so it accepts a nil manager.
func TestSetupWithoutReconcilersIsANoOp(t *testing.T) {
if err := Setup(nil, gpu.Config{Enabled: true}); err != nil {
t.Fatalf("Setup: %v", err)
}
}