Skip to content

Commit

Permalink
Fix workload.go
Browse files Browse the repository at this point in the history
  • Loading branch information
e-sumin committed Mar 19, 2024
1 parent 84bc700 commit e1c3136
Showing 1 changed file with 4 additions and 4 deletions.
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 e1c3136

Please sign in to comment.