Skip to content

[credentialhelper] Implement invoking credential helper as subprocess#15861

Closed
Yannic wants to merge 2 commits intobazelbuild:masterfrom
EngFlow:credhelper-call-subprocess
Closed

[credentialhelper] Implement invoking credential helper as subprocess#15861
Yannic wants to merge 2 commits intobazelbuild:masterfrom
EngFlow:credhelper-call-subprocess

Conversation

@Yannic
Copy link
Copy Markdown
Contributor

@Yannic Yannic commented Jul 11, 2022

@Yannic
Copy link
Copy Markdown
Contributor Author

Yannic commented Jul 11, 2022

@tjgq PTAL

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

process.waitFor();
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

Yannic commented Jul 14, 2022

PTAL

@Yannic
Copy link
Copy Markdown
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
Copy Markdown
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 added a commit that referenced this pull request Jul 18, 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