]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: allow passing custom prometheus alerts to bootstrap 57184/head
authorAdam King <adking@redhat.com>
Tue, 26 Mar 2024 19:10:31 +0000 (15:10 -0400)
committerAdam King <adking@redhat.com>
Wed, 29 May 2024 15:22:55 +0000 (11:22 -0400)
This can't be done with the --config flag as the thing
that needs to be changed is in the config-key store rather
than being a config option. I don't think we have any
option other than a new flag here. Makes use of the
`ceph orch prometheus set-custom-alerts` command being
added in another commit

Signed-off-by: Adam King <adking@redhat.com>
(cherry picked from commit e4883a30f37b6331359b6aa2d9e8bbe161106388)

src/cephadm/cephadm.py

index 0a8292c5f00bc7c3828143e1c8999e023d0f9fda..3cab1644f1883025cbe0176580b53cae8437a43d 100755 (executable)
@@ -2776,6 +2776,11 @@ def command_bootstrap(ctx):
             except PermissionError:
                 raise Error(f'Unable to create {dirname} due to permissions failure. Retry with root, or sudo or preallocate the directory.')
 
+    if getattr(ctx, 'custom_prometheus_alerts', None):
+        ctx.custom_prometheus_alerts = os.path.abspath(ctx.custom_prometheus_alerts)
+        if not os.path.isfile(ctx.custom_prometheus_alerts):
+            raise Error(f'No custom prometheus alerts file found at {ctx.custom_prometheus_alerts}')
+
     (user_conf, _) = get_config_and_keyring(ctx)
 
     if ctx.ssh_user != 'root':
@@ -2848,6 +2853,8 @@ def command_bootstrap(ctx):
             admin_keyring.name: '/etc/ceph/ceph.client.admin.keyring:z',
             tmp_config.name: '/etc/ceph/ceph.conf:z',
         }
+        if getattr(ctx, 'custom_prometheus_alerts', None):
+            mounts[ctx.custom_prometheus_alerts] = '/etc/ceph/custom_alerts.yml:z'
         for k, v in extra_mounts.items():
             mounts[k] = v
         timeout = timeout or ctx.timeout
@@ -2992,6 +2999,9 @@ def command_bootstrap(ctx):
     if getattr(ctx, 'deploy_cephadm_agent', None):
         cli(['config', 'set', 'mgr', 'mgr/cephadm/use_agent', 'true'])
 
+    if getattr(ctx, 'custom_prometheus_alerts', None):
+        cli(['orch', 'prometheus', 'set-custom-alerts', '-i', '/etc/ceph/custom_alerts.yml'])
+
     return ctx.error_code
 
 ##################################
@@ -5394,6 +5404,9 @@ def _get_parser():
         '--deploy-cephadm-agent',
         action='store_true',
         help='deploy the cephadm-agent')
+    parser_bootstrap.add_argument(
+        '--custom-prometheus-alerts',
+        help='provide a file with custom prometheus alerts')
 
     parser_deploy = subparsers.add_parser(
         'deploy', help='deploy a daemon')