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

fix: use "double fork" to invoke port forward within Taskfile #1148

Merged
merged 11 commits into from
Jan 14, 2025

Conversation

JeffreyDallas
Copy link
Contributor

@JeffreyDallas JeffreyDallas commented Jan 13, 2025

Description

This pull request changes the following:

  • Tried various method suggested by stackoverflow, chatGPT, Gemini, all suggesting Taskfile may have some bugs/limitation that causing "port-forward" was created in incorrect process groups. The workaround is to use double fork to invoke a program.
  • Remove re-enable port-foward from test script

Related Issues

Signed-off-by: Jeffrey Tang <[email protected]>
Signed-off-by: Jeffrey Tang <[email protected]>
Signed-off-by: Jeffrey Tang <[email protected]>
Signed-off-by: Jeffrey Tang <[email protected]>
@JeffreyDallas JeffreyDallas requested review from a team as code owners January 13, 2025 18:33
@JeffreyDallas JeffreyDallas marked this pull request as draft January 13, 2025 18:33
@JeffreyDallas
Copy link
Contributor Author

Reference from Gemini

The Problem: Process Groups and Signal Propagation

The core issue is very likely related to process groups and how signals are propagated within them. Even with setsid (which creates a new session), if the kubectl port-forward process isn't properly placed in its own process group, Taskfile (or its parent process) might be sending signals that inadvertently terminate the kubectl process when a connection is established and then closed.

Here's why this happens:

Process Groups: Processes are organized into process groups. When a signal is sent to a process group, all processes within that group receive the signal.

Taskfile's Process Management: Taskfile, when it finishes executing a task, might be sending signals (like SIGHUP or SIGTERM) to its child processes and their process groups.

Connection Establishment and Closure: When you connect with nc, the following happens:

nc connects to the forwarded port.
kubectl handles the connection, forwarding traffic to the pod.
nc closes the connection.
This connection closure might be triggering some internal cleanup or signal handling within kubectl. If kubectl is still in the same process group as Taskfile, Taskfile's cleanup signals might then reach kubectl, causing it to exit.

The Solution: Explicit Process Group Management

The most reliable solution is to explicitly create a new process group for the kubectl port-forward process. This ensures that signals sent by Taskfile won't affect it

@JeffreyDallas JeffreyDallas changed the title fix: use "double forking" to invoke port forward within Taskfile fix: use "double fork" to invoke port forward within Taskfile Jan 13, 2025
…portforward-quit-task

Signed-off-by: Jeffrey Tang <[email protected]>

# Conflicts:
#	Taskfile.helper.yml
Copy link
Contributor

github-actions bot commented Jan 13, 2025

Unit Test Results - Linux

  1 files  ±0   58 suites  ±0   4s ⏱️ ±0s
227 tests ±0  227 ✅ ±0  0 💤 ±0  0 ❌ ±0 
232 runs  ±0  232 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit f7dc8ca. ± Comparison against base commit 522b75d.

♻️ This comment has been updated with latest results.

Copy link
Contributor

github-actions bot commented Jan 13, 2025

Unit Test Results - Windows

  1 files  ±0   58 suites  ±0   13s ⏱️ ±0s
227 tests ±0  227 ✅ ±0  0 💤 ±0  0 ❌ ±0 
232 runs  ±0  232 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit f7dc8ca. ± Comparison against base commit 522b75d.

♻️ This comment has been updated with latest results.

@jeromy-cannon
Copy link
Contributor

@JeffreyDallas , I already fixed this: #1132

@JeffreyDallas JeffreyDallas marked this pull request as ready for review January 13, 2025 20:00
Copy link
Contributor

E2E Test Report

 16 files  ±0  121 suites  ±0   1h 22m 7s ⏱️ -33s
258 tests ±0  258 ✅ ±0  0 💤 ±0  0 ❌ ±0 
261 runs  ±0  261 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 9dd76c4. ± Comparison against base commit 0784b46.

Copy link
Contributor

