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

[BUG] Varken Crashes when ini is read only #146

Closed
rmzg opened this issue Jun 30, 2019 · 6 comments
Closed

[BUG] Varken Crashes when ini is read only #146

rmzg opened this issue Jun 30, 2019 · 6 comments
Labels
approved Enhancement or request that was approved to be worked on bug Something isn't working in-next-release In the next release

Comments

@rmzg
Copy link

rmzg commented Jun 30, 2019

I run Varken inside a kubernetes using its ConfigMap object to provide the actual config file, as a result of this the actual config file inside the docker image is read only (since it's being provided from another location). However, when varken detects a missing config stanza it attempts to rewrite the config file and this causes a crash since it can't open the file for writing.

Suggestion: if a config option is missing, attempt to rewrite the file but gracefully fail if this isn't possible and continue running with default values where possible. Since my case involves missing top level configs (ombi) it should be pretty ignorable.

Traceback (most recent call last):
  File "/app/varken/iniparser.py", line 25, in __init__
    self.parse_opts(read_file=True)
  File "/app/varken/iniparser.py", line 177, in parse_opts
    url = self.url_check(env.get(f'VRKN_{envsection}_URL', self.config.get(section, 'url')),
  File "/usr/local/lib/python3.7/configparser.py", line 780, in get
    d = self._unify_values(section, vars)
  File "/usr/local/lib/python3.7/configparser.py", line 1146, in _unify_values
    raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'ombi-0'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/Varken.py", line 92, in <module>
    CONFIG = INIParser(DATA_FOLDER)
  File "/app/varken/iniparser.py", line 28, in __init__
    self.rectify_ini()
  File "/app/varken/iniparser.py", line 133, in rectify_ini
    self.write_file('varken.ini')
  File "/app/varken/iniparser.py", line 80, in write_file
    with open(file_path, 'w') as config_ini:
OSError: [Errno 30] Read-only file system: '/config/varken.ini'
@rmzg rmzg added the awaiting-triage Request awaiting triage label Jun 30, 2019
@dirtycajunrice
Copy link
Member

dirtycajunrice commented Jun 30, 2019

Why not just use environment variables since you use k8s?

And that is in place for a reason. if your config is incomplete you should be completing it yourself instead of having it fail if its read only

@samwiseg0
Copy link
Member

I agree we should not crash but I disagree that Varken should continue to run. We should exit if we cannot write the config file if it is invalid.

@rmzg
Copy link
Author

rmzg commented Jul 1, 2019

A) I don't use environment variables because I didn't know they were an option and I don't understand how they apply in this situation

B) There may be some cases where the config file is invalid to the point of not being able to run, in this specific case (and the last couple of times this has happened), the problem is merely missing config blocks for services that aren't even enabled.

In other words, the config is valid, you add support for a new service (ombi) and suddenly the config becomes invalid and varken starts crashing trying to rewrite the config file. This seems pretty unnecessary, no?

@dirtycajunrice
Copy link
Member

Env vars are brand new so no harm no foul there! As for a new service, the block does not need to be there if the global is defined as false, but there does need to be a global server ids section for false. Maybe that is where the disconnect is?

@rmzg
Copy link
Author

rmzg commented Jul 7, 2019

Well, in my current config I have this line:

sickchill_server_ids = 0

and varken crashes with the error:

2019-07-07 17:54:38 : DEBUG : iniparser : Section sickchill-1 missing. Adding...
2019-07-07 17:54:38 : DEBUG : iniparser : url is missing in sickchill-1. Adding defaults...
2019-07-07 17:54:38 : DEBUG : iniparser : apikey is missing in sickchill-1. Adding defaults...
2019-07-07 17:54:38 : DEBUG : iniparser : ssl is missing in sickchill-1. Adding defaults...
2019-07-07 17:54:38 : DEBUG : iniparser : verify_ssl is missing in sickchill-1. Adding defaults...
2019-07-07 17:54:38 : DEBUG : iniparser : get_missing is missing in sickchill-1. Adding defaults...
2019-07-07 17:54:38 : DEBUG : iniparser : get_missing_run_seconds is missing in sickchill-1. Adding defaults...
2019-07-07 17:54:38 : DEBUG : iniparser : Writing to varken.ini
Traceback (most recent call last):
  File "/app/varken/iniparser.py", line 25, in __init__
    self.parse_opts(read_file=True)
  File "/app/varken/iniparser.py", line 177, in parse_opts
    url = self.url_check(env.get(f'VRKN_{envsection}_URL', self.config.get(section, 'url')),
  File "/usr/local/lib/python3.7/configparser.py", line 780, in get
    d = self._unify_values(section, vars)
  File "/usr/local/lib/python3.7/configparser.py", line 1146, in _unify_values
    raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'ombi-0'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/Varken.py", line 92, in <module>
    CONFIG = INIParser(DATA_FOLDER)
  File "/app/varken/iniparser.py", line 28, in __init__
    self.rectify_ini()
  File "/app/varken/iniparser.py", line 133, in rectify_ini
    self.write_file('varken.ini')
  File "/app/varken/iniparser.py", line 80, in write_file
    with open(file_path, 'w') as config_ini:
OSError: [Errno 30] Read-only file system: '/config/varken.ini'

I feel like the global server id = 0 used to be sufficient, since it worked when I added this a while ago, but it no longer works that way.

@dirtycajunrice
Copy link
Member

0 no longer works and an explicit false is required. This was changed in the last release

@dirtycajunrice dirtycajunrice changed the title [Feature Request] Avoid crashing when config file is read only [Bug] Varken Crashes when ini is read only Jul 17, 2019
@dirtycajunrice dirtycajunrice added approved Enhancement or request that was approved to be worked on bug Something isn't working and removed awaiting-triage Request awaiting triage labels Jul 17, 2019
@dirtycajunrice dirtycajunrice added the in-next-release In the next release label Aug 9, 2019
@dirtycajunrice dirtycajunrice changed the title [Bug] Varken Crashes when ini is read only [BUG] Varken Crashes when ini is read only Aug 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Enhancement or request that was approved to be worked on bug Something isn't working in-next-release In the next release
Projects
None yet
Development

No branches or pull requests

3 participants