Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions libcni/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,9 +663,9 @@ func (c *CNIConfig) DelNetwork(ctx context.Context, net *PluginConfig, rt *Runti
if gtet, err := version.GreaterThanOrEqualTo(net.Network.CNIVersion, "0.4.0"); err != nil {
return err
} else if gtet {
cachedResult, err = c.getCachedResult(net.Network.Name, net.Network.CNIVersion, rt)
if err != nil {
return fmt.Errorf("failed to get network %q cached result: %w", net.Network.Name, err)
if cachedResult, err = c.getCachedResult(net.Network.Name, net.Network.CNIVersion, rt); err != nil {
_ = c.cacheDel(net.Network.Name, rt)
cachedResult = nil
}
}

Expand Down
8 changes: 4 additions & 4 deletions libcni/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -837,12 +837,12 @@ var _ = Describe("Invoking plugins", func() {
})

Context("result is invalid JSON", func() {
It("returns an error", func() {
It("tolerates the error", func() {
err := os.WriteFile(cacheFile, []byte("adfadsfasdfasfdsafaf"), 0o600)
Expect(err).NotTo(HaveOccurred())

err = cniConfig.DelNetwork(ctx, netConfig, runtimeConfig)
Expect(err).To(MatchError("failed to get network \"apitest\" cached result: decoding version from network config: invalid character 'a' looking for beginning of value"))
Expect(err).NotTo(HaveOccurred())
})
})

Expand All @@ -859,7 +859,7 @@ var _ = Describe("Invoking plugins", func() {
Expect(err).NotTo(HaveOccurred())
})

It("returns an error when the cached result cannot be converted", func() {
It("tolerates the error when the cached result cannot be converted", func() {
err := os.WriteFile(cacheFile, []byte(`{
"cniVersion": "0.4567.0",
"ips": [{"version": "4", "address": "10.1.2.3/24"}],
Expand All @@ -868,7 +868,7 @@ var _ = Describe("Invoking plugins", func() {
Expect(err).NotTo(HaveOccurred())

err = cniConfig.DelNetwork(ctx, netConfig, runtimeConfig)
Expect(err).To(MatchError("failed to get network \"apitest\" cached result: unsupported CNI result version \"0.4567.0\""))
Expect(err).NotTo(HaveOccurred())
})
})
})
Expand Down
Loading