-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release-1.6] Fix BZ-2080547: mis-read the priority class after update (
#2003) * Fix a bug when updating the priority class Since most of the priority class fiels are emutable, when updating it, HCO remove and re-create it. Then HCO reads the new created priority class in order to set its refertence in the HyperConverged relatedObjects list. The re-reading often fails with "no found" just because some timing and cache issues. This PR is fixing the issue by droping the re-read. Signed-off-by: Nahshon Unna-Tsameret <nunnatsa@redhat.com> * fix the functional test in kubevirtci Signed-off-by: Nahshon Unna-Tsameret <nunnatsa@redhat.com> Co-authored-by: Nahshon Unna-Tsameret <nunnatsa@redhat.com>
- Loading branch information
1 parent
bd29043
commit 75aa9b7
Showing
3 changed files
with
36 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
|
||
# edit priority class labels, causing HCO to recreate it, making sure that the relatedObjects list contains the new priorityClass | ||
|
||
# check that the new priority class was created and that it does not include the new label | ||
function check_priority_class() { | ||
set -ex | ||
OLD_PC_UID=$1 | ||
|
||
# make sure the object was actually changed | ||
NEW_PC_UID=$(${KUBECTL_BINARY} get priorityclass -n ${INSTALLED_NAMESPACE} kubevirt-cluster-critical -o jsonpath='{.metadata.uid}') | ||
[[ "${OLD_PC_UID}" != "${NEW_PC_UID}" ]] | ||
|
||
# read the UID from the HyperConverged relatedObject list | ||
NEW_PC_REF_UID=$(${KUBECTL_BINARY} get hco -n ${INSTALLED_NAMESPACE} kubevirt-hyperconverged -o json | jq -r '.status.relatedObjects[] | select(.kind == "PriorityClass" and .name == "kubevirt-cluster-critical") | .uid') | ||
|
||
[[ "${NEW_PC_UID}" == "${NEW_PC_REF_UID}" ]] | ||
|
||
# make sure the new label was removed: | ||
TEST_LABEL=$(${KUBECTL_BINARY} get priorityclass -n ${INSTALLED_NAMESPACE} kubevirt-cluster-critical -o jsonpath='{.metadata.labels.test}') | ||
[[ -z "${TEST_LABEL}" ]] | ||
} | ||
|
||
export -f check_priority_class | ||
|
||
OLD_PC_REF_UID=$(${KUBECTL_BINARY} get hco -n ${INSTALLED_NAMESPACE} kubevirt-hyperconverged -o json | jq -r '.status.relatedObjects[] | select(.kind == "PriorityClass" and .name == "kubevirt-cluster-critical") | .uid') | ||
OLD_PC_UID=$(${KUBECTL_BINARY} get priorityclass -n ${INSTALLED_NAMESPACE} kubevirt-cluster-critical -o jsonpath='{.metadata.uid}') | ||
[[ "${OLD_PC_REF_UID}" == "${OLD_PC_UID}" ]] | ||
|
||
${KUBECTL_BINARY} patch priorityclass kubevirt-cluster-critical -n ${INSTALLED_NAMESPACE} --type=json -p='[{"op": "add", "path": "/metadata/labels/test", "value": "test"}]' | ||
./hack/retry.sh 3 10 "check_priority_class ${OLD_PC_UID}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters