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

add generator commit hash to node metadata #53

Merged
merged 8 commits into from
Jan 18, 2024

Conversation

arvindbr8
Copy link
Member

@arvindbr8 arvindbr8 commented Jan 17, 2024

For some of the features in flight, it would be nice to determine the version of the generator used by looking at the Node metadata that is being passed to TD. This change add a new value to Node.Metadata keyed with TRAFFICDIRECTOR_GRPC_BOOTSTRAP_GENERATOR_SHA and is plumbed the git commit ID at HEAD.

main.go Outdated Show resolved Hide resolved
@arvindbr8 arvindbr8 marked this pull request as ready for review January 17, 2024 22:40
Copy link
Collaborator

@ejona86 ejona86 left a comment

Choose a reason for hiding this comment

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

I'm not wild about requiring the vcs information, but that is easy enough to change in the future.

main_test.go Outdated
func TestCommitShaIdInNodeMetadata(t *testing.T) {

// Build td-grpc-bootstrap binary.
cmd := exec.Command("go", "build", ".")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, gosh, no. This is asking to be super confusing. Nobody expects a test to run go build.

Strictly better would be to run the tests with -buildvcs=true and call getGitCommitId(). Then just make sure it isn't an error and it looks like a SHA.

Copy link
Member Author

Choose a reason for hiding this comment

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

:') I see your point. Updating this in the next rev.

We discussed something similar a while ago about how to get test the generator for its default behavior with flags. One of the testing methods you suggested was to do something similar to running go build and executing the binary. I was thinking all of our tests should look like this.

Not for this change tho:
Do you think maybe adding a build and generate test to the github workflow might be worth it? And compare that to a golden file?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think I suggested go build. I might have suggested running the test binary though, like done in Go's CGI tests.

@arvindbr8 arvindbr8 assigned arvindbr8 and unassigned ejona86 Jan 18, 2024
@arvindbr8 arvindbr8 assigned ejona86 and unassigned arvindbr8 Jan 18, 2024
main_test.go Outdated

re := regexp.MustCompile(`^[a-f0-9]{40}$`)
if !re.MatchString(commitId) {
t.Fatal("getGitCommitId(): returned an invalid commit ID. Want commit ID to be a valid SHA1 hash.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Include the commitId in the message?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@arvindbr8 arvindbr8 merged commit 596c3a3 into GoogleCloudPlatform:master Jan 18, 2024
2 checks passed
@arvindbr8 arvindbr8 added the enhancement New feature or request label Jan 18, 2024
@arvindbr8 arvindbr8 deleted the version branch January 18, 2024 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants