eclipse-volttron / volttron-lib-base-historian

Other
0 stars 4 forks source link

Historians should create a default config file when launched without one. #15

Open davidraker opened 7 months ago

davidraker commented 7 months ago

When historians in modular are first installed, they do not have a valid configuration file by default. This causes the agent to die with an exception on startup. Because we are distributing the agent without source code, though, there is no place for the user to easily retrieve a configuration file without searching the documentation. While current users are accustomed to finding configuration files in the repository, we should not assume that users who first encounter VOLTTRON on Pypi will know where to look.

Since with modular, different historians have more specific agents associated with them (volttron-sqlite-historian, for instance), it should be possible to create a default configuration and place it in the configuration store on startup. For some, like the sqlite historian, this will probably just work. For more complicated databases, it will likely still need to be edited. In this case, though, the sane behavior would probably be to log an error asking the user to update the configuration before shutting down gracefully.

Describe the solution you'd like

Scenario 1 (sqlite):

  1. User installs sqlite historian with "vctl install volttron-sqlite-historian".
  2. User starts agent without adding a configuration file.
  3. Agent detects that there is not a configuration file present.
  4. Agent adds a default configuration to the configuration store and starts.

Scenario 2 (PostgreSQL):

  1. User installs postgres historian with "vctl install volttron-postgresql-historian".
  2. User starts agent without adding a configuration file.
  3. Agent detects that there is not a configuration file present.
  4. Agent adds a default configuration store and stops with error: "PostgreSQL historian must be configured before starting. Please edit the "config" file in the configuration store and then restart the agent."

Describe alternatives you've considered

Additional context We should keep in mind that if we automatically create a configuration and then start, that we should probably be cautious of overwriting or adding to an existing database. It would be straightforward to either check if the database uses the same vip-identity in the name or generate a different name if the default one is taken.

craig8 commented 7 months ago

This is only true if you don't pass an --agent-config as argument to the install path. Which I believe is how the agent should be installed in the first place. We don't require an --agent-config but it is definitely a recommended practice and should be documented as such in the readme.