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

[credentialhelper] Implement invoking credential helper as subprocess #15861

Closed
wants to merge 2 commits into from

Conversation

Yannic
Copy link
Contributor

@Yannic Yannic commented Jul 11, 2022

@Yannic
Copy link
Contributor Author

Yannic commented Jul 11, 2022

@tjgq PTAL

GSON.toJson(GetCredentialsRequest.newBuilder().setUri(uri).build(), stdin);
}

process.waitFor();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we have a timeout here to avoid hanging Bazel indefinitely? (Just some food for thought, this can be done in a followup)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should!

Copy link
Contributor

Choose a reason for hiding this comment

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

FYI, I will change the timeout error message before submitting internally, because Duration#toString doesn't produce a human-readable format.

throw new IOException(
String.format(
Locale.US,
"Failed to get credentials from helper (exited with code %d): %s",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we be a little more descriptive here? e.g. Failed to get credentials for url {url} from helper {path} ...

Same for the other two IOExceptions below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

}

private static boolean isWindows() {
return File.separatorChar == '\\';
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, changed

.put("header1", ImmutableList.of("value1"))
.build());
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO there's a couple more things we should test:

  • helper returns empty object ("no headers required for this URL")
  • environment variables (i.e., pass an env var to the helper and embed it in the response to verify that it was passed in correctly)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a test for env vars and the CWD of the helper. I don't think we need to test parsing many responses since we have many tests for parsing GetCredentialsResponse from JSON

eprint("Usage: test_credential_helper <command>")
return 1

if argv[1] == "get":
Copy link
Contributor

Choose a reason for hiding this comment

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

Prefer to exit early on error conditions to keep the indentation level as small as possible:

if argv[1] != "get":
  eprint("Unknown command ...")
  return 1

...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@sgowroji sgowroji added team-Remote-Exec Issues and PRs for the Execution (Remote) team awaiting-review PR is awaiting review from an assigned reviewer labels Jul 13, 2022
@Yannic
Copy link
Contributor Author

Yannic commented Jul 14, 2022

PTAL

@Yannic
Copy link
Contributor Author

Yannic commented Jul 15, 2022

@bazel-io flag

@Yannic Yannic deleted the credhelper-call-subprocess branch July 15, 2022 17:06
@bazel-io bazel-io added the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Jul 15, 2022
@sgowroji
Copy link
Member

@bazel-io fork 5.3.0

@bazel-io bazel-io removed the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Jul 18, 2022
sgowroji pushed a commit to sgowroji/bazel that referenced this pull request Jul 18, 2022
sgowroji added a commit that referenced this pull request Jul 18, 2022
…#15900)

Progress on https://github.com/bazelbuild/proposals/blob/main/designs/2022-06-07-bazel-credential-helpers.md
Progress on #15856

Closes #15861.

PiperOrigin-RevId: 461159351
Change-Id: I28eb4817ced8db8f095a1f35092fdefba28e0ede

Co-authored-by: Yannic Bonenberger <yannic@engflow.com>
aranguyen pushed a commit to aranguyen/bazel that referenced this pull request Jul 20, 2022
aranguyen pushed a commit to aranguyen/bazel that referenced this pull request Jul 20, 2022
@ShreeM01 ShreeM01 removed the awaiting-review PR is awaiting review from an assigned reviewer label Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Remote-Exec Issues and PRs for the Execution (Remote) team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants