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

Define resource fields for api.Machine #181

Open
Tracked by #147
so-sahu opened this issue Feb 15, 2024 · 6 comments
Open
Tracked by #147

Define resource fields for api.Machine #181

so-sahu opened this issue Feb 15, 2024 · 6 comments
Assignees
Labels
dt-target issue/pr for dt enhancement New feature or request prio-high

Comments

@so-sahu
Copy link
Contributor

so-sahu commented Feb 15, 2024

Summary

This issue captures the efforts to extend the API machine object and the corresponding reconciler changes. The proposals and changes can be discussed in this issue.

@so-sahu so-sahu added the enhancement New feature or request label Feb 15, 2024
@so-sahu so-sahu self-assigned this Feb 15, 2024
@so-sahu so-sahu added this to Compute Feb 15, 2024
@github-project-automation github-project-automation bot moved this to Todo in Compute Feb 15, 2024
@so-sahu so-sahu moved this from Todo to In Progress in Compute Feb 15, 2024
@so-sahu
Copy link
Contributor Author

so-sahu commented Feb 15, 2024

type ResourceName string

const (
	ResourceCPU      ResourceName = "cpu"
	ResourceMemory   ResourceName = "memory"
	ResourceSGX      ResourceName = "sgx"
	ResourceHugepages ResourceName = "hugepages"
)

type MachineSpec struct {
        ...
	Resources ResourceList
	NumaNodes []int
        CPUPins map[int]int
        ...
}

type ResourceList map[ResourceName]resource.Quantity

func (rl *ResourceList) Get(name ResourceName) resource.Quantity {
	if val, ok := (*rl)[name]; ok {
		return val
	}
	return resource.Quantity{}
}

func (rl *ResourceList) Set(name ResourceName, value resource.Quantity) {
	(*rl)[name] = value
}

func (rl *ResourceList) CPU() resource.Quantity {
	return rl.Get(ResourceCPU)
}

func (rl *ResourceList) Memory() resource.Quantity {
	return rl.Get(ResourceMemory)
}

func (rl *ResourceList) SGX() resource.Quantity {
	return rl.Get(ResourceSGX)
}

func (rl *ResourceList) EnableHugepages() bool{
	if rl.Get(ResourceHugepages).Value() == 1 {
		return true
	}
	return false
}

Changes made

  1. ResourceName and ResourceList Types

    • ResourceName defines string constants for different types of resources (cpu, memory, sgx, hugepages).
    • ResourceList is a map that associates ResourceName with resource.Quantity to manage resource quantities.
  2. MachineSpec Struct

    • The MachineSpec struct now includes a Resources field of type ResourceList to store resource allocations.
  3. ResourceList Methods

    • Get(name ResourceName) resource.Quantity: Retrieves the quantity of the specified resource.
    • Set(name ResourceName, value resource.Quantity): Sets the quantity of the specified resource.
    • CPU(), Memory(), SGX(): Convenience methods to retrieve specific resource quantities.
    • EnableHugepages(): Checks if hugepages are enabled.

Impact

  • Improved readability and maintainability of resource configurations.
  • Simplified handling of different resource types.
  • Easier access and manipulation of resource quantities.

@lukas016
Copy link
Contributor

Why do you need VCUAllocationRatio, BlockedHugepages and BlockedCPUs in machine spec? It is important for resource manager only for my point of view.

@lukas016 lukas016 changed the title Extending api.Machine with needed properties Define resource fields for api.Machine Feb 15, 2024
@lukas016
Copy link
Contributor

Do you need NumaDomain? Isn't it len(NumaNodes)?

@lukas016
Copy link
Contributor

network cards and storage can be resources too which ideally will manage by resource manager too. Could you think maybe how we can implement it too?

@lukas016
Copy link
Contributor

what do you think about use resource.Quantity type? https://github.com/ironcore-dev/ironcore/blob/main/api/core/v1alpha1/resource.go

@hardikdr hardikdr removed this from Compute Feb 21, 2024
@afritzler
Copy link
Member

How about the following. In the spec I have the possibility to assign a NUMA topoligy like this. If it is empty it is ignored (in case NUMA pinning is disabled) or a Scheduler/Resource Manager ensures that it is correctly filled later.

type MachineSpec struct {
	// Existing fields...

	NUMAPreferences NUMAPreferences `json:"numaPreferences,omitempty"`
}

type NUMAPreferences struct {
	CPUNodes    []int `json:"cpuNodes,omitempty"`
	MemoryNodes []int `json:"memoryNodes,omitempty"`
	IoNodes     []int `json:"ioNodes,omitempty"`
}

And in the Status you can update the information once the placement has been fulfilled.

type MachineStatus struct {
	// Existing fields...

	NUMAPlacement NUMAPlacement `json:"numaPlacement,omitempty"`
}

type NUMAPlacement struct {
	CPUNodes    []int `json:"cpuNodes"`
	MemoryNodes []int `json:"memoryNodes"`
	IoNodes     []int `json:"ioNodes"`
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dt-target issue/pr for dt enhancement New feature or request prio-high
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants