Moving mutable configuration to the database

February 20, 2019 by @devth

It's time to move mutable config to the database in adherence with immutable infrastructure practices. Yetibot embraces modern infrastructure. We made a lot of progress moving to mostly-immutable configuration. This is the next step, and is done as of Yetibot 0.5.0.

One reason why we haven't done this up till now is that mutable config has never been relied upon much. Its purpose was to:

  1. Store channel-specific configuration (e.g. jira-project, broadcast, jenkins-default or any other arbitrary room-specific key/value) for the channel command
  2. Store channel-specific disabled categories for the category command
  3. Remember which channels Yetibot should join upon connecting to IRC

Previously these values would be persisted to a local edn file which by default lives at config/mutable.edn. However, in modern cloud environments this is not durable. For example when running Yetibot on Kubernetes this would be lost on each pod creation (unless a durable disk was mounted, but that's an unnecessary complication). We already have a durable place to store keys and values: the Postgres database.

All of these use cases will now move to a single yetibot_channels table.

What does this mean for me?

Given that mutable config hasn't been heavily used the migration should be quite painless. We are not providing an automated migration tool, so your options are:

  1. Do nothing if you're not using any mutable config yet (quite likely) 😅
  2. Use Yetibot to recreate the config, e.g. channel set jia-project myjira
  3. Look in config/mutable.edn and manually copy the key/values and chat source rooms to the yetibot_channels Postgres table. For example, if your mutable.edn looks like:
   {:room
    {:ybslack
     {"#general" {:disabled-categories #{:crude}},
      "#dev" {"jira-project" "YETIBOT",
              "nope" "lol",
              :disabled-categories #{:crude}}}}}
   

You would create rows in yetibot_channels:

chat_source_adapter chat_source_room key value
:ybslack #general disabled-categories #{:crude}
:ybslack #dev jira-project YETIBOT
:ybslack #dev nope lol
:ybslack #dev disabled-categories #{:crude}

All values in the table are strings.

If you use IRC, your channels to join config will be lost as well. Simply re-invite Yetibot to the proper channels and they will be stored in the database.

Here's the Pull Request that made these changes.

config news 2019