Skip to content

Commit

Permalink
Checkup: Move VMI name generation
Browse files Browse the repository at this point in the history
In order for the VMI under test and CM to have
the same random suffix - move the randomization
logic to the calling function.

Signed-off-by: Orel Misan <omisan@redhat.com>
  • Loading branch information
orelmisan committed Apr 8, 2024
1 parent 2a94b04 commit bee6c3a
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pkg/internal/checkup/checkup.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,14 @@ const (
)

func New(client kubeVirtVMIClient, namespace string, checkupConfig config.Config, executor testExecutor) *Checkup {
const randomStringLen = 5
randomSuffix := k8srand.String(randomStringLen)

return &Checkup{
client: client,
namespace: namespace,
vmUnderTestConfigMap: newVMUnderTestConfigMap(checkupConfig),
vmi: newRealtimeVMI(checkupConfig),
vmi: newRealtimeVMI(vmiUnderTestName(randomSuffix), checkupConfig),
executor: executor,
cfg: checkupConfig,
}
Expand Down Expand Up @@ -237,7 +240,7 @@ func newVMUnderTestConfigMap(checkupConfig config.Config) *corev1.ConfigMap {
vmUnderTestConfigData)
}

func newRealtimeVMI(checkupConfig config.Config) *kvcorev1.VirtualMachineInstance {
func newRealtimeVMI(name string, checkupConfig config.Config) *kvcorev1.VirtualMachineInstance {
const (
CPUSocketsCount = 1
CPUCoresCount = 4
Expand All @@ -250,7 +253,7 @@ func newRealtimeVMI(checkupConfig config.Config) *kvcorev1.VirtualMachineInstanc
configVolumeName = "realtime-config"
)

return vmi.New(randomizeName(VMINamePrefix),
return vmi.New(name,
vmi.WithOwnerReference(checkupConfig.PodName, checkupConfig.PodUID),
vmi.WithoutCRIOCPULoadBalancing(),
vmi.WithoutCRIOCPUQuota(),
Expand Down Expand Up @@ -314,10 +317,8 @@ func realtimeVMIBootCommands(configDiskSerial string) []string {
}
}

func randomizeName(prefix string) string {
const randomStringLen = 5

return fmt.Sprintf("%s-%s", prefix, k8srand.String(randomStringLen))
func vmiUnderTestName(suffix string) string {
return VMINamePrefix + "-" + suffix
}

func ObjectFullName(namespace, name string) string {
Expand Down

0 comments on commit bee6c3a

Please sign in to comment.