mirror of
https://github.com/sablierapp/sablier.git
synced 2025-12-24 06:28:21 +01:00
fix(kubernetes): consider workload not ready when scaled to 0 (#543)
* test(kubernetes): use testcontainers for test
* fix(kubernetes): get state properly reports the workload as down when scaled to 0
* refactor(kubernetes): split provider in multiple files
* refactor(provider): use Instance prefix for actions
* test(testcontainers): use provider.PullImage
* squash
* Revert "test(testcontainers): use provider.PullImage"
This reverts commit 6f958c48a5.
* test: add random generator thread safety
This commit is contained in:
22
pkg/provider/kubernetes/deployment_inspect.go
Normal file
22
pkg/provider/kubernetes/deployment_inspect.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package kubernetes
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/sablierapp/sablier/app/instance"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
func (p *KubernetesProvider) DeploymentInspect(ctx context.Context, config ParsedName) (instance.State, error) {
|
||||
d, err := p.Client.AppsV1().Deployments(config.Namespace).Get(ctx, config.Name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return instance.State{}, fmt.Errorf("error getting deployment: %w", err)
|
||||
}
|
||||
|
||||
// TODO: Should add option to set ready as soon as one replica is ready
|
||||
if *d.Spec.Replicas != 0 && *d.Spec.Replicas == d.Status.ReadyReplicas {
|
||||
return instance.ReadyInstanceState(config.Original, config.Replicas), nil
|
||||
}
|
||||
|
||||
return instance.NotReadyInstanceState(config.Original, d.Status.ReadyReplicas, config.Replicas), nil
|
||||
}
|
||||
Reference in New Issue
Block a user