harbor v2.9.0 migration error, jinja template typo/bug #19320
Description
If you are reporting a problem, please make sure the following information are provided:
Expected behavior and actual behavior:
Expected: Updating harbor to version 2.9.0 using prepare container and migrate command works
Actual behavior:
docker run -it --rm -v /:/hostfs goharbor/prepare:v2.9.0 migrate -i ./harbor.yml
harbor.yml
contains object storage configuration
# Harbor Storage settings by default is using /data dir on local filesystem
# Uncomment storage_service setting If you want to using external storage
storage_service:
# # storage backend, default is filesystem, options include filesystem, azure, gcs, s3, swift and oss
# # for more info about this configuration please refer https://docs.docker.com/registry/configuration/
swift:
authurl: https://swift.example/auth/v1
username: user:foobar
password: secret-replaced
container: harbor
# # set disable to true when you want to disable registry redirect
redirect:
disable: False
Error message
migrating to version 2.9.0
Traceback (most recent call last):
File "/usr/src/app/main.py", line 15, in <module>
cli()
File "/usr/lib/python3.11/site-packages/click/core.py", line 1137, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/click/core.py", line 1062, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/click/core.py", line 1668, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/click/core.py", line 763, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/app/commands/migrate.py", line 43, in migrate
m.migrate(current_input_path, current_output_path)
File "/usr/src/app/migrations/version_2_9_0/__init__.py", line 21, in migrate
f.write(tpl.render(**config_dict))
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
self.environment.handle_exception()
File "/usr/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
raise rewrite_traceback_stack(source=source)
File "/usr/src/app/migrations/version_2_9_0/harbor.yml.jinja", line 117, in top-level template code
disable: {{ value.disabled }}
^^^^^^^^^^^^^^^^^^^^^^^^^
jinja2.exceptions.UndefinedError: 'dict object' has no attribute 'disabled'
Looking at the jinja template on GitHub
# # set disable to true when you want to disable registry redirect
redirect:
{% if value.disabled is not none %}
disable: {{ value.disabled }}
{% else %}
disable: {{ value.disable }}
{% endif %}
Looking at this code, there is both the word disable
and disabled
in the jinja. Someone probably needs to change this so only one word is used. (probably disable
?)
Remediation: Modify harbor.yml.jinja
to use the keyword disable
or disabled
consistently.
Steps to reproduce the problem:
Configure harbor.yml
to use object storage, with redirect: disable
, run the prepare & migration docker command.
Versions:
Please specify the versions of following systems.
- harbor version: 2.8.2
- docker engine version: 24.0.6
- docker-compose version: 2.21.0
Additional context:
- Harbor config files: Snipped provided above
- Log files: Not relevant as issue is with migration