github-actions bot commented Jan 13, 2025

E2E Test Report

 17 files  126 suites   1h 26m 47s ⏱️
258 tests 258 ✅ 0 💤 0 ❌
269 runs  269 ✅ 0 💤 0 ❌

Results for commit f7dc8ca.

♻️ This comment has been updated with latest results.

Copy link

codacy-production bot commented Jan 13, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for 522b75d1 0.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (522b75d) Report Missing Report Missing Report Missing
Head commit (f7dc8ca) 21171 17728 83.74%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#1148) 2 0 0.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

Copy link

codecov bot commented Jan 13, 2025

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 82.97%. Comparing base (9bc6fcd) to head (f7dc8ca).
Report is 36 commits behind head on main.

Files with missing lines Patch % Lines
src/commands/mirror_node.ts 0.00% 1 Missing ⚠️
src/commands/relay.ts 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1148      +/-   ##
==========================================
- Coverage   83.37%   82.97%   -0.40%     
==========================================
  Files          77       77              
  Lines       20809    21171     +362     
  Branches     1717     1468     -249     
==========================================
+ Hits        17349    17567     +218     
- Misses       3363     3544     +181     
+ Partials       97       60      -37     
Files with missing lines Coverage Δ
src/commands/mirror_node.ts 71.02% <0.00%> (ø)
src/commands/relay.ts 82.02% <0.00%> (ø)

... and 35 files with indirect coverage changes

Impacted file tree graph

instamenta
instamenta previously approved these changes Jan 14, 2025
Taskfile.helper.yml Outdated Show resolved Hide resolved
Copy link
Contributor

@jeromy-cannon jeromy-cannon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should support -q/--quiet on all commands/subcommands. Instead of removing the flag, just add the flag to the destroy subcommands.

Signed-off-by: Jeffrey Tang <[email protected]>
@JeffreyDallas JeffreyDallas merged commit d662d3f into main Jan 14, 2025
40 of 43 checks passed
@JeffreyDallas JeffreyDallas deleted the 01115-D-portforward-quit-task branch January 14, 2025 23:06
swirlds-automation added a commit that referenced this pull request Jan 24, 2025
## [0.34.0](v0.33.0...v0.34.0) (2025-01-24)

### Features

* `solo deployment create` should use the context and cluster provided for where to save the remote config ([#1142](#1142)) ([fe42edd](fe42edd))
* Connect to multicluster deployments and validate remoteConfigs ([#1141](#1141)) ([c78e226](c78e226))
* for v0.59.x or greater set the internal IP address to 127.0.0.1 to avoid an ISS, in config.txt ([#1162](#1162)) ([4ca488b](4ca488b))
* node upgrade command and new e2e tests ([#1133](#1133)) ([1cf5893](1cf5893))
* separate explorer from mirror node install/uninstall ([#1177](#1177)) ([0887fa6](0887fa6))
* solo network destroy should update remote-config ([#1155](#1155)) ([98b028f](98b028f))
* Update solo to load remote config near entry point ([#1176](#1176)) ([473a650](473a650))

### Bug Fixes

* merge error due to change of remote_config_tasks ([#1197](#1197)) ([9d1a8cb](9d1a8cb))
* Normalize mirror node resources path ([#1175](#1175)) ([ab018a7](ab018a7))
* Refactor RemoteConfigTasks class ([#1185](#1185)) ([66cfc4d](66cfc4d))
* remove k8.getKubeConfig ([#1182](#1182)) ([89c557a](89c557a))
* Set mirror node importer startDate ([#1174](#1174)) ([9d9ef53](9d9ef53))
* update hedera explorer chart version and location ([#1188](#1188)) ([0c415ef](0c415ef))
* use "double fork" to invoke port forward within Taskfile ([#1148](#1148)) ([d662d3f](d662d3f))
@swirlds-automation
Copy link
Contributor

🎉 This PR is included in version 0.34.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port-forward called from Taskfile exit itself
4 participants