Skip to content

Commit c583088

Browse files
authored
label length limitation (#341)
* label length cutoff Signed-off-by: Allen Li <[email protected]> * update character type Signed-off-by: Allen Li <[email protected]> * remove unnecessary conversion Signed-off-by: Allen Li <[email protected]> * remove string conversion Signed-off-by: Allen Li <[email protected]> --------- Signed-off-by: Allen Li <[email protected]>
1 parent 14e6660 commit c583088

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

controllers/common/util.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,10 @@ func GetResourcesDynamically(ctx context.Context, dynamic dynamic.Interface, gro
156156

157157
return list.Items, nil
158158
}
159+
160+
func GetFirstNCharacter(str string, n int) string {
161+
if n >= len(str) {
162+
return str
163+
}
164+
return str[:n]
165+
}

controllers/namespacescope_controller.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,9 +1015,11 @@ func (r *NamespaceScopeReconciler) CSVReconcile(ctx context.Context, req ctrl.Re
10151015
for _, packageName := range candidateSet.ToSlice() {
10161016
managedCSVList = append(managedCSVList, packageName.(string))
10171017
csvList := &olmv1alpha1.ClusterServiceVersionList{}
1018+
labelKey := packageName.(string) + "." + instance.Namespace
1019+
labelKey = util.GetFirstNCharacter(labelKey, 63)
10181020
if err := r.Client.List(ctx, csvList, &client.ListOptions{
10191021
LabelSelector: labels.SelectorFromSet(map[string]string{
1020-
"operators.coreos.com/" + packageName.(string) + "." + instance.Namespace: "",
1022+
"operators.coreos.com/" + labelKey: "",
10211023
})}); err != nil {
10221024
klog.Error(err)
10231025
return ctrl.Result{}, err

0 commit comments

Comments
 (0)