Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make VM image mandatory #65

Merged
merged 2 commits into from
Apr 8, 2024
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
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ roleRef:

## Configuration

| Key | Description | Is Mandatory | Remarks |
|----------------------------------------------|-----------------------------------------------------------------|--------------|------------------------------------------------------------------|
| spec.timeout | How much time before the checkup will try to close itself | True | |
| spec.param.vmUnderTestContainerDiskImage | VM under test container disk image | False | Defaults to `quay.io/kiagnose/kubevirt-realtime-checkup-vm:main` |
| spec.param.vmUnderTestTargetNodeName | Node Name on which the VM under test will be scheduled to | False | Assumed to be configured to nodes that allow realtime traffic |
| spec.param.oslatDuration | How much time will the oslat program run | False | Defaults to TBD |
| spec.param.oslatLatencyThresholdMicroSeconds | A latency higher than this value will cause the checkup to fail | False | Defaults to TBD |
| Key | Description | Is Mandatory | Remarks |
|----------------------------------------------|-----------------------------------------------------------------|--------------|---------------------------------------------------------------|
| spec.timeout | How much time before the checkup will try to close itself | True | |
| spec.param.vmUnderTestContainerDiskImage | VM under test container disk image | True | |
| spec.param.vmUnderTestTargetNodeName | Node Name on which the VM under test will be scheduled to | False | Assumed to be configured to nodes that allow realtime traffic |
| spec.param.oslatDuration | How much time will the oslat program run | False | Defaults to TBD |
| spec.param.oslatLatencyThresholdMicroSeconds | A latency higher than this value will cause the checkup to fail | False | Defaults to TBD |

### Example

Expand All @@ -82,6 +82,7 @@ metadata:
name: realtime-checkup-config
data:
spec.timeout: 10m
spec.param.vmUnderTestContainerDiskImage: quay.io/kiagnose/kubevirt-realtime-checkup-vm:main
spec.param.oslatDuration: 1h
```

Expand Down
12 changes: 6 additions & 6 deletions pkg/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ const (
const (
VMIPassword = "redhat" // #nosec

VMUnderTestDefaultContainerDiskImage = "quay.io/kiagnose/kubevirt-realtime-checkup-vm:main"
OslatDefaultDuration = 5 * time.Minute
OslatDefaultLatencyThreshold = 40 * time.Microsecond
OslatDefaultDuration = 5 * time.Minute
OslatDefaultLatencyThreshold = 40 * time.Microsecond

BootScriptName = "realtime-checkup-boot.sh"
BootScriptBinDirectory = "/usr/bin/"
Expand All @@ -48,6 +47,7 @@ const (
)

var (
ErrInvalidVMContainerDiskImage = errors.New("invalid VM container disk image")
ErrInvalidOslatDuration = errors.New("invalid oslat duration")
ErrInvalidOslatLatencyThreshold = errors.New("invalid oslat latency threshold")
)
Expand All @@ -66,13 +66,13 @@ func New(baseConfig kconfig.Config) (Config, error) {
PodName: baseConfig.PodName,
PodUID: baseConfig.PodUID,
VMUnderTestTargetNodeName: baseConfig.Params[VMUnderTestTargetNodeNameParamName],
VMUnderTestContainerDiskImage: VMUnderTestDefaultContainerDiskImage,
VMUnderTestContainerDiskImage: baseConfig.Params[VMUnderTestContainerDiskImageParamName],
OslatDuration: OslatDefaultDuration,
OslatLatencyThreshold: OslatDefaultLatencyThreshold,
}

if rawVal := baseConfig.Params[VMUnderTestContainerDiskImageParamName]; rawVal != "" {
newConfig.VMUnderTestContainerDiskImage = rawVal
if newConfig.VMUnderTestContainerDiskImage == "" {
return Config{}, ErrInvalidVMContainerDiskImage
}

if rawOslatDuration := baseConfig.Params[OslatDurationParamName]; rawOslatDuration != "" {
Expand Down
25 changes: 17 additions & 8 deletions pkg/internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ func TestNewShouldApplyDefaultsWhenOptionalFieldsAreMissing(t *testing.T) {
baseConfig := kconfig.Config{
PodName: testPodName,
PodUID: testPodUID,
Params: map[string]string{},
Params: map[string]string{
config.VMUnderTestContainerDiskImageParamName: testVMContainerDiskImage,
},
}

actualConfig, err := config.New(baseConfig)
Expand All @@ -53,7 +55,7 @@ func TestNewShouldApplyDefaultsWhenOptionalFieldsAreMissing(t *testing.T) {
PodName: testPodName,
PodUID: testPodUID,
VMUnderTestTargetNodeName: "",
VMUnderTestContainerDiskImage: config.VMUnderTestDefaultContainerDiskImage,
VMUnderTestContainerDiskImage: testVMContainerDiskImage,
OslatDuration: config.OslatDefaultDuration,
OslatLatencyThreshold: config.OslatDefaultLatencyThreshold,
}
Expand Down Expand Up @@ -94,21 +96,28 @@ func TestNewShouldFailWhen(t *testing.T) {
}

testCases := []failureTestCase{
{
description: "VM container disk image is missing",
userParameters: map[string]string{},
expectedError: config.ErrInvalidVMContainerDiskImage,
},
{
description: "oslatDuration is invalid",
userParameters: map[string]string{
config.VMUnderTestTargetNodeNameParamName: testVMUnderTestTargetNodeName,
config.OslatDurationParamName: "wrongValue",
config.OslatLatencyThresholdParamName: testOslatLatencyThresholdMicroSeconds,
config.VMUnderTestContainerDiskImageParamName: testVMContainerDiskImage,
config.VMUnderTestTargetNodeNameParamName: testVMUnderTestTargetNodeName,
config.OslatDurationParamName: "wrongValue",
config.OslatLatencyThresholdParamName: testOslatLatencyThresholdMicroSeconds,
},
expectedError: config.ErrInvalidOslatDuration,
},
{
description: "oslatLatencyThresholdMicroSeconds is invalid",
userParameters: map[string]string{
config.VMUnderTestTargetNodeNameParamName: testVMUnderTestTargetNodeName,
config.OslatDurationParamName: testOslatDuration,
config.OslatLatencyThresholdParamName: "wrongValue",
config.VMUnderTestContainerDiskImageParamName: testVMContainerDiskImage,
config.VMUnderTestTargetNodeNameParamName: testVMUnderTestTargetNodeName,
config.OslatDurationParamName: testOslatDuration,
config.OslatLatencyThresholdParamName: "wrongValue",
},
expectedError: config.ErrInvalidOslatLatencyThreshold,
},
Expand Down
Loading