-
Notifications
You must be signed in to change notification settings - Fork 137
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
CNF-15235: cnf-tests: move to rhel 9 #2139
Merged
+138
−17
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
61ff80f
cnf-tests:ocp:dockerfile: use rhel-9-golang builders
Tal-or b08ae08
cnf-tests:ocp:dockerfile: use oc-rpms from 4.19
Tal-or 0165d5e
cnf-tests:ocp:dockerfile: use rhel-9 as cnf-tests base image
Tal-or 963727b
cnf-tests:ocp:dockerfile: remove libhugetlbfs package
Tal-or 399ad8c
cnf-tests: introduce hugepages-allocator
Tal-or f497b24
cnf-tests:dockerfile: add hugepages-allocator to `Dockerfile` as well
Tal-or 8215d2d
cnf-tests:dockerfile: use rhel9 builders
Tal-or b8df9f2
cnf-tests: change test to use hugepages-allocator
Tal-or 0ec464f
cnf-tests: bump cnf-tests images -> 4.18
Tal-or File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"math" | ||
"os" | ||
"os/signal" | ||
"syscall" | ||
"time" | ||
"unsafe" | ||
|
||
"k8s.io/klog/v2" | ||
) | ||
|
||
const ( | ||
// MapHugeShift Shift for HugePage size | ||
MapHugeShift = 26 | ||
// DefaultHugePageSize 1GB HugePage size | ||
DefaultHugePageSize = 1 * 1024 * 1024 * 1024 | ||
) | ||
|
||
// MAP_HUGE_1GB 1GB HugePage mmap flag | ||
const MAP_HUGE_1GB = 30 << MapHugeShift | ||
|
||
type Args struct { | ||
TimeDuration time.Duration | ||
HugePageSize int | ||
} | ||
|
||
func main() { | ||
klog.InitFlags(nil) | ||
args := &Args{} | ||
flag.DurationVar(&args.TimeDuration, "time-duration", math.MaxInt64, "set the time duration for program to wait - wait forever by default") | ||
flag.IntVar(&args.HugePageSize, "hugepage-size", DefaultHugePageSize, "hugepage size to allocate - allocate 1G by default") | ||
|
||
flag.Parse() | ||
|
||
// Flags for HugePage allocation | ||
mmapFlags := syscall.MAP_PRIVATE | syscall.MAP_ANONYMOUS | syscall.MAP_HUGETLB | MAP_HUGE_1GB | ||
// Use mmap to allocate memory | ||
addr, _, errno := syscall.Syscall6( | ||
syscall.SYS_MMAP, | ||
0, // Let the kernel choose the address | ||
uintptr(args.HugePageSize), // Size of the memory | ||
uintptr(syscall.PROT_READ|syscall.PROT_WRITE), // Read/Write permissions | ||
uintptr(mmapFlags), // mmap flags | ||
0, // File descriptor (not used for anonymous memory) | ||
0, // Offset | ||
) | ||
if errno != 0 { | ||
klog.ErrorS(fmt.Errorf("errno=%v", errno), "Failed to allocate HugePage") | ||
os.Exit(1) | ||
} | ||
memory := unsafe.Pointer(addr) | ||
// Write a byte to the allocated memory | ||
*(*byte)(memory) = 42 | ||
|
||
klog.InfoS("Successfully allocated 1GB HugePage memory", "address", fmt.Sprintf("%p", unsafe.Pointer(addr))) | ||
|
||
// Cleanup: Unmap the memory | ||
defer func() { | ||
_, _, errno = syscall.Syscall(syscall.SYS_MUNMAP, addr, uintptr(args.HugePageSize), 0) | ||
if errno != 0 { | ||
klog.ErrorS(fmt.Errorf("errno=%v", errno), "Failed to unmap HugePage") | ||
os.Exit(2) | ||
} | ||
klog.InfoS("1GB HugePage memory unmapped successfully") | ||
}() | ||
wait(args.TimeDuration) | ||
} | ||
|
||
func wait(timeout time.Duration) { | ||
// Create a channel to listen for signals. | ||
signalChan := make(chan os.Signal, 1) | ||
|
||
// SIGINT handles Ctrl+C locally. | ||
// SIGTERM handles Cloud Run termination signal. | ||
signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM) | ||
|
||
klog.InfoS("Waiting", "period", timeout.String()) | ||
select { | ||
// Receive output from signalChan. | ||
case sig := <-signalChan: | ||
klog.InfoS("signal caught", "signal", sig) | ||
case <-time.After(timeout): | ||
klog.InfoS("Done") | ||
return | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to update this one also
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was on purpose actually, if we're changing to rhel9 then both
Dockerfile
andDockerfile.openshift
are identical. So one can be deleted