From fb31fc49787d5df2d84d099929838389de7d276b Mon Sep 17 00:00:00 2001 From: Sitnikov Ivan Date: Thu, 14 Nov 2024 15:53:51 +0500 Subject: [PATCH] hotfix(keystone): send queue metrics from worker process only (#5482) * hotfix(keystone): send queue metrics from worker process only * hotfix(address-service): add migration after kmigrator module changes * hotfix(condorb): add missing migration * hotfix(dev-api): add missing migration * hotfix(condorb): add missing migration --- ...sshistoryrecord_history_action_and_more.js | 42 ++++++++++ apps/condorb | 2 +- ..._b2cappaccessright_environment_and_more.js | 78 +++++++++++++++++++ .../keystone/KSv5v6/v5/prepareKeystone.js | 2 +- 4 files changed, 122 insertions(+), 2 deletions(-) create mode 100644 apps/address-service/migrations/20241114120757-0004_alter_addresshistoryrecord_history_action_and_more.js create mode 100644 apps/dev-api/migrations/20241114121446-0005_alter_b2cappaccessright_environment_and_more.js diff --git a/apps/address-service/migrations/20241114120757-0004_alter_addresshistoryrecord_history_action_and_more.js b/apps/address-service/migrations/20241114120757-0004_alter_addresshistoryrecord_history_action_and_more.js new file mode 100644 index 00000000000..2b593024b71 --- /dev/null +++ b/apps/address-service/migrations/20241114120757-0004_alter_addresshistoryrecord_history_action_and_more.js @@ -0,0 +1,42 @@ +// auto generated by kmigrator +// KMIGRATOR:0004_alter_addresshistoryrecord_history_action_and_more:IyBHZW5lcmF0ZWQgYnkgRGphbmdvIDQuMCBvbiAyMDI0LTExLTE0IDA3OjA3Cgpmcm9tIGRqYW5nby5kYiBpbXBvcnQgbWlncmF0aW9ucywgbW9kZWxzCgoKY2xhc3MgTWlncmF0aW9uKG1pZ3JhdGlvbnMuTWlncmF0aW9uKToKCiAgICBkZXBlbmRlbmNpZXMgPSBbCiAgICAgICAgKCdfZGphbmdvX3NjaGVtYScsICcwMDAzX2FkZHJlc3Nfb3ZlcnJpZGVzX2FkZHJlc3NoaXN0b3J5cmVjb3JkX292ZXJyaWRlcycpLAogICAgXQoKICAgIG9wZXJhdGlvbnMgPSBbCiAgICAgICAgbWlncmF0aW9ucy5BbHRlckZpZWxkKAogICAgICAgICAgICBtb2RlbF9uYW1lPSdhZGRyZXNzaGlzdG9yeXJlY29yZCcsCiAgICAgICAgICAgIG5hbWU9J2hpc3RvcnlfYWN0aW9uJywKICAgICAgICAgICAgZmllbGQ9bW9kZWxzLkNoYXJGaWVsZChtYXhfbGVuZ3RoPTUwKSwKICAgICAgICApLAogICAgICAgIG1pZ3JhdGlvbnMuQWx0ZXJGaWVsZCgKICAgICAgICAgICAgbW9kZWxfbmFtZT0nYWRkcmVzc2luamVjdGlvbmhpc3RvcnlyZWNvcmQnLAogICAgICAgICAgICBuYW1lPSdoaXN0b3J5X2FjdGlvbicsCiAgICAgICAgICAgIGZpZWxkPW1vZGVscy5DaGFyRmllbGQobWF4X2xlbmd0aD01MCksCiAgICAgICAgKSwKICAgICAgICBtaWdyYXRpb25zLkFsdGVyRmllbGQoCiAgICAgICAgICAgIG1vZGVsX25hbWU9J2FkZHJlc3Nzb3VyY2VoaXN0b3J5cmVjb3JkJywKICAgICAgICAgICAgbmFtZT0naGlzdG9yeV9hY3Rpb24nLAogICAgICAgICAgICBmaWVsZD1tb2RlbHMuQ2hhckZpZWxkKG1heF9sZW5ndGg9NTApLAogICAgICAgICksCiAgICAgICAgbWlncmF0aW9ucy5BbHRlckZpZWxkKAogICAgICAgICAgICBtb2RlbF9uYW1lPSd1c2VyaGlzdG9yeXJlY29yZCcsCiAgICAgICAgICAgIG5hbWU9J2hpc3RvcnlfYWN0aW9uJywKICAgICAgICAgICAgZmllbGQ9bW9kZWxzLkNoYXJGaWVsZChtYXhfbGVuZ3RoPTUwKSwKICAgICAgICApLAogICAgXQo= + +exports.up = async (knex) => { + await knex.raw(` + BEGIN; +-- +-- Alter field history_action on addresshistoryrecord +-- +-- +-- Alter field history_action on addressinjectionhistoryrecord +-- +-- +-- Alter field history_action on addresssourcehistoryrecord +-- +-- +-- Alter field history_action on userhistoryrecord +-- +COMMIT; + + `) +} + +exports.down = async (knex) => { + await knex.raw(` + BEGIN; +-- +-- Alter field history_action on userhistoryrecord +-- +-- +-- Alter field history_action on addresssourcehistoryrecord +-- +-- +-- Alter field history_action on addressinjectionhistoryrecord +-- +-- +-- Alter field history_action on addresshistoryrecord +-- +COMMIT; + + `) +} diff --git a/apps/condorb b/apps/condorb index 84f9c6576d9..f3fda084191 160000 --- a/apps/condorb +++ b/apps/condorb @@ -1 +1 @@ -Subproject commit 84f9c6576d9373957faf414dd3f8b87f154f9046 +Subproject commit f3fda084191ae1afa7635681aa9090731fa0feea diff --git a/apps/dev-api/migrations/20241114121446-0005_alter_b2cappaccessright_environment_and_more.js b/apps/dev-api/migrations/20241114121446-0005_alter_b2cappaccessright_environment_and_more.js new file mode 100644 index 00000000000..fc00496196a --- /dev/null +++ b/apps/dev-api/migrations/20241114121446-0005_alter_b2cappaccessright_environment_and_more.js @@ -0,0 +1,78 @@ +// auto generated by kmigrator +// KMIGRATOR:0005_alter_b2cappaccessright_environment_and_more:IyBHZW5lcmF0ZWQgYnkgRGphbmdvIDQuMCBvbiAyMDI0LTExLTE0IDA3OjE0Cgpmcm9tIGRqYW5nby5kYiBpbXBvcnQgbWlncmF0aW9ucywgbW9kZWxzCgoKY2xhc3MgTWlncmF0aW9uKG1pZ3JhdGlvbnMuTWlncmF0aW9uKToKCiAgICBkZXBlbmRlbmNpZXMgPSBbCiAgICAgICAgKCdfZGphbmdvX3NjaGVtYScsICcwMDA0X3JlbW92ZV9iMmNhcHBhY2Nlc3NyaWdodGhpc3RvcnlyZWNvcmRfY29uZG91c2VyZW1haWwnKSwKICAgIF0KCiAgICBvcGVyYXRpb25zID0gWwogICAgICAgIG1pZ3JhdGlvbnMuQWx0ZXJGaWVsZCgKICAgICAgICAgICAgbW9kZWxfbmFtZT0nYjJjYXBwYWNjZXNzcmlnaHQnLAogICAgICAgICAgICBuYW1lPSdlbnZpcm9ubWVudCcsCiAgICAgICAgICAgIGZpZWxkPW1vZGVscy5DaGFyRmllbGQobWF4X2xlbmd0aD01MCksCiAgICAgICAgKSwKICAgICAgICBtaWdyYXRpb25zLkFsdGVyRmllbGQoCiAgICAgICAgICAgIG1vZGVsX25hbWU9J2IyY2FwcGFjY2Vzc3JpZ2h0aGlzdG9yeXJlY29yZCcsCiAgICAgICAgICAgIG5hbWU9J2hpc3RvcnlfYWN0aW9uJywKICAgICAgICAgICAgZmllbGQ9bW9kZWxzLkNoYXJGaWVsZChtYXhfbGVuZ3RoPTUwKSwKICAgICAgICApLAogICAgICAgIG1pZ3JhdGlvbnMuQWx0ZXJGaWVsZCgKICAgICAgICAgICAgbW9kZWxfbmFtZT0nYjJjYXBwYnVpbGRoaXN0b3J5cmVjb3JkJywKICAgICAgICAgICAgbmFtZT0naGlzdG9yeV9hY3Rpb24nLAogICAgICAgICAgICBmaWVsZD1tb2RlbHMuQ2hhckZpZWxkKG1heF9sZW5ndGg9NTApLAogICAgICAgICksCiAgICAgICAgbWlncmF0aW9ucy5BbHRlckZpZWxkKAogICAgICAgICAgICBtb2RlbF9uYW1lPSdiMmNhcHBoaXN0b3J5cmVjb3JkJywKICAgICAgICAgICAgbmFtZT0naGlzdG9yeV9hY3Rpb24nLAogICAgICAgICAgICBmaWVsZD1tb2RlbHMuQ2hhckZpZWxkKG1heF9sZW5ndGg9NTApLAogICAgICAgICksCiAgICAgICAgbWlncmF0aW9ucy5BbHRlckZpZWxkKAogICAgICAgICAgICBtb2RlbF9uYW1lPSdiMmNhcHBwdWJsaXNocmVxdWVzdGhpc3RvcnlyZWNvcmQnLAogICAgICAgICAgICBuYW1lPSdoaXN0b3J5X2FjdGlvbicsCiAgICAgICAgICAgIGZpZWxkPW1vZGVscy5DaGFyRmllbGQobWF4X2xlbmd0aD01MCksCiAgICAgICAgKSwKICAgICAgICBtaWdyYXRpb25zLkFsdGVyRmllbGQoCiAgICAgICAgICAgIG1vZGVsX25hbWU9J2NvbmZpcm1lbWFpbGFjdGlvbmhpc3RvcnlyZWNvcmQnLAogICAgICAgICAgICBuYW1lPSdoaXN0b3J5X2FjdGlvbicsCiAgICAgICAgICAgIGZpZWxkPW1vZGVscy5DaGFyRmllbGQobWF4X2xlbmd0aD01MCksCiAgICAgICAgKSwKICAgICAgICBtaWdyYXRpb25zLkFsdGVyRmllbGQoCiAgICAgICAgICAgIG1vZGVsX25hbWU9J2NvbmZpcm1waG9uZWFjdGlvbmhpc3RvcnlyZWNvcmQnLAogICAgICAgICAgICBuYW1lPSdoaXN0b3J5X2FjdGlvbicsCiAgICAgICAgICAgIGZpZWxkPW1vZGVscy5DaGFyRmllbGQobWF4X2xlbmd0aD01MCksCiAgICAgICAgKSwKICAgICAgICBtaWdyYXRpb25zLkFsdGVyRmllbGQoCiAgICAgICAgICAgIG1vZGVsX25hbWU9J3VzZXJoaXN0b3J5cmVjb3JkJywKICAgICAgICAgICAgbmFtZT0naGlzdG9yeV9hY3Rpb24nLAogICAgICAgICAgICBmaWVsZD1tb2RlbHMuQ2hhckZpZWxkKG1heF9sZW5ndGg9NTApLAogICAgICAgICksCiAgICAgICAgbWlncmF0aW9ucy5BbHRlckZpZWxkKAogICAgICAgICAgICBtb2RlbF9uYW1lPSd3ZWJob29raGlzdG9yeXJlY29yZCcsCiAgICAgICAgICAgIG5hbWU9J2hpc3RvcnlfYWN0aW9uJywKICAgICAgICAgICAgZmllbGQ9bW9kZWxzLkNoYXJGaWVsZChtYXhfbGVuZ3RoPTUwKSwKICAgICAgICApLAogICAgICAgIG1pZ3JhdGlvbnMuQWx0ZXJGaWVsZCgKICAgICAgICAgICAgbW9kZWxfbmFtZT0nd2ViaG9va3N1YnNjcmlwdGlvbmhpc3RvcnlyZWNvcmQnLAogICAgICAgICAgICBuYW1lPSdoaXN0b3J5X2FjdGlvbicsCiAgICAgICAgICAgIGZpZWxkPW1vZGVscy5DaGFyRmllbGQobWF4X2xlbmd0aD01MCksCiAgICAgICAgKSwKICAgIF0K + +exports.up = async (knex) => { + await knex.raw(` + BEGIN; +-- +-- Alter field environment on b2cappaccessright +-- +-- +-- Alter field history_action on b2cappaccessrighthistoryrecord +-- +-- +-- Alter field history_action on b2cappbuildhistoryrecord +-- +-- +-- Alter field history_action on b2capphistoryrecord +-- +-- +-- Alter field history_action on b2capppublishrequesthistoryrecord +-- +-- +-- Alter field history_action on confirmemailactionhistoryrecord +-- +-- +-- Alter field history_action on confirmphoneactionhistoryrecord +-- +-- +-- Alter field history_action on userhistoryrecord +-- +-- +-- Alter field history_action on webhookhistoryrecord +-- +-- +-- Alter field history_action on webhooksubscriptionhistoryrecord +-- +COMMIT; + + `) +} + +exports.down = async (knex) => { + await knex.raw(` + BEGIN; +-- +-- Alter field history_action on webhooksubscriptionhistoryrecord +-- +-- +-- Alter field history_action on webhookhistoryrecord +-- +-- +-- Alter field history_action on userhistoryrecord +-- +-- +-- Alter field history_action on confirmphoneactionhistoryrecord +-- +-- +-- Alter field history_action on confirmemailactionhistoryrecord +-- +-- +-- Alter field history_action on b2capppublishrequesthistoryrecord +-- +-- +-- Alter field history_action on b2capphistoryrecord +-- +-- +-- Alter field history_action on b2cappbuildhistoryrecord +-- +-- +-- Alter field history_action on b2cappaccessrighthistoryrecord +-- +-- +-- Alter field environment on b2cappaccessright +-- +COMMIT; + + `) +} diff --git a/packages/keystone/KSv5v6/v5/prepareKeystone.js b/packages/keystone/KSv5v6/v5/prepareKeystone.js index e3ca76e5557..179361cc254 100644 --- a/packages/keystone/KSv5v6/v5/prepareKeystone.js +++ b/packages/keystone/KSv5v6/v5/prepareKeystone.js @@ -66,7 +66,7 @@ const sendAppMetrics = () => { metrics.gauge({ name: 'processMemoryUsage.rss', value: memUsage.rss }) metrics.gauge({ name: 'processMemoryUsage.external', value: memUsage.external }) - if (taskQueues.size > 0) { + if (IS_WORKER_PROCESS && taskQueues.size > 0) { Array.from(taskQueues.entries()).forEach(([queueName, queue]) => { queue.getJobCounts().then(jobCounts => { metrics.gauge({ name: `worker.${queueName}.activeTasks`, value: jobCounts.active })