Skip to content

Commit 6fc7a00

Browse files
committed
Review
1 parent 4067609 commit 6fc7a00

File tree

6 files changed

+19
-12
lines changed

6 files changed

+19
-12
lines changed

LICENSES/Apache-2.0.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
4444

4545
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
4646

47-
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as requested for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
47+
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
4848

49-
7. Disclaimer of Warranty. Unless requested by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
49+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
5050

51-
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless requested by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
51+
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
5252

5353
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
5454

@@ -66,7 +66,7 @@ You may obtain a copy of the License at
6666

6767
http://www.apache.org/licenses/LICENSE-2.0
6868

69-
Unless requested by applicable law or agreed to in writing, software
69+
Unless required by applicable law or agreed to in writing, software
7070
distributed under the License is distributed on an "AS IS" BASIS,
7171
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7272
See the License for the specific language governing permissions and

claimutils/claim/claimer.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ type Claimer interface {
2828
Start(ctx context.Context) error
2929
}
3030

31-
func NewResourceClaimer(plugins ...Plugin) (*claimer, error) {
31+
func NewResourceClaimer(log logr.Logger, plugins ...Plugin) (*claimer, error) {
3232
c := claimer{
33+
log: log,
3334
plugins: map[string]Plugin{},
3435
toClaim: make(chan claimReq, 1),
3536
toRelease: make(chan releaseReq, 1),

claimutils/claim/claimer_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ var _ = Describe("Resource Claimer", func() {
2929
It("should claim composite resources", func(ctx SpecContext) {
3030
By("init plugin")
3131
resourceClaimer, err := claim.NewResourceClaimer(
32+
log.FromContext(ctx),
3233
gpu.NewGPUClaimPlugin(log.FromContext(ctx), "nvidia.com/gpu", &mockReader{
3334
devices: []pci.Address{
3435
{},
@@ -39,15 +40,20 @@ var _ = Describe("Resource Claimer", func() {
3940
Expect(err).NotTo(HaveOccurred())
4041

4142
innerCtx, cancel := context.WithCancel(ctx)
42-
defer cancel()
43-
44-
// start the Runnable in the background
4543
errCh := make(chan error, 1)
44+
defer cancel()
4645
go func() {
4746
defer GinkgoRecover()
4847
errCh <- resourceClaimer.Start(innerCtx)
4948
}()
5049

50+
DeferCleanup(func() {
51+
cancel()
52+
var startErr error
53+
Eventually(errCh).Should(Receive(&startErr))
54+
Expect(startErr).To(Succeed())
55+
})
56+
5157
By("failing if not not existing resource is claimed")
5258
var resourceClaim claim.Claims
5359
Eventually(func() error {

claimutils/gpu/gpu.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ func (g *gpuClaimPlugin) Init() error {
138138
for _, pciDevice := range g.preClaimed {
139139
if _, ok := g.devices[pciDevice]; !ok {
140140
g.log.V(2).Info("Not discovered pre-claimed pci address", "pciAddress", pciDevice)
141-
141+
continue
142142
}
143143

144144
g.log.V(2).Info("Set device to claimed", "pciAddress", pciDevice)
145145
g.devices[pciDevice] = ClaimStatusClaimed
146-
continue
146+
147147
}
148148

149149
return nil

claimutils/gpu/gpu_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ var _ = Describe("GPU Claimer", func() {
146146
Expect(ociAddress1.PCIAddresses()[0]).NotTo(Equal(ociAddress2.PCIAddresses()[0]))
147147
})
148148

149-
It("should claim different devices", func(ctx SpecContext) {
149+
It("should handle zero-quantity claims", func(ctx SpecContext) {
150150
By("init plugin")
151151
plugin := gpu.NewGPUClaimPlugin(log.FromContext(ctx), "test-plugin", &MockReader{
152152
devices: []pci.Address{

claimutils/pci/reader_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func writeFakePCIDevice(t *testing.T, sysRoot, id string, vals map[string]string
5959
}
6060
}
6161

62-
func TestGPUClaimer_InitCorrect(t *testing.T) {
62+
func TestPCIReader_ReadFilters(t *testing.T) {
6363
tmpDir := t.TempDir()
6464

6565
// matching device 1

0 commit comments

Comments
 (0)