-
Notifications
You must be signed in to change notification settings - Fork 78
SANDBOX-1561 | feature: Make targets for debugging services and operators #1242
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,51 @@ setup-dev-sso: | |
| .PHONY: dev-deploy-e2e-local | ||
| dev-deploy-e2e-local: deploy-e2e-local-to-dev-namespaces print-reg-service-link | ||
|
|
||
| # Builds the services' and operators' images with the debugger in it, so that | ||
| # then an IDE can be connected to them. Since the targets down the line use | ||
| # the default namespaces, we can use them to patch the required CRs in order | ||
| # to launch the binaries with Delve. | ||
| .ONESHELL: | ||
| .PHONY: dev-deploy-e2e-local-debug | ||
| dev-deploy-e2e-local-debug: export DEBUG_MODE=true | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is needed so that the targets in
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. right, but isn't the variable propagated even without the So basically just writing: Maybe not, I'm not a big Makefile expert.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me try it, because I'm not sure either...
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gotcha! thanks for looking into it. |
||
| dev-deploy-e2e-local-debug: | ||
| $(MAKE) dev-deploy-e2e-local | ||
|
|
||
| # Get the CSVs for the host and member operators, in order to be able to | ||
| # patch them. | ||
| HOST_CSV_NAME=$$(oc get --namespace="${DEFAULT_HOST_NS}" --output name ClusterServiceVersion) | ||
| MEMBER_CSV_NAME=$$(oc get --namespace="${DEFAULT_MEMBER_NS}" --output name ClusterServiceVersion) | ||
|
|
||
| # Patch the host operator indicating which command the registration | ||
| # service should be run with. The command simply adds an environment | ||
| # variable to the operator which then makes sure that the registration | ||
| # service is run with Delve, in case the user wants to connect to it. | ||
| if ! oc get "${HOST_CSV_NAME}" --output jsonpath="{.spec.install.spec.deployments[0].spec.template.spec.containers[1].env}" | grep -q "REGISTRATION_SERVICE_COMMAND"; then \ | ||
| oc patch --namespace="${DEFAULT_HOST_NS}" "$${HOST_CSV_NAME}" --type='json' --patch='[{"op": "add", "path": "/spec/install/spec/deployments/0/spec/template/spec/containers/1/env/-", "value": {"name": "REGISTRATION_SERVICE_COMMAND", "value": "[\"dlv\", \"--listen=:50000\", \"--headless\", \"--continue\", \"--api-version=2\", \"--accept-multiclient\", \"exec\", \"/usr/local/bin/registration-service\"]"}}]' | ||
|
|
||
| # Wait for the registration service's command to have the "dlv" bit, and the rollout for its deployment to be | ||
| # complete. | ||
| @echo "Waiting for the registration service's deployment to get updated..." | ||
| oc wait --namespace="${DEFAULT_HOST_NS}" --timeout=3m --for=jsonpath='{.spec.template.spec.containers[0].command[0]}'="dlv" "deployment/registration-service" | ||
| oc rollout status --namespace="${DEFAULT_HOST_NS}" --timeout=3m deployment/registration-service | ||
| fi | ||
|
|
||
| # Reduce the registration service's replicas to 1, in order to facilitate | ||
| # the port forwarding and debugging of the service. | ||
| oc patch --namespace="${DEFAULT_HOST_NS}" ToolchainConfig config --type='merge' --patch='{"spec":{"host":{"registrationService":{"replicas":1}}}}' | ||
| @echo "Waiting for the registration service to get scaled to 1 replicas..." | ||
| oc wait --namespace="${DEFAULT_HOST_NS}" --timeout=3m --for=jsonpath='{.spec.replicas}'="1" "deployment/registration-service" | ||
|
|
||
| # Patch the host-operator and member-operator CSVs to make them run with | ||
| # Delve. | ||
| oc patch --namespace="${DEFAULT_HOST_NS}" "$${HOST_CSV_NAME}" --type='json' --patch='[{"op": "replace", "path": "/spec/install/spec/deployments/0/spec/template/spec/containers/1/args", "value": []}, {"op": "replace", "path": "/spec/install/spec/deployments/0/spec/template/spec/containers/1/command", "value": ["dlv", "--listen=:50000", "--headless", "--continue", "--api-version=2", "--accept-multiclient", "exec", "/usr/local/bin/host-operator", "--", "--health-probe-bind-address=:8081", "--metrics-bind-address=127.0.0.1:8080", "--leader-elect"]}]' | ||
| @echo "Waiting for the host operator to be ready..." | ||
| oc wait --namespace "${DEFAULT_HOST_NS}" "$${HOST_CSV_NAME}" --for=jsonpath='{.status.phase}'=Succeeded --timeout=300s | ||
|
|
||
| oc patch --namespace="${DEFAULT_MEMBER_NS}" "$${MEMBER_CSV_NAME}" --type='json' --patch='[{"op": "replace", "path": "/spec/install/spec/deployments/0/spec/template/spec/containers/0/args", "value": []}, {"op": "replace", "path": "/spec/install/spec/deployments/0/spec/template/spec/containers/0/command", "value": ["dlv", "--listen=:50000", "--headless", "--continue", "--api-version=2", "--accept-multiclient", "exec", "/usr/local/bin/member-operator", "--", "--health-probe-bind-address=:8081", "--metrics-bind-address=127.0.0.1:8080", "--leader-elect"]}]' | ||
| @echo "Waiting for the member operator to be ready..." | ||
| oc wait --namespace "${DEFAULT_HOST_NS}" "$${HOST_CSV_NAME}" --for=jsonpath='{.status.phase}'=Succeeded --timeout=300s | ||
|
Comment on lines
+83
to
+85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Wait command uses wrong CSV name for member operator. After patching the member operator CSV ( 🐛 Proposed fix oc patch --namespace="${DEFAULT_MEMBER_NS}" "$${MEMBER_CSV_NAME}" --type='json' --patch='[{"op": "replace", "path": "/spec/install/spec/deployments/0/spec/template/spec/containers/0/args", "value": []}, {"op": "replace", "path": "/spec/install/spec/deployments/0/spec/template/spec/containers/0/command", "value": ["dlv", "--listen=:50000", "--headless", "--continue", "--api-version=2", "--accept-multiclient", "exec", "/usr/local/bin/member-operator", "--", "--health-probe-bind-address=:8081", "--metrics-bind-address=127.0.0.1:8080", "--leader-elect"]}]'
`@echo` "Waiting for the member operator to be ready..."
- oc wait --namespace "${DEFAULT_HOST_NS}" "$${HOST_CSV_NAME}" --for=jsonpath='{.status.phase}'=Succeeded --timeout=300s
+ oc wait --namespace "${DEFAULT_MEMBER_NS}" "$${MEMBER_CSV_NAME}" --for=jsonpath='{.status.phase}'=Succeeded --timeout=300s🤖 Prompt for AI Agents |
||
|
|
||
| .PHONY: dev-deploy-e2e-local-two-members | ||
| dev-deploy-e2e-local-two-members: deploy-e2e-local-to-dev-namespaces-two-members print-reg-service-link | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ user_help () { | |
| echo "-rr, --reg-repo-path Path to the registation service repo" | ||
| echo "-ds, --date-suffix Date suffix to be added to some resources that are created" | ||
| echo "-ft, --forced-tag Forces a tag to be set to all built images. In the case deployment the tag is used for index image in the created CatalogSource" | ||
| echo "-dm, --debug-mode Builds and pushes the operator to quay, including a Delve debugger to be able to launch the operator with it" | ||
| echo "-h, --help To show this help text" | ||
| echo "" | ||
| exit 0 | ||
|
|
@@ -68,6 +69,11 @@ read_arguments() { | |
| FORCED_TAG=$1 | ||
| shift | ||
| ;; | ||
| -dm|--debug-mode) | ||
| shift | ||
| DEBUG_MODE=$1 | ||
| shift | ||
| ;; | ||
| *) | ||
| echo "$1 is not a recognized flag!" >> /dev/stderr | ||
| user_help | ||
|
|
@@ -96,7 +102,7 @@ if [[ -n "${CI}${REG_REPO_PATH}${HOST_REPO_PATH}" ]] && [[ $(echo ${REPO_NAME} | | |
| set_tags | ||
|
|
||
| if [[ ${PUBLISH_OPERATOR} == "true" ]]; then | ||
| push_image | ||
| push_image "${DEBUG_MODE}" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wonder whether this should be added as an option for consistency with other options or it's fine to treat it as a special environment variable. @MatousJobanek and @rsoaresd may have thoughts on this
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right, yes. I do agree that it's better to have an additional option for consistency. Refactored! |
||
| REG_SERV_IMAGE_LOC=${IMAGE_LOC} | ||
| REG_REPO_PATH=${REPOSITORY_PATH} | ||
| fi | ||
|
|
@@ -108,7 +114,7 @@ if [[ -n "${CI}${REG_REPO_PATH}${HOST_REPO_PATH}" ]] && [[ $(echo ${REPO_NAME} | | |
| set_tags | ||
|
|
||
| if [[ ${PUBLISH_OPERATOR} == "true" ]]; then | ||
| push_image | ||
| push_image "${DEBUG_MODE}" | ||
| OPERATOR_IMAGE_LOC=${IMAGE_LOC} | ||
| make -C ${REPOSITORY_PATH} publish-current-bundle INDEX_IMAGE_TAG=${BUNDLE_AND_INDEX_TAG} BUNDLE_TAG=${BUNDLE_AND_INDEX_TAG} QUAY_NAMESPACE=${QUAY_NAMESPACE} OTHER_REPO_PATH=${REG_REPO_PATH} OTHER_REPO_IMAGE_LOC=${REG_SERV_IMAGE_LOC} IMAGE=${OPERATOR_IMAGE_LOC} | ||
| fi | ||
|
|
||
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.
.ONESHELLis a global directive that affects all subsequent targets.The
.ONESHELLdirective on Line 46 applies to all targets defined after it in this file, not justdev-deploy-e2e-local-debug. This can have unintended consequences:If
.ONESHELLis needed only for variable persistence in the debug target (forHOST_CSV_NAMEandMEMBER_CSV_NAME), consider moving it to a separate included file or restructuring the target to avoid the need for.ONESHELL.♻️ Alternative approach
Instead of
.ONESHELL, you could capture variables and pass them to a sub-shell:This limits the
.ONESHELL-like behavior to only this target.