blakeblackshear / blakeshome-charts

Repo for helm charts
46 stars 61 forks source link

Doesnt work with frigate 0.14.0 #69

Open potchin opened 5 months ago

potchin commented 5 months ago

It looks as though having the frigate config.yml stored inside a configmap causes a problem for frigate 0.14.0-beta1 since it tries to make changes to the config file. This fails since its readonly..

2024-05-25T20:22:17.380638849+01:00 2024-05-25 19:22:17.380577333  [2024-05-25 19:22:17] frigate.util.config            INFO    : Checking if frigate config needs migration...
2024-05-25T20:22:17.380707349+01:00 2024-05-25 19:22:17.380667550  [2024-05-25 19:22:17] frigate.util.config            INFO    : copying config as backup...
2024-05-25T20:22:17.410153416+01:00 2024-05-25 19:22:17.410004617  *************************************************************
2024-05-25T20:22:17.410175446+01:00 2024-05-25 19:22:17.410018071  *************************************************************
2024-05-25T20:22:17.410180980+01:00 2024-05-25 19:22:17.410022344  ***    Your config file is not valid!                     ***
2024-05-25T20:22:17.410184687+01:00 2024-05-25 19:22:17.410024262  ***    Please check the docs at                           ***
2024-05-25T20:22:17.410187752+01:00 2024-05-25 19:22:17.410025687  ***    https://docs.frigate.video/configuration/index     ***
2024-05-25T20:22:17.410190580+01:00 2024-05-25 19:22:17.410049073  *************************************************************
2024-05-25T20:22:17.410193046+01:00 2024-05-25 19:22:17.410107658  *************************************************************
2024-05-25T20:22:17.410196222+01:00 2024-05-25 19:22:17.410109785  ***    Config Validation Errors                           ***
2024-05-25T20:22:17.410198890+01:00 2024-05-25 19:22:17.410111387  *************************************************************
2024-05-25T20:22:17.410211920+01:00 2024-05-25 19:22:17.410124420  [Errno 30] Read-only file system: '/config/config.yml'
2024-05-25T20:22:17.410662979+01:00 2024-05-25 19:22:17.410290075  [2024-05-25 19:22:17] frigate.util.config            INFO    : Migrating frigate config from 0.13 to 0.14...
2024-05-25T20:22:17.410869788+01:00 2024-05-25 19:22:17.410820697  Traceback (most recent call last):
2024-05-25T20:22:17.410878941+01:00 2024-05-25 19:22:17.410822739    File "/opt/frigate/frigate/app.py", line 644, in start
2024-05-25T20:22:17.410882248+01:00 2024-05-25 19:22:17.410823774      self.init_config()
2024-05-25T20:22:17.410884860+01:00 2024-05-25 19:22:17.410824945    File "/opt/frigate/frigate/app.py", line 137, in init_config
2024-05-25T20:22:17.410887340+01:00 2024-05-25 19:22:17.410825990      migrate_frigate_config(config_file)
2024-05-25T20:22:17.410889892+01:00 2024-05-25 19:22:17.410827221    File "/opt/frigate/frigate/util/config.py", line 46, in migrate_frigate_config
2024-05-25T20:22:17.410892350+01:00 2024-05-25 19:22:17.410828291      with open(config_file, "w") as f:
2024-05-25T20:22:17.410894749+01:00 2024-05-25 19:22:17.410829405  OSError: [Errno 30] Read-only file system: '/config/config.yml'
2024-05-25T20:22:17.410897380+01:00 2024-05-25 19:22:17.410831953  
2024-05-25T20:22:17.410899985+01:00 2024-05-25 19:22:17.410833096  *************************************************************
2024-05-25T20:22:17.410902425+01:00 2024-05-25 19:22:17.410842147  ***    End Config Validation Errors                       ***
2024-05-25T20:22:17.410904911+01:00 2024-05-25 19:22:17.410843449  *************************************************************
2024-05-25T20:22:18.776405371+01:00 2024-05-25 19:22:18.776269198  [INFO] Service Frigate exited with code 1 (by signal 0)

I've tried running frigate separately to generate an updated config file (which is no different)

potchin commented 5 months ago

Not ideal but I managed to get around it by running the migration in a separate container and then copying all the new files back to the pvc inside k8s. There are some hidden files which the app uses to determine the version of the config.

newbenji commented 5 months ago

Can you post those files here? and the diff

potchin commented 5 months ago

there was no diff between the config files, that's what was confusing me. Theres a .version file which needs to contain 0.14 for the migration to be skipped. Not sure what the other files are needed for but I copied them over from another container and it works..

