-
Notifications
You must be signed in to change notification settings - Fork 39
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
Add IntelRdt to CDI spec #164
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
[codespell] | ||
skip = .git,*.pdf,*.svg,*.sum,*.mod | ||
# | ||
# ignore-words-list = | ||
ignore-words-list = clos |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,6 +144,13 @@ func (e *ContainerEdits) Apply(spec *oci.Spec) error { | |
} | ||
} | ||
|
||
if e.IntelRdt != nil { | ||
// The specgen is missing functionality to set all parameters so we | ||
// just piggy-back on it to initialize all structs and the copy over. | ||
specgen.SetLinuxIntelRdtClosID(e.IntelRdt.ClosID) | ||
spec.Linux.IntelRdt = e.IntelRdt.ToOCI() | ||
} | ||
|
||
return nil | ||
} | ||
|
||
|
@@ -171,6 +178,11 @@ func (e *ContainerEdits) Validate() error { | |
return err | ||
} | ||
} | ||
if e.IntelRdt != nil { | ||
if err := ValidateIntelRdt(e.IntelRdt); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
@@ -192,6 +204,9 @@ func (e *ContainerEdits) Append(o *ContainerEdits) *ContainerEdits { | |
e.DeviceNodes = append(e.DeviceNodes, o.DeviceNodes...) | ||
e.Hooks = append(e.Hooks, o.Hooks...) | ||
e.Mounts = append(e.Mounts, o.Mounts...) | ||
if o.IntelRdt != nil { | ||
e.IntelRdt = o.IntelRdt | ||
} | ||
|
||
return e | ||
} | ||
|
@@ -202,7 +217,7 @@ func (e *ContainerEdits) isEmpty() bool { | |
if e == nil { | ||
return false | ||
} | ||
return len(e.Env)+len(e.DeviceNodes)+len(e.Hooks)+len(e.Mounts) == 0 | ||
return len(e.Env)+len(e.DeviceNodes)+len(e.Hooks)+len(e.Mounts) == 0 && e.IntelRdt == nil | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: Should we explicitly check for an empty There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think checking |
||
} | ||
|
||
// ValidateEnv validates the given environment variables. | ||
|
@@ -280,6 +295,15 @@ func (m *Mount) Validate() error { | |
return nil | ||
} | ||
|
||
// ValidateIntelRdt validates the IntelRdt configuration. | ||
func ValidateIntelRdt(i *specs.IntelRdt) error { | ||
// ClosID must be a valid Linux filename | ||
if len(i.ClosID) >= 4096 || i.ClosID == "." || i.ClosID == ".." || strings.ContainsAny(i.ClosID, "/\n") { | ||
elezar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return errors.New("invalid ClosID") | ||
} | ||
return nil | ||
} | ||
|
||
// Ensure OCI Spec hooks are not nil so we can add hooks. | ||
func ensureOCIHooks(spec *oci.Spec) { | ||
if spec.Hooks == nil { | ||
|
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.
What is the expected behaviour is both are non-nil? Here we overwrite the previous value if the input value is non-nil.
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.
intelRDT fiels in OCI spec can't have multiple values, so overwriting already set values theoretically expected behaviour. One thing which is questionable, is to go over individual values, instead of overwriting as a whole struct.
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.
Yes, it's like @kad explained. There can only be single RDT configuration per container. Also, the config must be applied as a whole (merging multiple RDT configs together is not something that we want).
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.
As discussed in the COD working group meeting, I'm happy as long as this is consistent with what is done for other edits (Env, Mounts). It seems to be the case in that the last value applied takes precedence.
We also mentioned that if we do want to expose errors due to conflicts, we can do so in a follow-up.
One thing that would be good would be to add a unit test to capture this behaviour to prevent regressions.