Skip to content
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

Wrap errors from computestorage package #925

Merged
merged 1 commit into from
Jan 15, 2021
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
4 changes: 2 additions & 2 deletions computestorage/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package computestorage
import (
"context"
"encoding/json"
"fmt"

"github.com/Microsoft/hcsshim/internal/oc"
"github.com/pkg/errors"
"go.opencensus.io/trace"
)

Expand All @@ -32,7 +32,7 @@ func AttachLayerStorageFilter(ctx context.Context, layerPath string, layerData L

err = hcsAttachLayerStorageFilter(layerPath, string(bytes))
if err != nil {
return fmt.Errorf("failed to attach layer storage filter: %s", err)
return errors.Wrap(err, "failed to attach layer storage filter")
}
return nil
}
4 changes: 2 additions & 2 deletions computestorage/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package computestorage

import (
"context"
"fmt"

"github.com/Microsoft/hcsshim/internal/oc"
"github.com/pkg/errors"
"go.opencensus.io/trace"
)

Expand All @@ -20,7 +20,7 @@ func DestroyLayer(ctx context.Context, layerPath string) (err error) {

err = hcsDestroyLayer(layerPath)
if err != nil {
return fmt.Errorf("failed to destroy layer: %s", err)
return errors.Wrap(err, "failed to destroy layer")
}
return nil
}
4 changes: 2 additions & 2 deletions computestorage/detach.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package computestorage

import (
"context"
"fmt"

"github.com/Microsoft/hcsshim/internal/oc"
"github.com/pkg/errors"
"go.opencensus.io/trace"
)

Expand All @@ -20,7 +20,7 @@ func DetachLayerStorageFilter(ctx context.Context, layerPath string) (err error)

err = hcsDetachLayerStorageFilter(layerPath)
if err != nil {
return fmt.Errorf("failed to detach layer storage filter: %s", err)
return errors.Wrap(err, "failed to detach layer storage filter")
}
return nil
}
4 changes: 2 additions & 2 deletions computestorage/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package computestorage
import (
"context"
"encoding/json"
"fmt"

"github.com/Microsoft/hcsshim/internal/oc"
"github.com/pkg/errors"
"go.opencensus.io/trace"
)

Expand Down Expand Up @@ -40,7 +40,7 @@ func ExportLayer(ctx context.Context, layerPath, exportFolderPath string, layerD

err = hcsExportLayer(layerPath, exportFolderPath, string(ldbytes), string(obytes))
if err != nil {
return fmt.Errorf("failed to export layer: %s", err)
return errors.Wrap(err, "failed to export layer")
}
return nil
}
4 changes: 2 additions & 2 deletions computestorage/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package computestorage

import (
"context"
"fmt"

"github.com/Microsoft/hcsshim/internal/oc"
"github.com/pkg/errors"
"go.opencensus.io/trace"
"golang.org/x/sys/windows"
)
Expand All @@ -20,7 +20,7 @@ func FormatWritableLayerVhd(ctx context.Context, vhdHandle windows.Handle) (err

err = hcsFormatWritableLayerVhd(vhdHandle)
if err != nil {
return fmt.Errorf("failed to format writable layer vhd: %s", err)
return errors.Wrap(err, "failed to format writable layer vhd")
}
return nil
}
4 changes: 2 additions & 2 deletions computestorage/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package computestorage
import (
"context"
"encoding/json"
"fmt"

"github.com/Microsoft/hcsshim/internal/oc"
"github.com/pkg/errors"
"go.opencensus.io/trace"
)

Expand Down Expand Up @@ -35,7 +35,7 @@ func ImportLayer(ctx context.Context, layerPath, sourceFolderPath string, layerD

err = hcsImportLayer(layerPath, sourceFolderPath, string(bytes))
if err != nil {
return fmt.Errorf("failed to import layer: %s", err)
return errors.Wrap(err, "failed to import layer")
}
return nil
}
4 changes: 2 additions & 2 deletions computestorage/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package computestorage
import (
"context"
"encoding/json"
"fmt"

"github.com/Microsoft/hcsshim/internal/oc"
"github.com/pkg/errors"
"go.opencensus.io/trace"
)

Expand All @@ -32,7 +32,7 @@ func InitializeWritableLayer(ctx context.Context, layerPath string, layerData La
// Options are not used in the platform as of RS5
err = hcsInitializeWritableLayer(layerPath, string(bytes), "")
if err != nil {
return fmt.Errorf("failed to intitialize container layer: %s", err)
return errors.Wrap(err, "failed to intitialize container layer")
}
return nil
}
4 changes: 2 additions & 2 deletions computestorage/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package computestorage

import (
"context"
"fmt"

"github.com/Microsoft/hcsshim/internal/interop"
"github.com/Microsoft/hcsshim/internal/oc"
"github.com/pkg/errors"
"go.opencensus.io/trace"
"golang.org/x/sys/windows"
)
Expand All @@ -20,7 +20,7 @@ func GetLayerVhdMountPath(ctx context.Context, vhdHandle windows.Handle) (path s
var mountPath *uint16
err = hcsGetLayerVhdMountPath(vhdHandle, &mountPath)
if err != nil {
return "", fmt.Errorf("failed to get vhd mount path: %s", err)
return "", errors.Wrap(err, "failed to get vhd mount path")
}
path = interop.ConvertAndFreeCoTaskMemString(mountPath)
return path, nil
Expand Down
7 changes: 3 additions & 4 deletions computestorage/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ package computestorage
import (
"context"
"encoding/json"
"errors"
"fmt"

"github.com/Microsoft/hcsshim/internal/oc"
"github.com/Microsoft/hcsshim/osversion"
"github.com/pkg/errors"
"go.opencensus.io/trace"
"golang.org/x/sys/windows"
)
Expand Down Expand Up @@ -37,7 +36,7 @@ func SetupBaseOSLayer(ctx context.Context, layerPath string, vhdHandle windows.H

err = hcsSetupBaseOSLayer(layerPath, vhdHandle, string(bytes))
if err != nil {
return fmt.Errorf("failed to setup base OS layer: %s", err)
return errors.Wrap(err, "failed to setup base OS layer")
}
return nil
}
Expand Down Expand Up @@ -69,7 +68,7 @@ func SetupBaseOSVolume(ctx context.Context, layerPath, volumePath string, option

err = hcsSetupBaseOSVolume(layerPath, volumePath, string(bytes))
if err != nil {
return fmt.Errorf("failed to setup base OS layer: %s", err)
return errors.Wrap(err, "failed to setup base OS layer")
}
return nil
}