Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: agent-uninstall.sh doesn't doesn't just act on the OH agent for getting node id #4179

Closed
dlarson04 opened this issue Dec 4, 2024 · 1 comment · Fixed by #4188
Closed
Assignees

Comments

@dlarson04
Copy link
Contributor

Describe the bug.

This section of agent-uninstall.sh filters on the label to get the pod

    if [[ $($KUBECTL get pods -n ${AGENT_NAMESPACE} -l app=agent,type!=auto-upgrade-cronjob -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" ]]; then
	    AGENT_POD_READY="false"
    else
	    AGENT_POD_READY="true"
    fi

But this next section does not

    if [ "$AGENT_POD_READY" == "true" ]; then
    	POD_ID=$($KUBECTL get pod -n ${AGENT_NAMESPACE} 2> /dev/null | grep "agent-" | cut -d " " -f1 2> /dev/null)
    	if [ -n "${POD_ID}" ]; then
        	log_info "get pod: ${POD_ID}"
    	else
        	log_info "Failed to get pod id, exiting..."
        	exit 1
    	fi
    fi

So if you have another pod running that has agent- in its name the script will get both of them

This is what the log looks like in that situation...

We should only get the PODID that has the label of "app=agent"

+ get_agent_pod_id
+ log_debug 'get_agent_pod_id() begin'
+ log 5 'DEBUG: get_agent_pod_id() begin'
+ '[' 3 -ge 5 ']'
++ k3s kubectl get pods -n mesh-nov15-1 -l 'app=agent,type!=auto-upgrade-cronjob' -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}'
+ [[ True != \T\r\u\e ]]
+ AGENT_POD_READY=true
+ '[' true == true ']'
++ k3s kubectl get pod -n mesh-nov15-1
++ cut -d ' ' -f1
++ grep agent-
+ POD_ID='agent-84579d8b7b-9zlbq
mesh-rhsi-agent-bc4d65977-qccf7'
+ '[' -n 'agent-84579d8b7b-9zlbq
mesh-rhsi-agent-bc4d65977-qccf7' ']'
+ log_info 'get pod: agent-84579d8b7b-9zlbq
mesh-rhsi-agent-bc4d65977-qccf7'
+ log 3 'INFO: get pod: agent-84579d8b7b-9zlbq
mesh-rhsi-agent-bc4d65977-qccf7'
+ '[' 3 -ge 3 ']'
++ now
+++ date '+%Y-%m-%d %H:%M:%S'
++ echo 2024-12-04 04:48:57
+ echo 2024-12-04 04:48:57 'INFO: get pod: agent-84579d8b7b-9zlbq
mesh-rhsi-agent-bc4d65977-qccf7'
2024-12-04 04:48:57 INFO: get pod: agent-84579d8b7b-9zlbq
mesh-rhsi-agent-bc4d65977-qccf7
+ log_debug 'get_agent_pod_id() end'
+ log 5 'DEBUG: get_agent_pod_id() end'
+ '[' 3 -ge 5 ']'
+ [[ true == \t\r\u\e ]]
+ removeNodeFromLocalAndManagementHub
+ log_debug 'removeNodeFromLocalAndManagementHub() begin'
+ log 5 'DEBUG: removeNodeFromLocalAndManagementHub() begin'
+ '[' 3 -ge 5 ']'
+ log_info 'Check node status for agent pod: agent-84579d8b7b-9zlbq
mesh-rhsi-agent-bc4d65977-qccf7'
+ log 3 'INFO: Check node status for agent pod: agent-84579d8b7b-9zlbq
mesh-rhsi-agent-bc4d65977-qccf7'
+ '[' 3 -ge 3 ']'
++ now
+++ date '+%Y-%m-%d %H:%M:%S'
++ echo 2024-12-04 04:48:57
+ echo 2024-12-04 04:48:57 'INFO: Check node status for agent pod: agent-84579d8b7b-9zlbq
mesh-rhsi-agent-bc4d65977-qccf7'
2024-12-04 04:48:57 INFO: Check node status for agent pod: agent-84579d8b7b-9zlbq
mesh-rhsi-agent-bc4d65977-qccf7
++ k3s kubectl exec -it agent-84579d8b7b-9zlbq mesh-rhsi-agent-bc4d65977-qccf7 -n mesh-nov15-1 -- bash -c 'hzn node list'

Describe the steps to reproduce the behavior.

No response

Expected behavior.

No response

Screenshots.

No response

Operating Environment

Linux

Additional Information

No response

@dlarson04
Copy link
Contributor Author

2 more changes to agent-uninstall.sh

need to escape the ) character too with

s/)/\\)/g

Also, there is 2 functions called now... Should delete one of them.

LiilyZhang added a commit to LiilyZhang/anax that referenced this issue Dec 6, 2024
…t act on the OH agent for getting node id

Signed-off-by: zhangl <[email protected]>
LiilyZhang added a commit to LiilyZhang/anax that referenced this issue Dec 6, 2024
…t act on the OH agent for getting node id

Signed-off-by: zhangl <[email protected]>
LiilyZhang added a commit that referenced this issue Dec 11, 2024
Issue #4179 - Bug: agent-uninstall.sh doesn't doesn't jus…
LiilyZhang added a commit to LiilyZhang/anax that referenced this issue Dec 13, 2024
…t act on the OH agent for getting node id

Signed-off-by: zhangl <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants