-
Notifications
You must be signed in to change notification settings - Fork 3
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 check for tenant existence #72
Conversation
12f3faa
to
35dc096
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.
The check is only required if a new ip address is assigned. Instead of directly checking this in the reconcile loop we could check it in the GetAvailableIpAddressClaim (
func (r *NetboxClient) GetAvailableIpAddressByClaim(ipAddressClaim *models.IPAddressClaim) (*models.IPAddress, error) { |
It would be great to have this check also for the prefix claims. |
35dc096
to
5d01e7b
Compare
5d01e7b
to
f14e969
Compare
388ccc8
to
234c73b
Compare
b8ddaf8
to
0650ea1
Compare
I just did a manual check, in my opinion the operator should not log the stack trace when the tenant is not found. This makes it look like a reconciler error. Its ok when the loglevel is error but adding the stack trace is not needed.
Also when a claim succeeds a status condition is set, would it make sense to also set a status condition when tenant is not found? I see that this is the same when the parent-prefix does not exist, could we also change this? @bruelea @alexandernorth @jstudler
|
a68bb3c
to
eb769b8
Compare
Agree, the status condition should be updated too. In #74 this is implemented. |
2c62b6f
to
4d91930
Compare
the status condition and the events will be implemented in #74 |
7423717
to
68774ac
Compare
Maybe I'm getting it wrong but wouldn't the simplest solution be to just add a function like e.g. "TenantExists" which takes a tenant string and returns a bool and then check this in e.g. https://github.com/netbox-community/netbox-operator/blob/main/internal/controller/ipaddressclaim_controller.go#L79 and https://github.com/netbox-community/netbox-operator/blob/main/internal/controller/ipaddress_controller.go#L103 (and the respective location in the prefix controllers)? It's kind of a config validation and should happen early in the process. If it doesn't exist, we write a log entry and exit. With the proposed solution it will create a lease and add other complexity that we don't need. wdyt @MaIT-HgA @faebr @bruelea ? |
That would work too. The motivation to do the check if the tenant exists was that the check is only required if the IP is not yet assigned (#72 (review)). We could check the "IPAssigned" status condition in the reconcile loop and check if the tenant exists if the status condition is "false". |
True, this is a valid concern for the (rare?) case that the tenant is removed from NetBox after the ip/ipc/px/pxc resource(s) have been sucessfully created. So maybe we keep it as is. |
This is what what I did at the very beginning but then @bruelea suggested to do it in the function getting available IP/prefix since we only need to do the check for new ip assignment |
ec1803d
to
46ac25c
Compare
46ac25c
to
ecbbec2
Compare
a2717e9
to
ce930f7
Compare
ce930f7
to
1800450
Compare
Finalizer changes is removed from this MR and will be in another MR |
1800450
to
21bd119
Compare
21bd119
to
261e07b
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 good!
Close #39