Skip to content

Commit 5a1476c

Browse files
committed
add some error handling
1 parent 440a327 commit 5a1476c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,17 +654,20 @@ func (c *controller) sync(ctx context.Context) {
654654

655655
if !ok {
656656
level.Error(c.logger).Log("msg", "failed type assertion from expected StatefulSet")
657+
continue
657658
}
658659

659660
hashring, ok := sts.Labels[hashringLabelKey]
660661
if !ok {
662+
level.Error(c.logger).Log("msg", "failed to get hashring label from StatefulSet", "sts", sts.Name)
661663
continue
662664
}
663665

664666
stsReplica, exist := c.replicas[sts.Name]
665667
desiredReplicas, err := c.getStsDesiredReplicas(ctx, sts)
666-
if err != nil {
668+
if err != nil || desiredReplicas == 0 {
667669
level.Error(c.logger).Log("msg", "failed to get desired replicas for Statefulset", "sts", sts.Name, "err", err)
670+
continue
668671
}
669672
stsReplicas[sts.Name] = desiredReplicas
670673
// If hashring is not initialized, need to wait for all pods ready within statefulset before generating hashring

0 commit comments

Comments
 (0)