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
4 changes: 2 additions & 2 deletions cmd/apiserver-watcher/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func runRunCmd(cmd *cobra.Command, args []string) error {

uri, err := url.Parse(runOpts.healthCheckURL)
if err != nil {
return fmt.Errorf("failed to parse health-check-url: %v", err)
return fmt.Errorf("failed to parse health-check-url: %w", err)
}
if !uri.IsAbs() {
return fmt.Errorf("invalid URI %q (no scheme)", uri)
Expand All @@ -82,7 +82,7 @@ func runRunCmd(cmd *cobra.Command, args []string) error {
}},
})
if err != nil {
return fmt.Errorf("failed to create httpCheck: %v", err)
return fmt.Errorf("failed to create httpCheck: %w", err)
}
errCh := make(chan error)

Expand Down
4 changes: 2 additions & 2 deletions cmd/machine-config-controller/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"flag"
"fmt"

"github.com/golang/glog"
"github.com/openshift/machine-config-operator/cmd/common"
Expand All @@ -14,7 +15,6 @@ import (
"github.com/openshift/machine-config-operator/pkg/controller/render"
"github.com/openshift/machine-config-operator/pkg/controller/template"
"github.com/openshift/machine-config-operator/pkg/version"
"github.com/pkg/errors"
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/leaderelection"
Expand Down Expand Up @@ -52,7 +52,7 @@ func runStartCmd(cmd *cobra.Command, args []string) {

cb, err := clients.NewBuilder(startOpts.kubeconfig)
if err != nil {
ctrlcommon.WriteTerminationError(errors.Wrapf(err, "Creating clients"))
ctrlcommon.WriteTerminationError(fmt.Errorf("creating clients: %w", err))
}
run := func(ctx context.Context) {
ctrlctx := ctrlcommon.CreateControllerContext(cb, ctx.Done(), componentName)
Expand Down
7 changes: 3 additions & 4 deletions cmd/machine-config-daemon/pivot.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

"github.com/golang/glog"
daemon "github.com/openshift/machine-config-operator/pkg/daemon"
errors "github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
Expand Down Expand Up @@ -50,9 +49,9 @@ func run(_ *cobra.Command, args []string) (retErr error) {
data, err := ioutil.ReadFile(etcPivotFile)
if err != nil {
if os.IsNotExist(err) {
return fmt.Errorf("No container specified")
return fmt.Errorf("no container specified")
}
return errors.Wrapf(err, "failed to read from %s", etcPivotFile)
return fmt.Errorf("failed to read from %s: %w", etcPivotFile, err)
}
container = strings.TrimSpace(string(data))
} else {
Expand All @@ -74,7 +73,7 @@ func run(_ *cobra.Command, args []string) (retErr error) {
if fromEtcPullSpec {
if err := os.Remove(etcPivotFile); err != nil {
if !os.IsNotExist(err) {
return errors.Wrapf(err, "failed to delete %s", etcPivotFile)
return fmt.Errorf("failed to delete %s: %w", etcPivotFile, err)
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/machine-config-daemon/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"bufio"
"flag"
"fmt"
"io"
"net/url"
"os"
Expand All @@ -19,7 +20,6 @@ import (
"github.com/openshift/machine-config-operator/pkg/daemon"
daemonconsts "github.com/openshift/machine-config-operator/pkg/daemon/constants"
"github.com/openshift/machine-config-operator/pkg/version"
errors "github.com/pkg/errors"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -68,15 +68,15 @@ func bindPodMounts(rootMount string) error {
// This will only affect our mount namespace, not the host
output, err := exec.Command("mount", "--rbind", "/run/secrets", targetSecrets).CombinedOutput()
if err != nil {
return errors.Wrapf(err, "failed to mount /run/secrets to %s: %s", targetSecrets, string(output))
return fmt.Errorf("failed to mount /run/secrets to %s: %s: %w", targetSecrets, string(output), err)
}
return nil
}

func selfCopyToHost() error {
selfExecutableFd, err := os.Open("/proc/self/exe")
if err != nil {
return errors.Wrapf(err, "Opening our binary")
return fmt.Errorf("opening our binary: %w", err)
}
defer selfExecutableFd.Close()
if err := os.MkdirAll(filepath.Dir(daemonconsts.HostSelfBinary), 0755); err != nil {
Expand Down Expand Up @@ -167,7 +167,7 @@ func runStartCmd(cmd *cobra.Command, args []string) {
// In the cluster case, for now we copy our binary out to the host
// for SELinux reasons, see https://bugzilla.redhat.com/show_bug.cgi?id=1839065
if err := selfCopyToHost(); err != nil {
glog.Fatalf("%v", errors.Wrapf(err, "copying self to host"))
glog.Fatalf("%v", fmt.Errorf("copying self to host: %w", err))
return
}

Expand Down
4 changes: 2 additions & 2 deletions internal/kubeutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ func UpdateNodeRetry(client corev1client.NodeInterface, lister corev1lister.Node

patchBytes, err := strategicpatch.CreateTwoWayMergePatch(oldNode, newNode, corev1.Node{})
if err != nil {
return fmt.Errorf("failed to create patch for node %q: %v", nodeName, err)
return fmt.Errorf("failed to create patch for node %q: %w", nodeName, err)
}

node, err = client.Patch(context.TODO(), nodeName, types.StrategicMergePatchType, patchBytes, metav1.PatchOptions{})
return err
}); err != nil {
// may be conflict if max retries were hit
return nil, fmt.Errorf("unable to update node %q: %v", node, err)
return nil, fmt.Errorf("unable to update node %q: %w", node, err)
}
return node, nil
}
2 changes: 1 addition & 1 deletion lib/resourceread/machineconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func ReadMachineConfigV1(objBytes []byte) (*mcfgv1.MachineConfig, error) {

m, err := runtime.Decode(mcfgCodecs.UniversalDecoder(mcfgv1.SchemeGroupVersion), objBytes)
if err != nil {
return nil, fmt.Errorf("failed to decode raw bytes to mcfgv1.SchemeGroupVersion: %v", err)
return nil, fmt.Errorf("failed to decode raw bytes to mcfgv1.SchemeGroupVersion: %w", err)
}
if m == nil {
return nil, fmt.Errorf("expected mcfgv1.SchemeGroupVersion but got nil")
Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ func (b *Bootstrap) Run(destDir string) error {

file, err := os.Open(filepath.Join(b.manifestDir, info.Name()))
if err != nil {
return fmt.Errorf("error opening %s: %v", file.Name(), err)
return fmt.Errorf("error opening %s: %w", file.Name(), err)
}
defer file.Close()

manifests, err := parseManifests(file.Name(), file)
if err != nil {
return fmt.Errorf("error parsing manifests from %s: %v", file.Name(), err)
return fmt.Errorf("error parsing manifests from %s: %w", file.Name(), err)
}

for idx, m := range manifests {
Expand All @@ -104,7 +104,7 @@ func (b *Bootstrap) Run(destDir string) error {
glog.V(4).Infof("skipping path %q [%d] manifest because it is not part of expected api group: %v", file.Name(), idx+1, err)
continue
}
return fmt.Errorf("error parsing %q [%d] manifest: %v", file.Name(), idx+1, err)
return fmt.Errorf("error parsing %q [%d] manifest: %w", file.Name(), idx+1, err)
}

switch obj := obji.(type) {
Expand Down Expand Up @@ -268,7 +268,7 @@ func parseManifests(filename string, r io.Reader) ([]manifest, error) {
if err == io.EOF {
return manifests, nil
}
return manifests, fmt.Errorf("error parsing %q: %v", filename, err)
return manifests, fmt.Errorf("error parsing %q: %w", filename, err)
}
m.Raw = bytes.TrimSpace(m.Raw)
if len(m.Raw) == 0 || bytes.Equal(m.Raw, []byte("null")) {
Expand Down
Loading