Skip to content

Commit

Permalink
Fix NewPureError => NewSentinelErr
Browse files Browse the repository at this point in the history
  • Loading branch information
e-sumin committed Mar 20, 2024
1 parent 84bc700 commit 2921b99
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions pkg/kube/pod_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/kube/pod_file_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions pkg/kube/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -518,23 +518,23 @@ 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
}

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
}

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
}

0 comments on commit 2921b99

Please sign in to comment.