-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Ability to use object store for images #1814
Comments
Per the discussion in PR #2466, the configuration scheme for this needs to be fleshed out. While I don't have a strong preference, whatever solution we decide on must be platform- and vendor-agnostic, and easily extendable to accommodate similar services. |
Hi, I've been directed here from #3095 - thanks for that @jeremystretch. I have implemented something as a PoC for this. For the configuration, I toyed with several approaches:
In my implementation, I opted for (3) which I found this to be a good balance between (1) and (2). It has some things I'd like to improve. Primarily reduce or eliminate the ability for a configuration parameter to be named the same as an existing NetBox parameter and override it - perhaps it needs to scan a list of known settings used by NetBox and error if the administrator attempts to pass them in this dictionary. That seems fairly easy to implement. Perhaps (3) and (2) at the same time would be a good option - "NetBox Native" storage systems and applications could use (2) while existing systems (django-storages, etc.) could use (3). |
Note I have very simply implemented the above option 3 for our use since we need to use a Swift back-end to save images (and there are numerous configuration settings that have to be imported) in case anyone is interested. https://gerrit.wikimedia.org/r/c/operations/software/netbox/+/518785 |
This is an implementation of the strategy 3 from this comment: netbox-community/netbox#1814 (comment) Bug: T209182 Change-Id: Icbdf212b7b1f9ff59fef4f5ecf64bfd9fdc41238
I'd be happy to take this issue. Because of the separation between The configuration could look like this:
For the implementation I suggest adding Any objections to this approach? |
Hi @steffann , In my scenario, S3 is not appropriate, so I don't think it should be the only option. I understand that Django-storages has various backends, however, none were suitable for my environment or tool set. I implemented a similar configuration system to you because of the configuration/settings.py split, however, it allows any storage system to be used through an additional application. I encourage you to have a look at it, before going ahead with other solutions: Django-storages could be implemented through this interface I believe, and it would allow any storage system to be used. Personally, I implemented a storage layer which uses postgres - which is of course not a good idea for many people as has been noted in a number of other discussions, however, for my environment this is the right choice right now for a number of reasons. I think giving people the ability to choose what they do here is best. I think it would be good to include "here's how to use django-storages to get S3/whatever" as a good "default" though. |
Hi @nward, I completely understand. Based on the existing code I have the feeling that @jeremystretch prefers explicit support and configuration though. I'll leave it up to him to decide whether "officially supported options with corresponding configuration" or "flexibility to use anything you want with less clearly defined configuration boundaries" is the way forward. Cheers, |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our contributing guide. |
Hi @steffann I think my solution is a good compromise between both those extremes. The defaults can implement officially supported options, while still allowing people to use alternative options. (Sorry, though I had replied to this back in Nov!) |
@nward I did see it back in November but got confused with all the proposed solutions. Yours does indeed look like a good middle ground! Because it took me a while to find it, here is the link for others to help evaluate it: SearchLightNZ@074ace6 I haven't tested it yet, but it does look well designed. |
@steffann I've taken some more time to dig into this. I have to say that maintaining a barrage of settings specific to each storage backend within NetBox isn't realistic. Even if we were to only support S3 (which IMO is underwhelming), it would require NetBox to essentially sync with the development of
This is correct: We should avoid opening an avenue for users to import unsanitized settings for various reasons. I recommend a more lean approach, where we introduce support for the optional use of
In the case of if STORAGE_BACKEND is not None:
import storages
def _setting(name, default=None):
if name in settings.STORAGE_CONFIG:
return getattr(settings.STORAGE_CONFIG, name, default)
return getattr(settings, name, default)
storages.utils.setting = _setting This would allow the user complete control over configuring the storage engine, while still keeping the global NetBox configuration gated. I will also note that I'd prefer to avoid making |
That was actually a lot easier than expected. Simple solutions FTW! #3666 has been rebased to develop2.7, and the new implementation is ready for merge. |
This is an implementation of the strategy 3 from this comment: netbox-community/netbox#1814 (comment) Bug: T209182 Change-Id: Icbdf212b7b1f9ff59fef4f5ecf64bfd9fdc41238 (cherry picked from commit 60c58bd)
This is an implementation of the strategy 3 from this comment: netbox-community/netbox#1814 (comment) Bug: T209182 Change-Id: Icbdf212b7b1f9ff59fef4f5ecf64bfd9fdc41238 (cherry picked from commit 60c58bd) (cherry picked from commit b46b469)
Issue type
[x] Feature request
[ ] Bug report
[ ] Documentation
Environment
Description
I'm running Netbox in a Kubernetes cluster. It currently runs as a single container as I have a block device mounted into the container so that there's persistent storage for the image attachments which were introduced in #152.
This works OK, but I cannot run multiple instances of netbox in a clustered fashion as it's tied to the block device.
Could there be some integration with https://github.com/jschneier/django-storages so that S3 can be used as a backend for the image attachments?
The text was updated successfully, but these errors were encountered: