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
Add doc about running debug directly from assisted-service container #6059
Open
bkopilov
wants to merge
1
commit into
openshift:master
Choose a base branch
from
bkopilov:debug_service_container
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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,91 @@ | ||
|
||
# assisted-service runs on minikube | ||
|
||
## Debug Setup | ||
|
||
To debug assisted-service directly from minikube container | ||
Install minikube setup with assisted-service with one replica | ||
|
||
```shell | ||
export KUBECONFIG=source /root/.kube/config | ||
kubectl patch deployment assisted-service -n assisted-installer --type json -p="[{\"op\": \"remove\", \"path\": \"/spec/template/spec/containers/0/livenessProbe\"}]" | ||
kubectl patch deployment assisted-service -n assisted-installer --type json -p="[{\"op\": \"remove\", \"path\": \"/spec/template/spec/containers/0/readinessProbe\"}]" | ||
oc rollout restart deployment -n assisted-installer assisted-service | ||
``` | ||
|
||
Login to minikube node and attach to assisted-service container | ||
|
||
```shell | ||
oc rsh -n assisted-installer [pod/assisted-service-name] | ||
# install packages git goland and telnet | ||
dnf install procps psmisc golang delve iproute iputils telnet net-tools git -y | ||
``` | ||
|
||
Before running dlv attach make sure assisted-service sources exists | ||
|
||
```shell | ||
git clone https://github.com/openshift/assisted-service.git | ||
# git checkout to the same minikube assisted-service version/tag | ||
``` | ||
After dlv attach we can break by func name or filepath:line | ||
Trigger event from UI, test-infra or others till hit on requested break | ||
|
||
Example for dlv attach to pid 1 (assisted-service) | ||
|
||
```shell | ||
dlv attach 1 | ||
|
||
(dlv) b /assisted-service/internal/bminventory/inventory.go:759 | ||
Breakpoint 1 set at 0x380418e for github.com/openshift/assisted-service/internal/bminventory.verifyMinimalOpenShiftVersionForSingleNode() ./internal/bminventory/inventory.go:759 | ||
(dlv) c | ||
|
||
> github.com/openshift/assisted-service/internal/bminventory.verifyMinimalOpenShiftVersionForSingleNode() ./internal/bminventory/inventory.go:759 (hits goroutine(45458):1 total:1) (PC: 0x380418e) | ||
Warning: debugging optimized function | ||
Warning: listing may not match stale executable | ||
756: | ||
757: func verifyMinimalOpenShiftVersionForSingleNode(requestedOpenshiftVersion string) error { | ||
758: ocpVersion, err := version.NewVersion(requestedOpenshiftVersion) | ||
=> 759: if err != nil { | ||
760: return errors.Errorf("Failed to parse OCP version %s", requestedOpenshiftVersion) | ||
761: } | ||
762: minimalVersionForSno, err := version.NewVersion(minimalOpenShiftVersionForSingleNode) | ||
763: if err != nil { | ||
764: return errors.Errorf("Failed to parse minimal OCP version %s", minimalOpenShiftVersionForSingleNode) | ||
765: } | ||
766: if ocpVersion.LessThan(minimalVersionForSno) { | ||
767: return errors.Errorf("Invalid OCP version (%s) for Single node, Single node OpenShift is supported for version 4.8 and above", requestedOpenshiftVersion) | ||
768: } | ||
769: return nil | ||
|
||
|
||
``` | ||
|
||
When break you can continue step/next/print command (Examples) | ||
|
||
```shell | ||
(dlv) stack | ||
0 0x000000000380418e in github.com/openshift/assisted-service/internal/bminventory.verifyMinimalOpenShiftVersionForSingleNode | ||
at ./internal/bminventory/inventory.go:759 | ||
1 0x00000000037ffe11 in github.com/openshift/assisted-service/internal/bminventory.(*bareMetalInventory).validateRegisterClusterInternalParams | ||
at ./internal/bminventory/inventory.go:399 | ||
2 0x00000000038010f7 in github.com/openshift/assisted-service/internal/bminventory.(*bareMetalInventory).RegisterClusterInternal | ||
at ./internal/bminventory/inventory.go:541 | ||
3 0x000000000383f619 in github.com/openshift/assisted-service/internal/bminventory.(*bareMetalInventory).V2RegisterCluster | ||
at ./internal/bminventory/inventory_v2_handlers.go:46 | ||
|
||
(dlv) locals | ||
ocpVersion = ("*github.com/hashicorp/go-version.Version")(0xc0013e8cd0) | ||
err = error nil | ||
|
||
|
||
(dlv) p ocpVersion | ||
("*github.com/hashicorp/go-version.Version")(0xc0013e8cd0) | ||
*github.com/hashicorp/go-version.Version { | ||
metadata: "", | ||
pre: "", | ||
segments: []int64 len: 3, cap: 4, [4,15,0], | ||
si: 2, | ||
original: "4.15",} | ||
(dlv) whatis ocpVersion | ||
*github.com/hashicorp/go-version.Versio | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any scenario where this is desirable over using the debug image?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only case i can think about is existnig minikue setup and we want to jump in and attach to golang binary to debug ... it might be service but also from agent too on hosts .
Just have a setup and want to get hands dirty quickly .... of course when we reboot the pod all installed stuff deleted....
anyway its up to you , i used to work with python pdb and asked to do the same with golang :) remote ide is also great but you will have to do all preperation before ....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have a good point, I think it's good to document and we have binaries where we do not provide debug tooling.
Maybe we could leverage the image in some cases, but in other it could be preferred to install tools.
Can we add a couple of lines mentioning the image approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paul-maidment Adding Paul about image approach . also we may have a seperate flow for image