-
Notifications
You must be signed in to change notification settings - Fork 601
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
many: add cuda-driver-libs interface #15063
many: add cuda-driver-libs interface #15063
Conversation
Tue Feb 25 15:14:27 UTC 2025 Failures:Preparing:
Executing:
Restoring:
|
d09bff4
to
fd9d5c0
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #15063 +/- ##
=========================================
Coverage ? 78.08%
=========================================
Files ? 1184
Lines ? 158105
Branches ? 0
=========================================
Hits ? 123457
Misses ? 26976
Partials ? 7672
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
fd9d5c0
to
540bc1d
Compare
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.
Thank you!
if len(fields) != 1 && len(fields) != 3 { | ||
return fmt.Errorf("wrong format for api-version: %q", versRange) | ||
} | ||
switch len(fields) { |
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.
A comment here with examples of the expected input might be good. I think something like this?
// valid input examples:
// 1.2.3
// 1.2.3 .. 2.3.4
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.
Good point, I've added a comment
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.
did a first pass, don't we need a configfile part to this?
interfaces/ldconfig/backend.go
Outdated
// For the moment only the system snap is supported - the | ||
// snap.system.conf file is owned by it and the set-up of other snaps | ||
// must not affect it. | ||
if !interfaces.IsTheSystemSnap(appSet.InstanceName()) { |
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.
we discussed before that this doesn't make a lot of sense because of the two of the interface, why is it needed?
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.
It is actually needed, otherwise when the slot side builds its profiles after, say, a disconnection, it overrides the content of snap.system.conf
. That file is owned by the system plug and no other plug/slot should touch it.
For instance, this is seen when there are 2 snaps providing slots, if one is removed, when reconstructing the slot profiles it sees no spec.libDirs
and it removes the file, overriding what the plug profile wrote just before.
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.
let's talk about this in our 1-1, I'm really worried that these are the only interfaces that need this kind of behavior and they assume things about two levels up in the code from them
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.
71aca8f adds behavior so instead of checking the snap name we check if the snap owns plugs that need configuration. We cannot rely only in the connected plugs unfortunately.
} | ||
// Validate directories | ||
for _, dir := range libDirs { | ||
if !strings.HasPrefix(dir, "$SNAP") && !strings.HasPrefix(dir, "${SNAP}") { |
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.
shouldn't this also include the / ?
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.
Good point, changed
@alfonsosanchezbeato maybe it would make sense to make the changes to support implicit plugs their own PR? |
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.
@pedronis thanks for the review, comments addressed. Regarding configfile, no, for th cuda interface we do not have configuration files that we need to take care of.
interfaces/ldconfig/backend.go
Outdated
// For the moment only the system snap is supported - the | ||
// snap.system.conf file is owned by it and the set-up of other snaps | ||
// must not affect it. | ||
if !interfaces.IsTheSystemSnap(appSet.InstanceName()) { |
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.
It is actually needed, otherwise when the slot side builds its profiles after, say, a disconnection, it overrides the content of snap.system.conf
. That file is owned by the system plug and no other plug/slot should touch it.
For instance, this is seen when there are 2 snaps providing slots, if one is removed, when reconstructing the slot profiles it sees no spec.libDirs
and it removes the file, overriding what the plug profile wrote just before.
} | ||
// Validate directories | ||
for _, dir := range libDirs { | ||
if !strings.HasPrefix(dir, "$SNAP") && !strings.HasPrefix(dir, "${SNAP}") { |
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.
Good point, changed
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.
thanks for the changes, one comment about a detail
interfaces/ldconfig/spec.go
Outdated
@@ -61,10 +63,18 @@ func (spec *Specification) AddLibDirs(dirs []string) error { | |||
return nil | |||
} | |||
|
|||
func (spec *Specification) AddPlug(plug string) { |
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.
this doesn't need to be public and done by the interfaces, we can do it for them in:
snapd/interfaces/ldconfig/spec.go
Line 114 in 71aca8f
func (spec *Specification) AddPermanentPlug(iface interfaces.Interface, plug *snap.PlugInfo) error { |
no?
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.
Right, I've changed this now: a5b040c
interfaces/ldconfig/backend.go
Outdated
@@ -59,6 +59,12 @@ func (b *Backend) Setup(appSet *interfaces.SnapAppSet, opts interfaces.Confineme | |||
appSet.InstanceName(), err) | |||
} | |||
|
|||
// Setup ldconfig only of the snap has plugs that require it. For the | |||
// moment this is only the system snap. | |||
if len(spec.(*Specification).plugs) == 0 { |
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.
nitpick: I would do this check in the helper, also because it gets the spec casted already
71aca8f
to
a5b040c
Compare
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.
question about the last change
interfaces/ldconfig/spec.go
Outdated
@@ -102,6 +108,9 @@ func (spec *Specification) AddConnectedSlot(iface interfaces.Interface, plug *in | |||
|
|||
// AddPermanentPlug records ldconfig-specific side-effects of having a plug. | |||
func (spec *Specification) AddPermanentPlug(iface interfaces.Interface, plug *snap.PlugInfo) error { | |||
// Keep track of interfaces using this backend on the consumer side |
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.
shouldn't we do this only if the interface has actually LdconfigPermanentPlug or LdconfigConnectedPlug implemented? otherwise I think this method is called for all plugs
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.
I check now for LdconfigConnectedPlug, I want to avoid the interface to implement an empty LdconfigPermanentPlug.
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.
I thought you mentioned you need to run things even if the plug is not connected? as I said you can check for either definer in AddPermantPlug
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, otherwise we do not know if we need to remove configuration if all connections are gone.
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.
Latest commit checks the definer in AddPermantPlug
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.
thanks
interfaces/ldconfig/spec.go
Outdated
if !interfaces.IsTheSystemSnap(plug.Snap().InstanceName()) { | ||
return errors.New("internal error: ldconfig plugs can be defined only by the system snap") | ||
} |
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.
would it make sense to move the check into the getConnectedPlugCallback ?
this has changed quite a bit since the initial review
a1cc010
to
757157f
Compare
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.
LGTM
Grow test for interfaces that export libraries to the rootfs, like cuda-driver-libs.
Make sure that Setup touches the ldconfig configuration only for the system snap, as it is the owner of it. Otherwise the configuration would be destroyed when the other snaps are configured.
Register snap plugs so we know when we need to generate an ldconfig file.
interface wants to use the ldconfig backend.
757157f
to
ad8f627
Compare
slot *interfaces.ConnectedSlot) error | ||
connectedPlugCallback, err := getConnectedPlugCallback(iface, plug.Snap().InstanceName()) | ||
if err != nil { | ||
return err | ||
} |
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.
Thanks for this, it'd be nice if we could do this change for other things. It makes reading the code in this package harder when the interfaces are defined locally like this.
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.
Thanks!
Add cuda-driver-libs interface. This is the first interface using the ldconfig backend. Additionally, it is the first example of an implicit plug, so some changes in ifacestate are also part of this change.