-
Notifications
You must be signed in to change notification settings - Fork 101
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
Add DNS ManagedZone managed resource #457
base: master
Are you sure you want to change the base?
Add DNS ManagedZone managed resource #457
Conversation
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.
Hey @danielinclouds, thanks for opening this PR!
You just need to rebase your commits signing each of them (git commit -s
), otherwise the DCO CI check will fail.
I've added some small comments in the code.
ff28de4
to
35bb96b
Compare
@Feggah I made all requested changes. Do I resolve your comments or leave them to you? |
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.
I did some testing running the code and that's what I think should be fixed:
- Import is not working.
- Import isn't importing the private networks.
I think the one of the errors are occurring because I told you in the last review to remove some fields from the LateInitialize method. I'm sorry if this is the cause, I didn't predict it.
The first error you can reproduce with this test case:
- Create a DNS zone in the GCP interface
- Create a ManagedZone managed resource only with required fields with the same name as created in the step 1.
apiVersion: dns.gcp.crossplane.io/v1alpha1
kind: ManagedZone
metadata:
name: test
spec:
forProvider:
dnsName: test.com.
providerConfigRef:
name: default
- Results in a error, because it is trying to update the
visibility
to public (it was created as private in the interface). The expected behavior would be importing the values from the API and not updating the resource at all (because that would be nothing to update, as we are importing the fields from the API.
1.6639251312905607e+09 DEBUG provider-gcp Reconciling {"controller": "managed/managedzone.dns.gcp.crossplane.io", "request": "/test"}
1.6639251331243162e+09 DEBUG provider-gcp Cannot update external resource {"controller": "managed/managedzone.dns.gcp.crossplane.io", "request": "/test", "uid": "ad15a248-58ca-47d1-90f3-22a51a8062e6", "version": "53015", "external-name": "test"}
1.663925133124595e+09 DEBUG events Warning {"object": {"kind":"ManagedZone","name":"test","uid":"ad15a248-58ca-47d1-90f3-22a51a8062e6","apiVersion":"dns.gcp.crossplane.io/v1alpha1","resourceVersion":"53015"}, "reason": "CannotUpdateExternalResource", "message": "googleapi: Error 400: The field 'entity.managedZone.visibility' cannot be modified., immutableField"}
To see the second error, you can create an ManagedZone without specifying the networks, and then you specify it in the GCP interface.
What happens is that the controller isn't considering this field, and the controller is behaving as it is already up to date with the external state (and it isn't).
The expected behavior would be: after specifying in the GCP interface, in the next reconciliation loop the network would be filled when kubectl describe
the resource.
202d79d
to
fcca94c
Compare
Signed-off-by: Daniel Kozlowski <[email protected]>
Signed-off-by: Daniel Kozlowski <[email protected]>
Signed-off-by: Daniel Kozlowski <[email protected]>
Signed-off-by: Daniel Kozlowski <[email protected]>
Signed-off-by: Daniel Kozlowski <[email protected]>
…eSpecFail Signed-off-by: Daniel Kozlowski <[email protected]>
Signed-off-by: Daniel Kozlowski <[email protected]>
Signed-off-by: Daniel Kozlowski <[email protected]>
Co-authored-by: Gabriel Ferreira <[email protected]> Signed-off-by: Daniel Kozlowski <[email protected]>
Signed-off-by: Daniel Kozlowski <[email protected]>
Signed-off-by: Daniel Kozlowski <[email protected]>
Signed-off-by: Daniel Kozlowski <[email protected]>
Signed-off-by: Daniel Kozlowski <[email protected]>
Signed-off-by: Daniel Kozlowski <[email protected]>
Signed-off-by: Daniel Kozlowski <[email protected]>
Signed-off-by: Daniel Kozlowski <[email protected]>
fcca94c
to
cf88e93
Compare
@Feggah Please look again, I think all problems should be addressed now. |
Signed-off-by: Daniel Kozlowski <[email protected]>
52293fc
to
f8dd587
Compare
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.
Looks great! We are pretty close to merge, thanks for your effort!
I created the manifest:
apiVersion: compute.gcp.crossplane.io/v1beta1
kind: Network
metadata:
name: example
spec:
forProvider:
autoCreateSubnetworks: false
routingConfig:
routingMode: REGIONAL
---
apiVersion: dns.gcp.crossplane.io/v1alpha1
kind: ManagedZone
metadata:
name: test
spec:
forProvider:
dnsName: test.com.
visibility: private
privateVisibilityConfig:
networks:
- networkRef:
name: example
And I got an update loop in the managed resource. Every reconciliation it was updating, even if not needed.
Besides that, I added some small comments in the code.
// NetworkSelfLink extracts the SelfLink of a Network. | ||
func NetworkSelfLink() reference.ExtractValueFn { | ||
return func(mg resource.Managed) string { | ||
n, ok := mg.(*Network) | ||
if !ok { | ||
return "" | ||
} | ||
return n.Status.AtProvider.SelfLink | ||
} | ||
} |
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.
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.
Unfortunately NetworkURL
function is not enough because I need a full SelfLink not a trimmed version of the link. I also can't just add a prefix to the string returned by NetworkURL()
because the Extract
field expects a value of type reference.ExtractValueFn
.
Here is an error I'm getting when I'm using NetworkURL()
instead of NetworkSelfLink()
1.667036804796583e+09 DEBUG provider-gcp Cannot create external resource {"controller": "managed/managedzone.dns.gcp.crossplane.io", "request": "/test", "uid": "6f5ba5ef-dcd2-488f-b5bc-48e3cbad11fd", "version": "800", "external-name": "test", "error": "cannot create DNS ManagedZone: googleapi: Error 400: Invalid value for 'entity.managedZone.privateVisibilityConfig.networks[0].networkUrl': 'projects/po-test-314912/global/networks/example', invalid"}
Co-authored-by: Gabriel Ferreira <[email protected]> Signed-off-by: Daniel Kozlowski <[email protected]>
3abee0f
to
1234435
Compare
Co-authored-by: Gabriel Ferreira <[email protected]> Signed-off-by: Daniel Kozlowski <[email protected]>
2c57896
to
d8ba224
Compare
Signed-off-by: Daniel Kozlowski <[email protected]>
Signed-off-by: Daniel Kozlowski <[email protected]>
@Feggah Let's try again :) |
Description of your changes
Add DNS ManagedZone managed resource.
Fixes #455
I have:
make reviewable test
to ensure this PR is ready for review.How has this code been tested
Notes
This resource is based on ManagedZone but is missing
DnssecConfig
,ForwardingConfig
,NameServerSet
,PeeringConfig
,ServiceDirectoryConfig
,ReverseLookupConfig
parameters. The idea behind this implementation is to satisfy the most common use of GCP DNS Managed Zone.