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

Scheduler not working when the CSV update #79

Open
ralfyang opened this issue Aug 20, 2021 · 1 comment
Open

Scheduler not working when the CSV update #79

ralfyang opened this issue Aug 20, 2021 · 1 comment

Comments

@ralfyang
Copy link
Contributor

Scheduler has some problem(not working) after the CSV file has been updated in the exporterhub.io

@bart2001
Copy link
Contributor

bart2001 commented Sep 3, 2021

I have tested scheduler job create_or_update_exporters on csv file change by setting it to run every minute and it seems working well.

Steps to Reproduce

  1. set create_or_update_exporters to run every minute in api/hub/management/commands/scheduler.py
def listener(event):
    if not event.exception:
        if scheduler.get_job('check_token'):
            job = scheduler.get_job('check_token')
       
            if job.func() == 'VALID_TOKEN':
                scheduler.remove_job('check_token')
                logger.info('Remove check_token job.')

                scheduler.add_job(
                    create_or_update_exporters,
                    #trigger            = CronTrigger(hour='*/4'),
                    trigger            = CronTrigger(minute='*'),
                    id                 = 'create_or_update_exporters',
                    max_instances      = 1,
                    replace_existing   = True,
                    coalesce           = True,
                    misfire_grace_time = 900,
                    next_run_time      = datetime.now()
                )
                logger.info("Added job 'create_or_update_exporters'.")
  1. Run all containers
make build && make run
  1. (other terminal) check logs from scheduler container
docker-compose logs -f scheduler
# create_or_update_exporters job is running every hour
scheduler_1   | CHECK_EXPORTERS_DONE
scheduler_1   | CHECK_EXPORTERS_START
scheduler_1   | CHECK_EXPORTERS_DONE
scheduler_1   | CHECK_EXPORTERS_START
  1. SSH into docker scheduler container and append new exporter in /data/exporter_list.csv
docker-compose exec scheduler /bin/bash
root@032832075fb2:/data# echo "Traefik Exporter,traefik-exporter,https://github.com/iadvize/traefik-exporter,0,HTTP" >> /data/exporter_list.csv
  1. Check logs from scheduler container and see if new exporter is added to the database
# ...
scheduler_1   | CHECK_EXPORTERS_START
scheduler_1   | CHECK_EXPORTERS_DONE
scheduler_1   | CHECK_EXPORTERS_START
scheduler_1   | id: 42 name: traefik-exporter | SUCCESSFULLY_ADDED_REPOSITORY_AND_RELEASES | 2021-09-04 00:22:57.102681
scheduler_1   | CHECK_EXPORTERS_DONE
scheduler_1   | CHECK_EXPORTERS_START
scheduler_1   | CHECK_EXPORTERS_DONE
# ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants