mirror of
				https://github.com/NVIDIA/nvidia-container-toolkit
				synced 2025-06-26 18:18:24 +00:00 
			
		
		
		
	Merge pull request #799 from elezar/fix-legacy-nvidia-imex-channels
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				CodeQL / Analyze Go code with CodeQL (push) Failing after 51m27s
				
			
		
			
				
	
				Golang / check (push) Failing after 6m27s
				
			
		
			
				
	
				Golang / Unit test (push) Failing after 2m23s
				
			
		
			
				
	
				Golang / Build (push) Failing after 2m24s
				
			
		
			
				
	
				image / packages (${{github.event_name == 'pull_request'}}, centos7-aarch64) (push) Failing after 6m40s
				
			
		
			
				
	
				image / packages (${{github.event_name == 'pull_request'}}, centos7-x86_64) (push) Failing after 3m9s
				
			
		
			
				
	
				image / packages (${{github.event_name == 'pull_request'}}, centos8-ppc64le) (push) Failing after 2m38s
				
			
		
			
				
	
				image / packages (${{github.event_name == 'pull_request'}}, ubuntu18.04-amd64) (push) Failing after 2m51s
				
			
		
			
				
	
				image / packages (${{github.event_name == 'pull_request'}}, ubuntu18.04-arm64) (push) Failing after 2m32s
				
			
		
			
				
	
				image / packages (${{github.event_name == 'pull_request'}}, ubuntu18.04-ppc64le) (push) Failing after 2m56s
				
			
		
			
				
	
				image / image (packaging, ${{github.event_name == 'pull_request'}}) (push) Has been skipped
				
			
		
			
				
	
				image / image (ubi8, ${{github.event_name == 'pull_request'}}) (push) Has been skipped
				
			
		
			
				
	
				image / image (ubuntu20.04, ${{github.event_name == 'pull_request'}}) (push) Has been skipped
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	CodeQL / Analyze Go code with CodeQL (push) Failing after 51m27s
				
			Golang / check (push) Failing after 6m27s
				
			Golang / Unit test (push) Failing after 2m23s
				
			Golang / Build (push) Failing after 2m24s
				
			image / packages (${{github.event_name == 'pull_request'}}, centos7-aarch64) (push) Failing after 6m40s
				
			image / packages (${{github.event_name == 'pull_request'}}, centos7-x86_64) (push) Failing after 3m9s
				
			image / packages (${{github.event_name == 'pull_request'}}, centos8-ppc64le) (push) Failing after 2m38s
				
			image / packages (${{github.event_name == 'pull_request'}}, ubuntu18.04-amd64) (push) Failing after 2m51s
				
			image / packages (${{github.event_name == 'pull_request'}}, ubuntu18.04-arm64) (push) Failing after 2m32s
				
			image / packages (${{github.event_name == 'pull_request'}}, ubuntu18.04-ppc64le) (push) Failing after 2m56s
				
			image / image (packaging, ${{github.event_name == 'pull_request'}}) (push) Has been skipped
				
			image / image (ubi8, ${{github.event_name == 'pull_request'}}) (push) Has been skipped
				
			image / image (ubuntu20.04, ${{github.event_name == 'pull_request'}}) (push) Has been skipped
				
			Fix NVIDIA_IMEX_CHANNELS handling on legacy images
This commit is contained in:
		
						commit
						5c3ffc2fba
					
				@ -292,7 +292,11 @@ func (i CUDA) CDIDevicesFromMounts() []string {
 | 
			
		||||
 | 
			
		||||
// ImexChannelsFromEnvVar returns the list of IMEX channels requested for the image.
 | 
			
		||||
func (i CUDA) ImexChannelsFromEnvVar() []string {
 | 
			
		||||
	return i.DevicesFromEnvvars(EnvVarNvidiaImexChannels).List()
 | 
			
		||||
	imexChannels := i.DevicesFromEnvvars(EnvVarNvidiaImexChannels).List()
 | 
			
		||||
	if len(imexChannels) == 1 && imexChannels[0] == "all" {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
	return imexChannels
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ImexChannelsFromMounts returns the list of IMEX channels requested for the image.
 | 
			
		||||
 | 
			
		||||
@ -203,6 +203,37 @@ func TestGetVisibleDevicesFromMounts(t *testing.T) {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestImexChannelsFromEnvVar(t *testing.T) {
 | 
			
		||||
	testCases := []struct {
 | 
			
		||||
		description string
 | 
			
		||||
		env         []string
 | 
			
		||||
		expected    []string
 | 
			
		||||
	}{
 | 
			
		||||
		{
 | 
			
		||||
			description: "no imex channels specified",
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			description: "imex channel specified",
 | 
			
		||||
			env: []string{
 | 
			
		||||
				"NVIDIA_IMEX_CHANNELS=3,4",
 | 
			
		||||
			},
 | 
			
		||||
			expected: []string{"3", "4"},
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, tc := range testCases {
 | 
			
		||||
		for id, baseEnvvars := range map[string][]string{"": nil, "legacy": {"CUDA_VERSION=1.2.3"}} {
 | 
			
		||||
			t.Run(tc.description+id, func(t *testing.T) {
 | 
			
		||||
				i, err := NewCUDAImageFromEnv(append(baseEnvvars, tc.env...))
 | 
			
		||||
				require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
				channels := i.ImexChannelsFromEnvVar()
 | 
			
		||||
				require.EqualValues(t, tc.expected, channels)
 | 
			
		||||
			})
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func makeTestMounts(paths ...string) []specs.Mount {
 | 
			
		||||
	var mounts []specs.Mount
 | 
			
		||||
	for _, path := range paths {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user