From 2921b9959d0639abae9d5bcd3d577373e3084880 Mon Sep 17 00:00:00 2001 From: Eugen Sumin Date: Tue, 19 Mar 2024 20:00:46 +0100 Subject: [PATCH] Fix NewPureError => NewSentinelErr --- pkg/kube/pod_controller.go | 8 ++++---- pkg/kube/pod_file_writer_test.go | 2 +- pkg/kube/workload.go | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/kube/pod_controller.go b/pkg/kube/pod_controller.go index 752d771513..9580b46098 100644 --- a/pkg/kube/pod_controller.go +++ b/pkg/kube/pod_controller.go @@ -29,10 +29,10 @@ import ( ) var ( - ErrPodControllerNotInitialized = errkit.NewPureError("pod has not been initialized") - ErrPodControllerPodAlreadyStarted = errkit.NewPureError("pod has already been started") - ErrPodControllerPodNotReady = errkit.NewPureError("pod is not yet ready") - ErrPodControllerPodNotStarted = errkit.NewPureError("pod is not yet started") + ErrPodControllerNotInitialized = errkit.NewSentinelErr("pod has not been initialized") + ErrPodControllerPodAlreadyStarted = errkit.NewSentinelErr("pod has already been started") + ErrPodControllerPodNotReady = errkit.NewSentinelErr("pod is not yet ready") + ErrPodControllerPodNotStarted = errkit.NewSentinelErr("pod is not yet started") PodControllerDefaultStopTime = 30 * time.Second PodControllerInfiniteStopTime = 0 * time.Second ) diff --git a/pkg/kube/pod_file_writer_test.go b/pkg/kube/pod_file_writer_test.go index ac9180748f..7c9f1dc3be 100644 --- a/pkg/kube/pod_file_writer_test.go +++ b/pkg/kube/pod_file_writer_test.go @@ -79,7 +79,7 @@ func (s *PodFileWriterTestSuite) TestPodRunnerWriteFile(c *C) { ctx := context.Background() cli := fake.NewSimpleClientset() - simulatedError := errkit.NewPureError("SimulatedError") + simulatedError := errkit.NewSentinelErr("SimulatedError") cases := map[string]func(pfwp *fakePodFileWriterProcessor, pfw PodFileWriter){ "Write to pod failed": func(pfwp *fakePodFileWriterProcessor, pfw PodFileWriter) { diff --git a/pkg/kube/workload.go b/pkg/kube/workload.go index a03b93ca76..0d492f371d 100644 --- a/pkg/kube/workload.go +++ b/pkg/kube/workload.go @@ -310,7 +310,7 @@ func FetchReplicationController(cli kubernetes.Interface, namespace string, uid return nil, nil } -var errNotFound = errkit.NewPureError("not found") +var errNotFound = errkit.NewSentinelErr("not found") // FetchReplicaSet fetches the replicaset matching the specified owner UID func FetchReplicaSet(cli kubernetes.Interface, namespace string, uid types.UID, revision string) (*appsv1.ReplicaSet, error) { @@ -518,7 +518,7 @@ func IsPodRunning(cli kubernetes.Interface, podName, podNamespace string) (bool, func StatefulSetReplicas(ctx context.Context, kubeCli kubernetes.Interface, namespace, name string) (int32, error) { sts, err := kubeCli.AppsV1().StatefulSets(namespace).Get(ctx, name, metav1.GetOptions{}) if err != nil { - return 0, errors.Wrapf(err, "Could not get StatefulSet{Namespace %s, Name: %s}, to figure out replicas", namespace, name) + return 0, errkit.Wrap(err, "Could not get StatefulSet, to figure out replicas", "Namespace", namespace, "StatefulSet", name) } return *sts.Spec.Replicas, nil } @@ -526,7 +526,7 @@ func StatefulSetReplicas(ctx context.Context, kubeCli kubernetes.Interface, name func DeploymentReplicas(ctx context.Context, kubeCli kubernetes.Interface, namespace, name string) (int32, error) { d, err := kubeCli.AppsV1().Deployments(namespace).Get(ctx, name, metav1.GetOptions{}) if err != nil { - return 0, errors.Wrapf(err, "Could not get Deployment{Namespace %s, Name: %s}, to figure out replicas", namespace, name) + return 0, errkit.Wrap(err, "Could not get Deployment, to figure out replicas", "Namespace", namespace, "Deployment", name) } return *d.Spec.Replicas, nil } @@ -534,7 +534,7 @@ func DeploymentReplicas(ctx context.Context, kubeCli kubernetes.Interface, names func DeploymentConfigReplicas(ctx context.Context, osCli osversioned.Interface, namespace, name string) (int32, error) { dc, err := osCli.AppsV1().DeploymentConfigs(namespace).Get(ctx, name, metav1.GetOptions{}) if err != nil { - return 0, errors.Wrapf(err, "Could not get DeploymentConfig{Namespace %s, Name: %s}, to figure out replicas", namespace, name) + return 0, errkit.Wrap(err, "Could not get DeploymentConfig, to figure out replicas", "Namespace", namespace, "DeploymentConfig", name) } return dc.Spec.Replicas, nil }