support insecure registry in configuration reload#22337
Conversation
d353874 to
95e671e
Compare
ee2739d to
2a57374
Compare
|
Any update? |
|
design LGTM @aaronlehmann @tiborvass wdyt? This keeps the |
|
Yeah, I like the concept. I don't really follow how the code changes work, though. Where does registryService := registry.NewService(cli.Config.ServiceOptions)from daemon's My apologies if I am missing something. |
2a57374 to
01c7125
Compare
|
Moving to code review. |
|
@aaronlehmann PTAL! |
|
@icecrime: See my question above. |
|
LGTM |
d0acf00 to
4aab6a4
Compare
|
ping @allencloud could you answer @aaronlehmann's question? |
|
@thaJeztah @icecrime @aaronlehmann |
There was a problem hiding this comment.
Would be better to check multiple entries as the interface supports it.
|
@allencloud were you still working on this? |
|
@thaJeztah |
|
No problem! Was going through PR's and noticed this one 👍 |
e90b5a7 to
7a792fe
Compare
|
+1 Any update? My friends. |
|
Hi, My friends. PTAL, reloading insecure registry is really important for users to use registries. Really sorry for bothering you. @thaJeztah @aaronlehmann @icecrime @cpuguy83 @LK4D4 |
There was a problem hiding this comment.
I think there are concurrency issues with writing to the live config struct without locking. It looks like it could race with isSecureIndex.
There was a problem hiding this comment.
@thaJeztah @aaronlehmann
Oh, I am afraid race could exist. Since newRepositoryInfo would be called via ResolveRepository, while ResolveRepository would be called via daemon's field RegistryService, like repoInfo, err := daemon.RegistryService.ResolveRepository(ref).
Updated it soon.
There was a problem hiding this comment.
This looks sorta weird. You should use bytes.Equal or compare the output of (*IPNet).String() I think.
There was a problem hiding this comment.
Definitely. In fact, when I put forward this PR, in api/types/resgistry/registry.go, there is no func (ipnet *NetIPNet) String() string implemented yet. And still separated in engine-api.
While now, I think it is better to use String(). And updated.
There was a problem hiding this comment.
I'm not sure how it's in other place, but it looks quite bad to ignore errors from Marshal.
There was a problem hiding this comment.
Oh, Great. Thanks for your review. @LK4D4
I will update the PR soon.
There was a problem hiding this comment.
Added the err judging, and add several other places related to this issue.
|
Thanks for all your reviews. And I am really sorry for my delay. |
|
I see some other places where there may be concurrency problems:
|
|
@aaronlehmann |
There was a problem hiding this comment.
This doesn't help. s.config.ServiceConfig is returned by the function, and then it can be read by the caller while being modified by LoadInsecureRegistries.
This function either needs to return a deep copy of ServiceConfig, or be refactored so that callers do not retrieve ServiceConfig directly (i.e. methods to look up items in the maps, which hold locks while doing the lookups).
There was a problem hiding this comment.
Thanks for review @aaronlehmann
I tried the second way. PTAL
|
Thanks for making the changes. I think the locking is correct now. But I'm concerned it will be hard to maintain. It's not obvious which functions should acquire the lock and which ones should not. For example It might be better to push all the locking to the methods on |
|
@aaronlehmann Thanks a lot for your suggestion. |
There was a problem hiding this comment.
servConfig.InsecureRegistryCIDRs = append(servConfig.InsecureRegistryCIDRs, s.config.ServiceConfig.InsecureRegistryCIDRs...)
Or allocate servConfig.InsecureRegistryCIDRs with the right size and use copy.
There was a problem hiding this comment.
servConfig.Mirrors = append(servConfig.Mirrors, s.config.ServiceConfig.Mirrors...)
There was a problem hiding this comment.
I know I suggested this, but now I'm not so sure. It means only one search can run at once, for example. And a running search will block calls to other DefaultService methods. I didn't realize that some of these methods are long-running.
I guess the general strategy of locking s.config in every exported method is okay as long as we release the lock before any long-running operation. Not sure if this just an issue for Search, or if it also applies to other methods.
There was a problem hiding this comment.
I think it is my mistake to lock the entire func Search. It will block others.
Now I try to only lock s.config in Search. Like this:
s.mu.Lock()
index, err := newIndexInfo(s.config, indexName)
s.mu.Unlock()
PTAL, thanks @aaronlehmann
|
LGTM @dmcgowan @LK4D4 Could you please review as well? My main concern with this one is getting the locking correct. It's been through a few passes and I think it's correct now (thanks @allencloud for sticking with it). There are some cases where the lock could be held for an extended period, for example |
Signed-off-by: allencloud <allen.sun@daocloud.io>
|
LGTM |
|
Yay! Thanks @allencloud! |
|
🤗 Thanks for all of your help and guide. |
|
Thanks for the pr, but it cannot do the thing well on |
|
@fsword this PR will be in docker 1.13, so isn't available yet; also, for enhancements for the docker for mac ui, please use https://github.com/docker/for-mac/issues |
Make docker support more configuration reload, like insecure-registry.
This pr did:
fixed #22332