Skip to content

Commit b4ae83a

Browse files
committed
Revert "try to catch err no left space"
This reverts commit b870c0d.
1 parent b870c0d commit b4ae83a

File tree

2 files changed

+2
-74
lines changed

2 files changed

+2
-74
lines changed

images/dvcr-artifact/pkg/errors/errors.go

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,7 @@ limitations under the License.
1616

1717
package errors
1818

19-
import (
20-
"errors"
21-
"fmt"
22-
"os"
23-
"syscall"
24-
)
19+
import "fmt"
2520

2621
type ReasonError interface {
2722
error
@@ -49,52 +44,3 @@ func (e BadImageChecksumError) Reason() string {
4944
func (e BadImageChecksumError) Error() string {
5045
return fmt.Sprintf("%s sum mismatch: %s != %s", e.algorithm, e.expected, e.actual)
5146
}
52-
53-
func NewNoSpaceLeftError(err error) NoSpaceLeftError {
54-
return NoSpaceLeftError{
55-
err: err,
56-
}
57-
}
58-
59-
type NoSpaceLeftError struct {
60-
err error
61-
}
62-
63-
func (e NoSpaceLeftError) Reason() string {
64-
return "NoSpaceLeft"
65-
}
66-
67-
func (e NoSpaceLeftError) Error() string {
68-
return fmt.Sprintf("no space left on device: %v", e.err)
69-
}
70-
71-
func (e NoSpaceLeftError) Unwrap() error {
72-
return e.err
73-
}
74-
75-
func IsNoSpaceLeftError(err error) bool {
76-
if err == nil {
77-
return false
78-
}
79-
80-
var noSpaceErr NoSpaceLeftError
81-
if errors.As(err, &noSpaceErr) {
82-
return true
83-
}
84-
85-
var pathErr *os.PathError
86-
if errors.As(err, &pathErr) {
87-
if pathErr.Err == syscall.ENOSPC {
88-
return true
89-
}
90-
}
91-
92-
var errno syscall.Errno
93-
if errors.As(err, &errno) {
94-
if errno == syscall.ENOSPC {
95-
return true
96-
}
97-
}
98-
99-
return false
100-
}

images/dvcr-artifact/pkg/registry/registry.go

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535

3636
"github.com/google/go-containerregistry/pkg/authn"
3737
"github.com/google/go-containerregistry/pkg/name"
38-
v1 "github.com/google/go-containerregistry/pkg/v1"
38+
"github.com/google/go-containerregistry/pkg/v1"
3939
"github.com/google/go-containerregistry/pkg/v1/empty"
4040
"github.com/google/go-containerregistry/pkg/v1/mutate"
4141
"github.com/google/go-containerregistry/pkg/v1/remote"
@@ -261,9 +261,6 @@ func (p DataProcessor) inspectAndStreamSourceImage(
261261
klog.Infoln("Streaming from the source")
262262
doneSize, err := io.Copy(streamWriter, io.TeeReader(sourceImageReader, imageInfoWriter))
263263
if err != nil {
264-
if importerrs.IsNoSpaceLeftError(err) {
265-
return importerrs.NewNoSpaceLeftError(err)
266-
}
267264
return fmt.Errorf("error copying from the source: %w", err)
268265
}
269266

@@ -328,9 +325,6 @@ func (p DataProcessor) uploadLayersAndImage(
328325

329326
klog.Infoln("Uploading layer to registry")
330327
if err := remote.WriteLayer(repo, layer, remoteOpts...); err != nil {
331-
if importerrs.IsNoSpaceLeftError(err) {
332-
return importerrs.NewNoSpaceLeftError(err)
333-
}
334328
return fmt.Errorf("error uploading layer: %w", err)
335329
}
336330
klog.Infoln("Layer uploaded")
@@ -362,9 +356,6 @@ func (p DataProcessor) uploadLayersAndImage(
362356

363357
klog.Infof("Uploading image %q to registry", p.destImageName)
364358
if err = remote.Write(ref, image, remoteOpts...); err != nil {
365-
if importerrs.IsNoSpaceLeftError(err) {
366-
return importerrs.NewNoSpaceLeftError(err)
367-
}
368359
return fmt.Errorf("error uploading image: %w", err)
369360
}
370361

@@ -412,9 +403,6 @@ func getImageInfo(ctx context.Context, sourceReader io.ReadCloser) (ImageInfo, e
412403

413404
uncompressedN, err = io.CopyN(tempImageInfoFile, formatSourceReaders.TopReader(), imageInfoSize)
414405
if err != nil && !errors.Is(err, io.EOF) {
415-
if importerrs.IsNoSpaceLeftError(err) {
416-
return ImageInfo{}, importerrs.NewNoSpaceLeftError(err)
417-
}
418406
return ImageInfo{}, fmt.Errorf("error writing to temp file: %w", err)
419407
}
420408

@@ -442,9 +430,6 @@ func getImageInfo(ctx context.Context, sourceReader io.ReadCloser) (ImageInfo, e
442430
// It's necessary to read everything from the original image to avoid blocking.
443431
_, err = io.Copy(&EmptyWriter{}, sourceReader)
444432
if err != nil {
445-
if importerrs.IsNoSpaceLeftError(err) {
446-
return ImageInfo{}, importerrs.NewNoSpaceLeftError(err)
447-
}
448433
return ImageInfo{}, fmt.Errorf("error copying to nowhere: %w", err)
449434
}
450435

@@ -473,9 +458,6 @@ func getImageInfo(ctx context.Context, sourceReader io.ReadCloser) (ImageInfo, e
473458
// Count uncompressed size of source image.
474459
n, err := io.Copy(&EmptyWriter{}, formatSourceReaders.TopReader())
475460
if err != nil {
476-
if importerrs.IsNoSpaceLeftError(err) {
477-
return ImageInfo{}, importerrs.NewNoSpaceLeftError(err)
478-
}
479461
return ImageInfo{}, fmt.Errorf("error copying to nowhere: %w", err)
480462
}
481463

0 commit comments

Comments
 (0)