Skip to content

Commit 87b948c

Browse files
authored
label length limited to 64 characters (#2237)
* label length Signed-off-by: Allen Li <liyuchen223@gmail.com> * 1 Signed-off-by: Allen Li <liyuchen223@gmail.com> --------- Signed-off-by: Allen Li <liyuchen223@gmail.com>
1 parent 1a699d3 commit 87b948c

File tree

2 files changed

+37
-12
lines changed

2 files changed

+37
-12
lines changed

cp3pt0-deployment/common/utils.sh

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,10 @@ function wait_for_certificate() {
279279
function wait_for_csv() {
280280
local namespace=$1
281281
local package_name=$2
282-
local condition="${OC} get subscription.operators.coreos.com -l operators.coreos.com/${package_name}.${namespace}='' -n ${namespace} -o yaml -o jsonpath='{.items[*].status.installedCSV}'"
283-
local debug_condition="${OC} get subscription.operators.coreos.com -l operators.coreos.com/${package_name}.${namespace}='' -n ${namespace} -o jsonpath='{.items[*].status.conditions}'"
282+
local key="${package_name}.${namespace}"
283+
local length_limited_key=$(echo ${key:0:63})
284+
local condition="${OC} get subscription.operators.coreos.com -l operators.coreos.com/${length_limited_key}='' -n ${namespace} -o yaml -o jsonpath='{.items[*].status.installedCSV}'"
285+
local debug_condition="${OC} get subscription.operators.coreos.com -l operators.coreos.com/${length_limited_key}='' -n ${namespace} -o jsonpath='{.items[*].status.conditions}'"
284286

285287
local retries=180
286288
local sleep_time=10
@@ -337,8 +339,10 @@ function wait_for_operand_request() {
337339
function wait_for_nss_patch() {
338340
local namespace=$1
339341
local package_name=$2
342+
local key="${package_name}.${namespace}"
343+
local length_limited_key=$(echo ${key:0:63})
340344

341-
local sub_name=$(${OC} get subscription.operators.coreos.com -n ${namespace} -l operators.coreos.com/${package_name}.${namespace}='' --no-headers | awk '{print $1}')
345+
local sub_name=$(${OC} get subscription.operators.coreos.com -n ${namespace} -l operators.coreos.com/${length_limited_key}='' --no-headers | awk '{print $1}')
342346
local csv_name=$(${OC} get subscription.operators.coreos.com ${sub_name} -n ${namespace} --ignore-not-found -o jsonpath={.status.installedCSV})
343347

344348
local condition="${OC} -n ${namespace} get csv ${csv_name} -o jsonpath='{.spec.install.spec.deployments[0].spec.template.spec.containers[0].env[?(@.name==\"WATCH_NAMESPACE\")].valueFrom.configMapKeyRef.name}'| grep 'namespace-scope'"
@@ -507,8 +511,11 @@ function wait_for_operator_upgrade() {
507511
local package_name=$2
508512
local channel=$3
509513
local install_mode=$4
510-
local condition="${OC} get subscription.operators.coreos.com -l operators.coreos.com/${package_name}.${namespace}='' -n ${namespace} -o yaml -o jsonpath='{.items[*].status.installedCSV}' | grep -w $channel"
511-
local debug_condition="${OC} get subscription.operators.coreos.com -l operators.coreos.com/${package_name}.${namespace}='' -n ${namespace} -o jsonpath='{.items[*].status.conditions}'"
514+
local key="${package_name}.${namespace}"
515+
# k8s label name length limit to 64 characters
516+
local length_limited_key=$(echo ${key:0:63})
517+
local condition="${OC} get subscription.operators.coreos.com -l operators.coreos.com/${length_limited_key}='' -n ${namespace} -o yaml -o jsonpath='{.items[*].status.installedCSV}' | grep -w $channel"
518+
local debug_condition="${OC} get subscription.operators.coreos.com -l operators.coreos.com/${length_limited_key}='' -n ${namespace} -o jsonpath='{.items[*].status.conditions}'"
512519

513520
local retries=120
514521
local sleep_time=20
@@ -1272,8 +1279,10 @@ function update_operator() {
12721279
local remove_opreq_label=${7:-}
12731280
local retries=5 # Number of retries
12741281
local delay=5 # Delay between retries in seconds
1275-
1276-
local sub_name=$(${OC} get subscription.operators.coreos.com -n ${ns} -l operators.coreos.com/${package_name}.${ns}='' --no-headers | awk '{print $1}')
1282+
local key="${package_name}.${ns}"
1283+
# k8s label name length limit to 64 characters
1284+
local length_limited_key=$(echo ${key:0:63})
1285+
local sub_name=$(${OC} get subscription.operators.coreos.com -n ${ns} -l operators.coreos.com/${length_limited_key}='' --no-headers | awk '{print $1}')
12771286
if [ -z "$sub_name" ]; then
12781287
warning "Not found subscription ${package_name} in ${ns}"
12791288
return 0
@@ -1407,9 +1416,18 @@ function scale_down() {
14071416
local services_ns=$2
14081417
local channel=$3
14091418
local source=$4
1410-
local cs_sub=$(${OC} get subscription.operators.coreos.com -n ${operator_ns} -l operators.coreos.com/ibm-common-service-operator.${operator_ns}='' --no-headers | awk '{print $1}')
1419+
local cs_package="ibm-common-service-operator"
1420+
local cs_key="${cs_package}.${operator_ns}"
1421+
# k8s label name length limit to 64 characters
1422+
local length_limited_cs_key=$(echo ${cs_key:0:63})
1423+
local cs_sub=$(${OC} get subscription.operators.coreos.com -n ${operator_ns} -l operators.coreos.com/${length_limited_cs_key}='' --no-headers | awk '{print $1}')
14111424
local cs_CSV=$(${OC} get subscription.operators.coreos.com ${cs_sub} -n ${operator_ns} --ignore-not-found -o jsonpath={.status.installedCSV})
1412-
local odlm_sub=$(${OC} get subscription.operators.coreos.com -n ${services_ns} -l operators.coreos.com/ibm-odlm.${services_ns}='' --no-headers | awk '{print $1}')
1425+
1426+
local odlm_package="ibm-odlm"
1427+
local odlm_key="${odlm_package}.${services_ns}"
1428+
# k8s label name length limit to 64 characters
1429+
local length_limited_odlm_key=$(echo ${odlm_key:0:63})
1430+
local odlm_sub=$(${OC} get subscription.operators.coreos.com -n ${services_ns} -l operators.coreos.com/${length_limited_odlm_key}='' --no-headers | awk '{print $1}')
14131431
local odlm_CSV=$(${OC} get subscription.operators.coreos.com ${odlm_sub} -n ${services_ns} --ignore-not-found -o jsonpath={.status.installedCSV})
14141432

14151433
${OC} get subscription.operators.coreos.com ${cs_sub} -n ${operator_ns} -o yaml > /tmp/sub.yaml
@@ -1496,7 +1514,9 @@ function scale_up() {
14961514
local services_ns=$2
14971515
local package_name=$3
14981516
local deployment=$4
1499-
local sub=$(${OC} get subscription.operators.coreos.com -n ${operator_ns} -l operators.coreos.com/${package_name}.${operator_ns}='' --no-headers | awk '{print $1}')
1517+
local key="${package_name}.${operator_ns}"
1518+
local length_limited_key=$(echo ${key:0:63})
1519+
local sub=$(${OC} get subscription.operators.coreos.com -n ${operator_ns} -l operators.coreos.com/${length_limited_key}='' --no-headers | awk '{print $1}')
15001520
local csv=$(${OC} get subscription.operators.coreos.com ${sub} -n ${operator_ns} --ignore-not-found -o jsonpath={.status.installedCSV})
15011521

15021522
if [[ "$deployment" == "operand-deployment-lifecycle-manager" ]]; then

cp3pt0-deployment/setup_tenant.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,9 @@ function install_cs_operator() {
637637
else
638638
for ns in ${ns_list//,/ }; do
639639
if [[ "$ns" != "$OPERATOR_NS" ]]; then
640-
local sub_name=$(${OC} get subscription.operators.coreos.com -n ${ns} -l operators.coreos.com/${pm}.${ns}='' --no-headers | awk '{print $1}')
640+
local key="${pm}.${ns}"
641+
local length_limited_key=$(echo ${key:0:63})
642+
local sub_name=$(${OC} get subscription.operators.coreos.com -n ${ns} -l operators.coreos.com/${length_limited_key}='' --no-headers | awk '{print $1}')
641643
if [ ! -z "$sub_name" ]; then
642644
op_source=$SOURCE
643645
op_source_ns=$SOURCE_NS
@@ -788,7 +790,10 @@ EOF
788790
function upgrade_mitigation() {
789791
# When it is upgrade scenario, and it is complex toppology, then do the mitigation
790792
if [[ $IS_UPGRADE -eq 1 && $IS_NOT_COMPLEX_TOPOLOGY -eq 0 ]]; then
791-
local sub_name=$(${OC} get subscription.operators.coreos.com -n ${OPERATOR_NS} -l operators.coreos.com/ibm-common-service-operator.${OPERATOR_NS}='' --no-headers | awk '{print $1}')
793+
local package_name="ibm-common-service-operator"
794+
local key="${package_name}.${OPERATOR_NS}"
795+
local length_limited_key=$(echo ${key:0:63})
796+
local sub_name=$(${OC} get subscription.operators.coreos.com -n ${OPERATOR_NS} -l operators.coreos.com/${length_limited_key}='' --no-headers | awk '{print $1}')
792797
local csv_name=$(${OC} get subscription.operators.coreos.com ${sub_name} -n ${OPERATOR_NS} --ignore-not-found -o jsonpath={.status.installedCSV})
793798
if [[ ! -z ${csv_name} ]]; then
794799
local csv_deleted=$(${OC} get csv -n ${OPERATOR_NS} --ignore-not-found -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep ibm-common-service-operator | grep -v ${csv_name})

0 commit comments

Comments
 (0)