Skip to content

Commit

Permalink
overwrite nss managed role during upgrade (#2087)
Browse files Browse the repository at this point in the history
Signed-off-by: YuChen <[email protected]>
  • Loading branch information
YCShen1010 authored Jul 10, 2024
1 parent 1e380a4 commit f042b75
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions cp3pt0-deployment/setup_tenant.sh
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,21 @@ roleRef:
EOF
title "Checking and authorizing NSS to all namespaces in tenant..."
for ns in $OPERATOR_NS $SERVICES_NS ${TETHERED_NS//,/ }; do
existing_ns=$(${OC} get nss common-service -n $OPERATOR_NS -o=jsonpath='{.spec.namespaceMembers}' | tr -d \" | tr -d [ | tr -d ])
for ns in ${existing_ns//,/ }; do
if [[ $($OC get RoleBinding nss-managed-role-from-$OPERATOR_NS -n $ns 2>/dev/null) != "" ]] && [[ $($OC get Role nss-managed-role-from-$OPERATOR_NS -n $ns 2>/dev/null) != "" ]];then
info "Role and RoleBinding nss-managed-role-from-$OPERATOR_NS is already existed in $ns, skip creating\n"
if [ $MINIMAL_RBAC_ENABLED -eq 1 ]; then
debug1 "Overwriting existing Role nss-managed-role-from-$OPERATOR_NS in $ns\n"
local role=$(cat ${PREVIEW_DIR}/role.yaml | sed "s/ns_to_replace/$ns/g")
debug1 "$role"
echo ""
echo "$role" | ${OC_CMD} apply -f -
if [[ $? -ne 0 ]]; then
error "Failed to update Role for NSS in namespace $ns, please check if user has proper permission\n"
fi
else
info "Role and RoleBinding nss-managed-role-from-$OPERATOR_NS is already existed in $ns, skip creating\n"
fi
else
debug1 "Creating following Role:\n"
local role=$(cat ${PREVIEW_DIR}/role.yaml | sed "s/ns_to_replace/$ns/g")
Expand Down

0 comments on commit f042b75

Please sign in to comment.