Skip to content

Commit dea3ce5

Browse files
committed
Simplify shard and drain labels
1 parent c773fba commit dea3ce5

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

pkg/apis/sharding/v1alpha1/constants.go

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@ limitations under the License.
1616

1717
package v1alpha1
1818

19-
import (
20-
"crypto/sha256"
21-
"encoding/hex"
22-
23-
"k8s.io/utils/strings"
24-
)
25-
2619
// This file contains API-related constants for the sharding implementation, e.g. well-known annotations and labels.
2720

2821
const (
@@ -51,26 +44,15 @@ const (
5144
// IdentityShardLeaseController is the identity that the shardlease controller uses to acquire leases of unavailable
5245
// shards.
5346
IdentityShardLeaseController = "shardlease-controller"
54-
55-
delimiter = "-"
5647
)
5748

5849
// LabelShard returns the label on sharded objects that holds the name of the responsible shard within a ring.
5950
func LabelShard(ringName string) string {
60-
return LabelShardPrefix + RingSuffix(ringName)
51+
return LabelShardPrefix + ringName
6152
}
6253

6354
// LabelDrain returns the label on sharded objects that instructs the responsible shard within a ring to stop reconciling
6455
// the object and remove both the shard and drain label.
6556
func LabelDrain(ringName string) string {
66-
return LabelDrainPrefix + RingSuffix(ringName)
67-
}
68-
69-
// RingSuffix returns the label key for a given ring name that is appended to a qualified prefix.
70-
func RingSuffix(ringName string) string {
71-
keyHash := sha256.Sum256([]byte(ringName))
72-
hexHash := hex.EncodeToString(keyHash[:])
73-
74-
// the label part after the "/" must not exceed 63 characters, cut off at 63 characters
75-
return strings.ShortenString(hexHash[:8]+delimiter+ringName, 63)
57+
return LabelDrainPrefix + ringName
7658
}

0 commit comments

Comments
 (0)