Skip to content

json: cannot unmarshal number -1 into Go value of type uint64 #867

@xiajohnnyxia

Description

@xiajohnnyxia

/runc/vendor/github.com/opencontainers/runc/libcontainer/factory_linux.go

func (l *LinuxFactory) loadState(root, id string) (*State, error)

               json.NewDecoder(f).Decode(&state)

In this type : State.BaseState.Config.Cgroups.Resources,there are serval unit64 type field . And their json value is number.
How can i fix this error?

"memory": 0,
"memory_reservation": 0,
"memory_swap": 0,
"kernel_memory": 0,
"kernel_memory_tcp": 0,
"cpu_shares": 0,
"cpu_quota": 0,
"cpu_period": 0,
"cpu_rt_quota": 0,
"cpu_rt_period": 0,
"cpuset_cpus": "",
"cpuset_mems": "",
// Memory limit (in bytes)
Memory uint64 json:"memory"

// Memory reservation or soft_limit (in bytes)
MemoryReservation uint64 `json:"memory_reservation"`

// Total memory usage (memory + swap); set `-1` to enable unlimited swap
MemorySwap uint64 `json:"memory_swap"`

// Kernel memory limit (in bytes)
KernelMemory uint64 `json:"kernel_memory"`

// Kernel memory limit for TCP use (in bytes)
KernelMemoryTCP uint64 `json:"kernel_memory_tcp"`

// CPU shares (relative weight vs. other containers)
CpuShares uint64 `json:"cpu_shares"`

// CPU hardcap limit (in usecs). Allowed cpu time in a given period.
CpuQuota int64 `json:"cpu_quota"`

// CPU period to be used for hardcapping (in usecs). 0 to use system default.
CpuPeriod uint64 `json:"cpu_period"`

// How many time CPU will use in realtime scheduling (in usecs).
CpuRtRuntime int64 `json:"cpu_rt_quota"`

// CPU period to be used for realtime scheduling (in usecs).
CpuRtPeriod uint64 `json:"cpu_rt_period"`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions