-
Notifications
You must be signed in to change notification settings - Fork 429
Filter already tracked directories from ldcache update #1403
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
Open
elezar
wants to merge
1
commit into
NVIDIA:main
Choose a base branch
from
elezar:selective-ldcache-config
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+188
−4
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| /** | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| **/ | ||
|
|
||
| package ldconfig | ||
|
|
||
| import ( | ||
| "os" | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestFilterDirectories(t *testing.T) { | ||
| const topLevelConf = "TOPLEVEL.conf" | ||
|
|
||
| testCases := []struct { | ||
| description string | ||
| confs map[string]string // map[filename]content, must have topLevelConf key | ||
| input []string | ||
| expected []string | ||
| }{ | ||
| { | ||
| description: "all filtered", | ||
| confs: map[string]string{ | ||
| topLevelConf: ` | ||
| # some comment | ||
| /tmp/libdir1 | ||
| /tmp/libdir2 | ||
| `, | ||
| }, | ||
| input: []string{"/tmp/libdir1", "/tmp/libdir2"}, | ||
| expected: nil, | ||
| }, | ||
| { | ||
| description: "partially filtered", | ||
| confs: map[string]string{ | ||
| topLevelConf: ` | ||
| /tmp/libdir1 | ||
| `, | ||
| }, | ||
| input: []string{"/tmp/libdir1", "/tmp/libdir2"}, | ||
| expected: []string{"/tmp/libdir2"}, | ||
| }, | ||
| { | ||
| description: "none filtered", | ||
| confs: map[string]string{ | ||
| topLevelConf: ` | ||
| # empty config | ||
| `, | ||
| }, | ||
| input: []string{"/tmp/libdir1", "/tmp/libdir2"}, | ||
| expected: []string{"/tmp/libdir1", "/tmp/libdir2"}, | ||
| }, | ||
| { | ||
| description: "filter with include and comments", | ||
| confs: map[string]string{ | ||
| topLevelConf: ` | ||
| # comment | ||
| /tmp/libdir1 | ||
| include /nonexistent/pattern* | ||
| `, | ||
| }, | ||
| input: []string{"/tmp/libdir1", "/tmp/libdir2"}, | ||
| expected: []string{"/tmp/libdir2"}, | ||
| }, | ||
| { | ||
| description: "include directive picks up more dirs to filter", | ||
| confs: map[string]string{ | ||
| topLevelConf: ` | ||
| # top-level | ||
| include INCLUDED_PATTERN* | ||
| /tmp/libdir3 | ||
| `, | ||
| "INCLUDED_PATTERN0.conf": ` | ||
| /tmp/libdir2 | ||
| # another comment | ||
| /tmp/libdir4 | ||
| `, | ||
| "INCLUDED_PATTERN1.conf": ` | ||
| /tmp/libdir1 | ||
| `, | ||
| }, | ||
| input: []string{"/tmp/libdir1", "/tmp/libdir2", "/tmp/libdir3", "/tmp/libdir4", "/tmp/libdir5"}, | ||
| expected: []string{"/tmp/libdir5"}, | ||
| }, | ||
| } | ||
|
|
||
| for _, tc := range testCases { | ||
| t.Run(tc.description, func(t *testing.T) { | ||
| tmpDir := t.TempDir() | ||
|
|
||
| // Prepare file contents, adjusting include globs to be absolute and unique within tmpDir | ||
| for name, content := range tc.confs { | ||
| if name == topLevelConf && len(tc.confs) > 1 { | ||
| content = strings.ReplaceAll(content, "include INCLUDED_PATTERN*", "include "+tmpDir+"/INCLUDED_PATTERN*") | ||
| } | ||
| err := os.WriteFile(tmpDir+"/"+name, []byte(content), 0600) | ||
| require.NoError(t, err) | ||
| } | ||
|
|
||
| topLevelConfPath := tmpDir + "/" + topLevelConf | ||
| filtered, err := filterDirectories(topLevelConfPath, tc.input...) | ||
|
|
||
| require.NoError(t, err) | ||
| require.Equal(t, tc.expected, filtered) | ||
| }) | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
(Jason from Uber AI Infra here - we filed the ticket) What will be passed in as
directories?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.
directoriescontains the container paths of parent directories for any CUDA user-mode driver libraries that are mounted from the host. Note that at present the contianer paths of the libraries are the same as the host path.On an ubuntu based system the list is typically:
which results in the following CDI hook:
If you wanted to know what the list is on your system, you could run the
nvidia-ctk cdi generatecommand and check the output for the generatedupdate-ldcachehook.