Page MenuHomePhabricator

[services] Blob/Backup - Read env vars in runtime instead of compile-time flags
ClosedPublic

Authored by karol on Apr 28 2022, 2:34 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Nov 14, 9:06 AM
Unknown Object (File)
Wed, Nov 13, 10:47 AM
Unknown Object (File)
Tue, Nov 12, 10:50 PM
Unknown Object (File)
Tue, Nov 12, 10:31 PM
Unknown Object (File)
Tue, Nov 12, 9:35 PM
Unknown Object (File)
Tue, Nov 12, 7:25 PM
Unknown Object (File)
Tue, Nov 12, 7:07 PM
Unknown Object (File)
Tue, Nov 12, 6:11 PM

Details

Summary

Depends on D3691

As suggested in https://phabricator.ashoat.com/D3498#98870 we want to avoid using compile-time flags and replace them with reading environment variables in the runtime.

Test Plan
cd services
yarn test-backup-service
yarn test-backup-service-dev-mode
yarn run-backup-service
yarn run-backup-service-dev-mode
yarn test-blob-service
yarn test-blob-service-dev-mode
yarn run-blob-service
yarn run-blob-service-dev-mode

They all should work as before.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

karol edited the test plan for this revision. (Show Details)
karol added reviewers: tomek, jim.
services/backup/src/AwsTools.cpp
12–14 ↗(On Diff #12033)

Here too

services/backup/src/Tools.cpp
29–31 ↗(On Diff #12033)

This looks really messy... can we pull the ternary out of the conditional to make it cleaner?

services/blob/src/Tools.cpp
79–80 ↗(On Diff #12033)

Here too

tomek requested changes to this revision.Apr 29 2022, 5:51 AM
tomek added inline comments.
services/backup/src/Tools.cpp
29–31 ↗(On Diff #12033)

Yeah, this seems to be overly complicated. What do you think about something like this.

Also, creating a function that returns a bool would be really useful.

This revision now requires changes to proceed.Apr 29 2022, 5:51 AM
services/backup/src/Tools.cpp
29–31 ↗(On Diff #12033)

I think a helper function is a way to go here!

karol edited the summary of this revision. (Show Details)

add helper function isDevMode()

Please use the new function in decorateTableName functions before landing

services/backup/src/Tools.cpp
29–31 ↗(On Diff #12118)
services/blob/src/Tools.cpp
78–80 ↗(On Diff #12118)
This revision is now accepted and ready to land.Apr 29 2022, 7:59 AM
services/backup/src/Tools.cpp
29–31 ↗(On Diff #12118)

isDevMode checks against COMM_SERVICES_DEV_MODE, here we have COMM_TEST_SERVICES. These are 2 different flags.

We could create a similar function isTesting but std::getenv("COMM_TEST_SERVICES") is really used only in one place so there's no point I guess.

services/blob/src/Tools.cpp
78–80 ↗(On Diff #12118)

as above

services/backup/src/Tools.cpp
29–31 ↗(On Diff #12118)

Please do not land this diff with this messy ternary inside a conditional. It is very difficult to read

services/backup/src/Tools.cpp
29–31 ↗(On Diff #12118)

We've landed this, but one possible option here was to introduce a new function e.g. hasEnvFlag that would contain the if with two conditions and could be used here and in isDevMode function.

This is true, we can have hasEnvFlag. Creating a follow up as this is landed already https://linear.app/comm/issue/ENG-1104/consider-creating-hasenvflag-function