Skip to content
Open
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
1 change: 1 addition & 0 deletions .github/linters/urunc-dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ derr
ldconfig
vfsd
crun
Rlimits
vaccel
VACCEL
vsock
Expand Down
7 changes: 7 additions & 0 deletions pkg/unikontainers/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,18 @@ type RootfsParams struct {
MonRootfs string // The rootfs for the monitor process
}

type Rlimit struct {
Type string
Hard uint64
Soft uint64
}

// Specific to Linux
type ProcessConfig struct {
UID uint32 // The uid of the process inside the guest
GID uint32 // The gid of the process inside the guest
WorkDir string // The workdir of the process inside the guest
Rlimits []Rlimit
}

// UnikernelParams holds the data required to build the unikernels commandline
Expand Down
9 changes: 9 additions & 0 deletions pkg/unikontainers/unikernels/linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,15 @@ func (l *Linux) buildUrunitConfig() string {
sb.WriteString("WD:")
sb.WriteString(l.ProcConfig.WorkDir)
sb.WriteString("\n")
for _, limit := range l.ProcConfig.Rlimits {
sb.WriteString("RLIMIT:")
sb.WriteString(limit.Type)
sb.WriteString(":")
sb.WriteString(strconv.FormatUint(limit.Hard, 10))
sb.WriteString(":")
sb.WriteString(strconv.FormatUint(limit.Soft, 10))
sb.WriteString("\n")
}
sb.WriteString(lpcEndMarker)
sb.WriteString("\n")
sb.WriteString(blkStartMarker)
Expand Down
10 changes: 10 additions & 0 deletions pkg/unikontainers/unikontainers.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,16 @@ func (u *Unikontainer) Exec(metrics m.Writer) error {
GID: u.Spec.Process.User.GID,
WorkDir: u.Spec.Process.Cwd,
}

if u.Spec.Process.Rlimits != nil {
for _, rl := range u.Spec.Process.Rlimits {
procAttrs.Rlimits = append(procAttrs.Rlimits, types.Rlimit{
Type: rl.Type,
Hard: rl.Hard,
Soft: rl.Soft,
})
}
}
// UnikernelParams
// populate unikernel params
unikernelParams := types.UnikernelParams{
Expand Down
Loading