# ls -lrthA
total 1.6M
drwxr-xr-x. 2 root root 4.0K May 25 20:33 model_cache
-rw-r--r--. 1 root root    0 May 25 20:37 backup_config.yaml
-rw-r--r--. 1 root root 8.0K May 25 20:39 backup.db
-rw-r--r--. 1 root root 140K May 25 20:39 frigate.db
-rw-r--r--. 1 root root   17 May 25 20:40 .vacuum
-rw-r--r--. 1 root root   16 May 25 20:40 .timeline
-rw-r--r--. 1 root root  128 May 25 20:40 .jwt_secret
-rw-r--r--. 1 root root   17 May 25 20:40 .exports
-rw-r--r--. 1 root root    4 May 25 20:40 .version
-rwxr-xr-x. 1 root root    0 May 25 20:40 config.yml
-rw-r--r--. 1 root root  32K May 25 20:57 frigate.db-shm
-rw-r--r--. 1 root root 1.4M May 25 20:57 frigate.db-wal

# cat .version 
0.14
newbenji commented 5 months ago

yeah i can see i dont have version file in mine and it can write all files in /config beside config.yml :-D

newbenji commented 5 months ago

so basicly could be solved by adding to values. versionsfile: enabled: true version: 0.14

that makes that file?

newbenji commented 5 months ago

ah reading hes changes, i can see he have changes to mask coordinates etc. so i will be hit by it

kjvellajr commented 3 months ago

As a temporary solution I did the following with the current 7.5.1 Helm chart:

  1. Shell into the current Frigate pod and make a copy of the /config/config.yml to /config/config.yml.bkp
  2. Scale the deployment down to 0 replicas
  3. Mount the frigate-config pvc to a debug container and copy the backup /config/config.yml.bkp to /config/config.yml
  4. On the deployment, remove the configmap volumeMount and update the image tag to be 0.14.0
  5. Scale the deployment back up to 1 replicas
  6. Copy the new changes of /config/config.yml to your Helm chart values.yaml
raedkit commented 2 months ago

@blakeblackshear is there any possibility to print the content of the new config.yml to console when file is read only and frigate fail with error ? This will make the change smooth even with the automatic migration process of keys in config.yaml for 0.14.0.

jurgenweber commented 1 month ago

I took a copy of my config and just ran it up in docker and it fails but it rewrites it, all good;

docker run -it -v $(pwd)/frigate.yaml:/config/config.yaml ghcr.io/blakeblackshear/frigate:0.14.1

and then to see if it did anything;

$ diff frigate.yaml original_config.yaml
4c4
<   enabled: true
---
>   enabled: True
37c37
<       enabled: true
---
>       enabled: True
39c39
<       timestamp: true
---
>       timestamp: True
41c41
<       bounding_box: true
---
>       bounding_box: True
66c66
<       enabled: true
---
>       enabled: True
68c68
<       timestamp: false
---
>       timestamp: False
70,71c70,71
<       bounding_box: false
<       crop: true
---
>       bounding_box: False
>       crop: True
128,129c128,129
<   user: '{FRIGATE_MQTT_USER}'
<   password: '{FRIGATE_MQTT_PASSWORD}'
---
>   user: "{FRIGATE_MQTT_USER}"
>   password: "{FRIGATE_MQTT_PASSWORD}"
140c140
<   enabled: true
---
>   enabled: True
190c190
<   enabled: true
---
>   enabled: True
192c192
<   clean_copy: true
---
>   clean_copy: True
194c194
<   timestamp: false
---
>   timestamp: False
196c196
<   bounding_box: false
---
>   bounding_box: False
198c198
<   crop: false
---
>   crop: False
210d209
< version: 0.14

interestingly, this new config file still fails with errors, so it isn't comprehensive;

2024-09-28 05:13:23.731341595  *************************************************************
2024-09-28 05:13:23.731344637  *************************************************************
2024-09-28 05:13:23.731346220  ***    Your config file is not valid!                     ***
2024-09-28 05:13:23.731347637  ***    Please check the docs at                           ***
2024-09-28 05:13:23.731349012  ***    https://docs.frigate.video/configuration/index     ***
2024-09-28 05:13:23.731350220  *************************************************************
2024-09-28 05:13:23.731351428  *************************************************************
2024-09-28 05:13:23.731352678  ***    Config Validation Errors                           ***
2024-09-28 05:13:23.731354012  *************************************************************
2024-09-28 05:13:23.731356178  record.events.required_zones: Extra inputs are not permitted
2024-09-28 05:13:23.731357595  *************************************************************
2024-09-28 05:13:23.731378845  ***    End Config Validation Errors                       ***
2024-09-28 05:13:23.731379553  *************************************************************

record.events.required_zones was just a '[]' so I just hashed out the key and it was fine after that.