-
Notifications
You must be signed in to change notification settings - Fork 37
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
getResourceCondition
function is potentially destructive?
#85
Comments
+1 |
Yes. The resource in your conditional block would be recreated. I just tried it out with gcp with
Upon deleting the global address the connection resource got scheduled for deletion and then a new one took its place.
|
I might be missing something, but how are we supposed to use this function then? Until it can pass composition i.e. render successfully, it will not be creating root level resources, and until it creates root level resources - it cannot render rest of the composition. The most important reason I am using this function and not patch and transform function is that the latter do not seem to have any access to the context published by another function, so I am really in the catch 22 here. I'm sure I'm simply missing something since everyone else seem to be using it just fine? |
Hi, I've contributed the function to this repo. Our use case is to have dependencies in our compositions, to ensure that certain resources are only spawned, when their dependencies are already there - as there would be many reconcilement issues if they were created at the same time. We also noticed the problem you mentioned, and handle it like this:
This ensures, that a resource is never destructed due to a dependency becoming unready. |
Correct me if I'm wrong, but that's not always possible to do. For example in my use case, the dependencies are referenced, specifically - their status field:
If resource is not ready but exists, this composition will fail for the same reason I need to use these if statements to begin with - if composition fails, dependent resources will not be created in the first place. On the other hand, if resource becomes not ready - conditioned portion will disappear from my composition. Am I getting it right or did you mean something else @jan-di? |
I was talking mainly about the creation of composed resources. I think, the XR Status and the connection details are somewhat of a special case. We actually dont check for the Ready state of composed resources when using their status fields in the XR Status/Connection secret, instead we just use a with clause
So the respective status fields are always there, when the subresources exists independent of their status. In the end, its up to consument of the XR to wait until the XR is ready itself until its guranteed that everything output in the status is ready. |
Yeah, that's just one example - it's not necessarily limited to it... here's another example, composing KMS encrypted S3 with IAM role for it:
In a case crossplane "thinks" there is something wrong with either kms/s3, it will stip out the role of the relevant policies, potentially causing production outage. There are lots more examples, not everything fits into this model of "selectors", some resources are just missing them, some is not a simple "reference" like in the policy above. |
Thanks @jan-di , this does works! here is a snippet from composition that queries the observed resource which is creating AWS Managed Prefix Lists and stores it ID to my composite -
|
So, trying to define a composition of a multiple resources where one depends on another but does not implement selectors. Probably most typical use case is
kind: CompositeConnectionDetails
but also things like a IAM policy template that uses ARN of the previous resource.Since there is a dependency, template would fail at the composition and nothing will happen.
One way to workaround that as far as I understood from the documentation is by using
getResourceCondition
function. So I ended up with something like this:And then it got me thinking... what if for whatever reason one of these resources become not ready? Composition will void dependent resources from the output and consequentially Crossplane will try to delete them. Am I missing something or doing something wrong? Any better ways to handle these dependencies? Am I supposed to just make sure that if dependencies are not ready, at least some incomplete version of the resource is still being produced? That doesn't solve the connection details though, as keys may become temporarily corrupted...
The text was updated successfully, but these errors were encountered: