Skip to content

Commit

Permalink
INF-302 Expose auto upgrading flag (#4336)
Browse files Browse the repository at this point in the history
* Add autoUpgradeEnabled bool to /health_check

IMPORTANT this does not work in a container as crontabs are at the hypervisor level

* Return presence of auto upgrade cron on host in /health_check

* Lint and test fixes

* Address PR comments

Co-authored-by: endline <endline>
  • Loading branch information
endline committed Nov 21, 2022
1 parent e25edea commit bda4782
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ const healthCheck = async (
const clusterWorkersCount = clusterUtils.getNumWorkers()

const healthy = !config.get('considerNodeUnhealthy')
const databaseIsLocalhost =
config.get('dbUrl') ===
'postgres://postgres:postgres@db:5432/audius_creator_node' ||
config.get('dbUrl').includes('localhost')

const response = {
...versionInfo,
Expand All @@ -146,6 +150,7 @@ const healthCheck = async (
isRegisteredOnURSM: config.get('isRegisteredOnURSM'),
dataProviderUrl: config.get('dataProviderUrl'),
audiusContentInfraSetup,
autoUpgradeEnabled: config.get('autoUpgradeEnabled'),
numberOfCPUs,
totalMemory,
storagePathSize,
Expand All @@ -154,6 +159,7 @@ const healthCheck = async (
longitude,
databaseConnections,
databaseSize,
databaseIsLocalhost: databaseIsLocalhost,
usedMemory,
usedTCPMemory,
storagePathUsed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,12 @@ describe('Test Health Check', function () {
isRegisteredOnURSM: false,
dataProviderUrl: config.get('dataProviderUrl'),
audiusContentInfraSetup: '',
autoUpgradeEnabled: false,
country: 'US',
latitude: '37.7749',
longitude: '-122.4194',
databaseConnections: 5,
databaseIsLocalhost: true,
databaseSize: 1102901,
totalMemory: 6237151232,
usedMemory: 5969739776,
Expand Down Expand Up @@ -307,10 +309,12 @@ describe('Test Health Check', function () {
isRegisteredOnURSM: false,
dataProviderUrl: config.get('dataProviderUrl'),
audiusContentInfraSetup: '',
autoUpgradeEnabled: false,
country: 'US',
latitude: '37.7749',
longitude: '-122.4194',
databaseConnections: 5,
databaseIsLocalhost: true,
databaseSize: 1102901,
totalMemory: 6237151232,
usedMemory: 5969739776,
Expand Down Expand Up @@ -412,10 +416,12 @@ describe('Test Health Check', function () {
isRegisteredOnURSM: false,
dataProviderUrl: config.get('dataProviderUrl'),
audiusContentInfraSetup: '',
autoUpgradeEnabled: false,
country: 'US',
latitude: '37.7749',
longitude: '-122.4194',
databaseConnections: 5,
databaseIsLocalhost: true,
databaseSize: 1102901,
totalMemory: 6237151232,
usedMemory: 5969739776,
Expand Down Expand Up @@ -560,10 +566,12 @@ describe('Test Health Check Verbose', function () {
isRegisteredOnURSM: false,
dataProviderUrl: config.get('dataProviderUrl'),
audiusContentInfraSetup: '',
autoUpgradeEnabled: false,
country: 'US',
latitude: '37.7749',
longitude: '-122.4194',
databaseConnections: 5,
databaseIsLocalhost: true,
databaseSize: 1102901,
totalMemory: 6237151232,
usedMemory: 5969739776,
Expand Down
6 changes: 6 additions & 0 deletions creator-node/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,12 @@ const config = convict({
env: 'syncOverridePassword',
default: '',
sensitive: true
},
autoUpgradeEnabled: {
doc: 'Is the audius-cli cron job for auto upgrade enabled on the host machine.',
format: Boolean,
env: 'autoUpgradeEnabled',
default: false
}
})

Expand Down
11 changes: 11 additions & 0 deletions discovery-provider/src/queries/get_health.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,15 @@ def get_health(args: GetHealthArgs, use_redis_cache: bool = True) -> Tuple[Dict,
url = shared_config["discprov"]["url"]
final_poa_block = helpers.get_final_poa_block(shared_config)

auto_upgrade_enabled = (
True if os.getenv("audius_auto_upgrade_enabled") == "true" else False
)
database_is_localhost = os.getenv(
"audius_db_url"
) == "postgresql://postgres:postgres@db:5432/audius_discovery" or "localhost" in os.getenv(
"audius_db_url", ""
)

health_results = {
"web": {
"blocknumber": latest_block_num,
Expand All @@ -324,6 +333,8 @@ def get_health(args: GetHealthArgs, use_redis_cache: bool = True) -> Tuple[Dict,
"blockhash": latest_indexed_block_hash,
},
"git": os.getenv("GIT_SHA"),
"auto_upgrade_enabled": auto_upgrade_enabled,
"database_is_localhost": database_is_localhost,
"trending_tracks_age_sec": trending_tracks_age_sec,
"trending_playlists_age_sec": trending_playlists_age_sec,
"challenge_last_event_age_sec": challenge_events_age_sec,
Expand Down

0 comments on commit bda4782

Please sign in to comment.