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 running sauce connect with --log-file #278

Merged
merged 2 commits into from
Feb 5, 2025
Merged

Conversation

budziam
Copy link
Contributor

@budziam budziam commented Jan 31, 2025

One-line summary

Description

Use the API exposed by Sauce Connect for health checks instead of parsing log lines from stdout. SC5 doesn't print anything (almost) to stdout and stderr when --log-file is passed.

Types of Changes

What types of changes does your code introduce? Keep the ones that apply:

  • Refactor/improvements

@budziam budziam force-pushed the mb/use-api-for-healthcheck branch 3 times, most recently from 329067b to 6d55369 Compare January 31, 2025 17:09
@@ -301,6 +291,18 @@ export default class SauceLabs {
args.push(`--proxy-sauce=${this.proxy}`);
}

// Provide a default runner name. It's used for identifying the tunnel's initiation method.
let metadata = argv.metadata || '';
if (!metadata.includes('runner=')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

good catch. I noticed it before but figured it can be dealt with later

}
args.push(`--metadata=${metadata}`);

const apiAddress = argv.apiAddress || ':8032';
Copy link
Contributor

@waggledans waggledans Jan 31, 2025

Choose a reason for hiding this comment

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

This one is problematic in the sense that it would prevent running two SC instances on the same host without specifying different apiAddress values. It's a normal constraint, just need to make sure it's gracefully handled with a clear error message. I remember it wasn't obvious what's wrong but maybe it's already fixed. Did you try running two instances on the same host without specifying apiAddress? Is it handled in a way that it's obvious why SC doesn't start?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will check that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It fails in the following way

 $ ./bin/sl sc --tunnel-name example2
2025/02/03 15:16:59.199262 [control] [INFO] Sauce Connect Proxy version=5.2.2
2025/02/03 15:16:59.207453 [control] [INFO] configuration
access-key=xxxxx
api-address=:8032
metadata=runner=node-saucelabs
region=us-west-1
tunnel-name=example2
username=[redacted]
2025/02/03 15:16:59.207560 [proxy] [INFO] no upstream proxy specified
2025/02/03 15:16:59.207563 [proxy] [INFO] localhost proxying mode=deny
2025/02/03 15:16:59.207643 [control] [INFO] please wait for 'you may start your tests' to start your tests
2025/02/03 15:16:59.207646 [control] [INFO] provisioning Sauce Connect region=us-west name=example2
2025/02/03 15:17:13.161754 [control] [INFO] Sauce Connect running id=[redacted]
2025/02/03 15:17:13.161891 [tunnel] [INFO] waiting for Sauce Connect server to be reachable
2025/02/03 15:17:21.251507 [ERROR] fatal error exiting: api: failed to open listener on address :8032: listen tcp :8032: bind: address already in use

I believe this is readable enough. WDYT?

@budziam budziam force-pushed the mb/use-api-for-healthcheck branch from 6d55369 to 74be6d0 Compare February 3, 2025 18:12
@budziam budziam changed the title Use SC API for healthcheck Fix running sauce connect with --log-file Feb 4, 2025
@budziam budziam merged commit c326d30 into main Feb 5, 2025
6 checks passed
@budziam budziam deleted the mb/use-api-for-healthcheck branch February 5, 2025 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants