Skip to content

StartTransientUnit adding empty lines when given an array of structs #23938

@cdoern

Description

@cdoern

systemd version the issue has been seen with

systemd 249 (v249.12-5.fc35)

Used distribution

Fedora 35

Linux kernel version used

5.18.5-100.fc35.x86_64

CPU architectures issue was seen on

x86_64

Component

systemd

Expected behaviour you didn't see

[Unit]
Description=cgroup machine2-libpod_pod_123456789.slice
Wants=machine2.slice
DefaultDependencies=no

[Slice]
MemoryAccounting=yes
CPUAccounting=yes
BlockIOAccounting=yes
CPUQuota=100%
CPUWeight=4
MemoryMax=900
MemorySwapMax=1000
BlockIOWeight=300
CPUQuotaPeriodSec=100ms
AllowedCPUs=4-5
AllowedMemoryNodes=4-5
BlockIOReadBandwidth=3:10 2097152
io.max
3:10 2097152

Unexpected behaviour you saw

I am using godbus and coreos/go-systemd to create an array of properties and use these properties to create a transient unit file. However, one specific type a(st) is giving me some trouble and systemd seems to be either fumbling the handling or I am fumbling the setup. **godbus is giving me the proper syntax, something happens once I call StartTransientUnit` via go-systemd
I am here to ask, what is the correct format of this type? my array of properties looks like so:

[{Description "cgroup machine2-libpod_pod_12345.slice"} 
{Wants ["machine2.slice"]}{MemoryAccounting true}
{CPUAccounting true}{BlockIOAccounting true} 
{DefaultDependencies false}{BlockIOWeight @t 300} 
{CPUQuotaPeriodUSec @t 100000}
{CPUQuotaPerSecUSec @t 1000000}
{CPUWeight @t 4}
{MemoryMax @t 900} 
{MemorySwapMax @t 1000}
{AllowedCPUs @ay [0x30]} 
{AllowedMemoryNodes @ay [0x30]}
{BlockIOReadBandwidth @a(st) [("3:10" 2097152)]} ]

where the final entry is the array of structs. However, my transient unit file when generated looks like:

[Unit]
Description=cgroup machine2-libpod_pod_123456789.slice
Wants=machine2.slice
DefaultDependencies=no

[Slice]
MemoryAccounting=yes
CPUAccounting=yes
BlockIOAccounting=yes
CPUQuota=100%
CPUWeight=4
MemoryMax=900
MemorySwapMax=1000
BlockIOWeight=300
CPUQuotaPeriodSec=100ms
AllowedCPUs=4-5
AllowedMemoryNodes=4-5
BlockIOReadBandwidth=
BlockIOReadBandwidth=3:10 2097152

with strange extra lines added and no additions to the io.max file that the read bandwidth should impact. Again, not sure if this is even a systemd issue that is why I am asking the mailing list rather than filing an issue.

Steps to reproduce the problem

type BlkioBpsThrottle struct {
	Device   string
	Throttle uint64
}

structMap := make(map[string][]BlkioBpsThrottle)

structMap["BlockIOReadBandwidth"] = BlkioBpsThrottle {
    Device: "8:16",
    Throttle: 2097152,
}

for k, v := range structMap {
val := dbus.MakeVariant(v)
fmt.Println(reflect.ValueOf(v), val.Signature(), val.Value(), val.String())
		p := systemdDbus.Property{
			Name:  k,
			Value: val,
		}

		properties = append(properties, p)

}
ch := make(chan string)
_, err := c.StartTransientUnitContext(context.TODO(), name, "replace", properties, ch)
if err != nil {
    return err
}

Additional program output to the terminal or log subsystem illustrating the issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions