-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Google Cloud DNS dnsprovider #25389
Google Cloud DNS dnsprovider #25389
Conversation
Successfully tested against both real and stubbed cloud backends. |
cc: @justinsb |
"github.com/golang/glog" | ||
) | ||
|
||
// Factory is a function that returns a cloudprovider.Interface. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My apologies - this file needs updating, and has not been tested yet. I'll fix it now. But you can review the rest of the PR in the mean time,
Looks like a vendor-related problem. I'm looking...
|
Apparently #25516 did not fix this:
|
…fully Tested against both real backend and stubbed backend.
@k8s-bot Test this please |
Looks like I need a better header comment. Fixing...
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as previous files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, done.
@k8s-bot Test this please. |
|
||
// All registered dns providers. | ||
var providersMutex sync.Mutex | ||
var providers = make(map[string]Factory) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two are always used together and should be structurally reflected that way. Something like:
type providersMap struct {
providers map[string]Factory
mutex sync.Mutex
}
And initialize the struct in InitDnsProviders()
below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InitDnsProvider()
seems to be not the right place. It seems to initialize a single provider. providersMap
can probably be globally initialized. Or could be done in a package level init()
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is actually a direct mirror of what's in the cloudprovider package. I'd suggest that we fix both of them, as you suggest, but in a separate cleanup PR. At least the two (dnsprovider and cloudprovider) are consistent now :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
package internal | ||
|
||
import ( | ||
"google.golang.org/api/dns/v1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@quinton-hoole I did one full pass. Have left some comments. In terms of what it accomplishes, it looks good. But on the other hand, there are too many levels in the hierarchy. I guess you are doing all that to provide fakes for testing. But that makes it hard to form a very good mental model in the first pass. |
Also, why is all this in |
@madhusudancs Agreed it's a lot of code, but there is no other/better way to do unit testing. At least not that I could think of. I don't like it either, but I couldn't think of a better/more lucid way. Also, agreed, this could/should be moved to pkg/dnsprovider. Will do. |
@madhusudancs One more thing about the unit testing. The root of the complication is that Google Cloud DNS golang library does not include any golang interfaces. It implements structs directly, with read/write fields. This is what makes it fundamentally unstubbable without a separate interface level, and another level of implementations of that interface (as well as the stub implementation) - hence three levels. AWS Route 53 on the other hand, provides the interfaces and implementations thereof, hence requiring only a single layer of stub implementations. Make sense? |
GCE e2e build/test passed for commit 4988c43. |
Should compile correctly after #25679 merges. Needs updated googleapi package. |
@quinton-hoole Is this ready for next review pass? |
All that remains is to move it out of the federation package tree, I think.
|
@quinton-hoole Except for a few very minor nits, this code looks good to me for the first cut. I definitely don't want to hold this PR for the dnsprovider package to be moved to pkg/. Please do consider doing that in a follow up PR and also address the tiny nits. I am applying the LGTM label. If you need to rebase or something and the merge bot removes the label, please feel free to reapply. |
Yeah, makes sense. |
Replaced by identical #26020 |
Add Google Cloud DNS dnsprovider.