Skip to content
Open
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
3 changes: 2 additions & 1 deletion api/v2/weightsandbiases_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,8 @@ type RedisConfig struct {
}

type RedisSentinelSpec struct {
Enabled bool `json:"enabled"`
// +kubebuilder:default=true
Enabled *bool `json:"enabled,omitempty"`
Config RedisSentinelConfig `json:"config,omitempty"`
}

Expand Down
5 changes: 5 additions & 0 deletions api/v2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions config/crd/bases/apps.wandb.com_weightsandbiases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3864,9 +3864,8 @@ spec:
type: object
type: object
enabled:
default: true
type: boolean
required:
- enabled
type: object
storageSize:
type: string
Expand Down
8 changes: 8 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -396,3 +396,11 @@ rules:
- securitycontextconstraints
verbs:
- use
- apiGroups:
- storage.k8s.io
resources:
- storageclasses
verbs:
- get
- list
- watch
10 changes: 9 additions & 1 deletion deploy/operator/templates/wandb-operator-wandb-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ kind: ClusterRole
metadata:
name: {{ .Release.Name }}-wandb
rules:
- apiGroups:
- storage.k8s.io
resources:
- storageclasses
verbs:
- get
- list
- watch
- apiGroups:
- apps.wandb.com
resources:
Expand Down Expand Up @@ -210,4 +218,4 @@ subjects:
- kind: ServiceAccount
name: {{ include "wandb-operator.fullname" . }}
namespace: {{ .Release.Namespace }}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion internal/controller/common/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ const (
)

var NotReadyStates = []string{
ErrorState, PendingState, UnavailableState,
ErrorState, PendingState, DegradedState, UnknownState, UnavailableState,
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func ReadState(
}}
}

return computeKeeperReadyCondition(ctx, podsRunning)
return computeKeeperReadyCondition(ctx, expectedKeeperPodCount(actual), podsRunning)
}

func keeperPodsRunningStatus(
Expand All @@ -70,7 +70,7 @@ func keeperPodsRunningStatus(
return result, nil
}

func computeKeeperReadyCondition(ctx context.Context, podsRunning map[string]bool) []metav1.Condition {
func computeKeeperReadyCondition(ctx context.Context, expectedPodCount int, podsRunning map[string]bool) []metav1.Condition {
log := logx.GetSlog(ctx)

var runningCount, podCount int
Expand All @@ -80,19 +80,19 @@ func computeKeeperReadyCondition(ctx context.Context, podsRunning map[string]boo
runningCount++
}
}
log.Info("Keeper pods status", "running", runningCount, "total", podCount)
log.Info("Keeper pods status", "running", runningCount, "reported", podCount, "expected", expectedPodCount)

status := metav1.ConditionUnknown
reason := common.UnknownReason
message := ""
switch {
case podCount > 0 && podCount == runningCount:
case expectedPodCount > 0 && podCount == expectedPodCount && podCount == runningCount:
status = metav1.ConditionTrue
reason = common.ResourceExistsReason
case podCount > 0:
case expectedPodCount > 0 || podCount > 0:
status = metav1.ConditionFalse
reason = common.NoResourceReason
message = fmt.Sprintf("%d of %d keeper pods running", runningCount, podCount)
message = fmt.Sprintf("%d of %d expected keeper pods running (%d reported)", runningCount, expectedPodCount, podCount)
}

return []metav1.Condition{{
Expand All @@ -102,3 +102,21 @@ func computeKeeperReadyCondition(ctx context.Context, podsRunning map[string]boo
Message: message,
}}
}

func expectedKeeperPodCount(chk *chkv1.ClickHouseKeeperInstallation) int {
if chk == nil || chk.Spec.Configuration == nil {
return 0
}
var count int
for _, cluster := range chk.Spec.Configuration.Clusters {
if cluster == nil || cluster.Layout == nil {
continue
}
replicas := cluster.Layout.ReplicasCount
if replicas < 1 {
replicas = 1
}
count += replicas
}
return count
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,26 @@ import (

var _ = Describe("Keeper readiness", func() {
It("is ready when all pods are running", func() {
conds := computeKeeperReadyCondition(context.Background(), map[string]bool{"a": true, "b": true, "c": true})
conds := computeKeeperReadyCondition(context.Background(), 3, map[string]bool{"a": true, "b": true, "c": true})
Expect(conds).To(HaveLen(1))
Expect(conds[0].Type).To(Equal(KeeperReportedReadyType))
Expect(conds[0].Status).To(Equal(metav1.ConditionTrue))
})

It("is not ready when some pods are not running", func() {
conds := computeKeeperReadyCondition(context.Background(), map[string]bool{"a": true, "b": false, "c": true})
conds := computeKeeperReadyCondition(context.Background(), 3, map[string]bool{"a": true, "b": false, "c": true})
Expect(conds[0].Status).To(Equal(metav1.ConditionFalse))
Expect(conds[0].Message).To(ContainSubstring("2 of 3"))
})

It("is unknown when no pods are reported yet", func() {
conds := computeKeeperReadyCondition(context.Background(), map[string]bool{})
Expect(conds[0].Status).To(Equal(metav1.ConditionUnknown))
It("is not ready when no desired pods are reported yet", func() {
conds := computeKeeperReadyCondition(context.Background(), 3, map[string]bool{})
Expect(conds[0].Status).To(Equal(metav1.ConditionFalse))
})

It("is not ready when fewer pods are reported than desired", func() {
conds := computeKeeperReadyCondition(context.Background(), 3, map[string]bool{"a": true})
Expect(conds[0].Status).To(Equal(metav1.ConditionFalse))
Expect(conds[0].Message).To(ContainSubstring("1 of 3 expected"))
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ func ToKeeperVendorSpec(
}

labels := common.BuildWandbLabels(wandb, KeeperModuleName)
settings := chiv1.NewSettings()
settings.Set("keeper_server/enable_reconfiguration", chiv1.NewSettingScalar("true"))

podSpec := corev1.PodSpec{
SecurityContext: keeperPodSecurityContext(),
Expand Down Expand Up @@ -70,6 +72,7 @@ func ToKeeperVendorSpec(
},
Spec: chkv1.ChkSpec{
Configuration: &chkv1.Configuration{
Settings: settings,
Clusters: []*chkv1.Cluster{
{
Name: ClusterName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ var _ = Describe("Keeper vendor spec", func() {

Expect(chk.Spec.Configuration.Clusters).To(HaveLen(1))
Expect(chk.Spec.Configuration.Clusters[0].Layout.ReplicasCount).To(Equal(5))
Expect(chk.Spec.Configuration.Settings.Get("keeper_server/enable_reconfiguration").String()).To(Equal("true"))

Expect(chk.Spec.Templates.VolumeClaimTemplates).To(HaveLen(1))
storage := chk.Spec.Templates.VolumeClaimTemplates[0].Spec.Resources.Requests[corev1.ResourceStorage]
Expand Down
Loading
Loading