-
Notifications
You must be signed in to change notification settings - Fork 107
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
fix(DSC): do not reconcile resource if it has a special annotation #879
fix(DSC): do not reconcile resource if it has a special annotation #879
Conversation
rawdeployment Signed-off-by: Wen Zhou <wenzhou@redhat.com>
controllers/datasciencecluster/datasciencecluster_controller.go
Outdated
Show resolved
Hide resolved
Signed-off-by: Wen Zhou <wenzhou@redhat.com>
/lgtm |
@@ -335,6 +335,10 @@ var configMapPredicates = predicate.Funcs{ | |||
if e.ObjectNew.GetName() == "prometheus" && e.ObjectNew.GetNamespace() == "redhat-ods-monitoring" { | |||
return false | |||
} | |||
// Do not reconcile on kserver's inferenceservice-config CM updates, for rawdeployment | |||
if e.ObjectNew.GetName() == "inferenceservice-config" && (e.ObjectNew.GetNamespace() == "redhat-ods-applications" || e.ObjectNew.GetNamespace() == "opendatahub") { |
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.
Please correct if I'm wrong but I'm not sure if this if condition works like we need: during an upgrade (i.e. from version 2.1 to 2.2) this value should not be overridden otherwise the user will need to restore the configuration after every release.
@etirelli
Is this the predicate that you mentioned be that can be used to bypass the reconcile?
Is there any way (like an annotation?) to let the user opt-out the reconcile? This configMap is something the user might want to update even if it is not something that we officially document yet
@VaishnaviHire
FYI
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.
originally with this change, my thought goes with "changes in one specific CM should not lead to unnecessary reconcile of DSC"
but after some offline talk, I think the real problem we want to resolve here is:
user can update CM's data and not get reverted back during the same ODH release and even update ODH upgrade to a new release.
so i think in this case we will need 2 changes:
- prevent DSC reconcile because of this CM has been updated
- skip ownerreference on some resources
and the only thing i can think of for (2) is to use an annotation as indication, which user can add it when they are updating CM's data
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.
Out of curiosity, why the namespace test is needed?
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.
BTW, I think the ownership annotation is still needed, because IMO uninstalling the component should still collect and remove the CM. So, IMO, the annotation should simply control whether cli.Patch
should be skipped in the managedResource
func of pkg/deploy/deploy.go
.
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.
Out of curiosity, why the namespace test is needed?
the part to check if it is in opendatahub or in redhat-ods-applications?
only to narrow down if the CM is in these 2 namespaces. do you see it is possible that users create a different application namespace and deploy kseve into that?
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.
good point @israel-hdez
if not set ownerreference, then users will need to cleanup these resource by themselves when they Removed component or uninstall ODH.
we need to be clear:
- if annoation is set by the users, what consequence it will be
- if component manifests has it set by default, do we need to state this in the release docs to user
leave above ^ to @danielezonca
and i start to lean towards your idea to "keep ownerreference but just skip patch"
this is mainly because i am thinking, in the first case, annoation is post added by user, so when it first gets applied to the cluster (by component set as Managed) it should get ownerreference already. to skip it , only works the annotation has been added in the manifests out of the box.
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.
Well overall the use case is to let user customise this configMap and at that point the operator should not reconcile it anymore.
About the delete I agree that it is fine to keep removing it because it is tied to KServe so if the user remove KServe it is fine to remove it.
I'm fine with an exception (if) or an annotation to opt-out. The "skip patch" should work but we need to make sure it works also when we update from one version to another (i.e. 2.7 -> 2.8)
Note: this feature for now is a bit "advanced" and not really something we would like to document for "normal usage" but it can be necessary for hotfixes or ad hoc solutions and at the moment the only way to make it work (as far as I know) is to scale the operator to 0 that is definitely big as impact.
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 made another updates on this PR:
- we will keep adding owerreference (same logic as before)
- we do not patch resource if it has annotation set
- even upgrade to a new version of ODH, it consists with same customized content if annotation exists
- when component is Removed, such resource will be removed as well.
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 logic seems good to me (but I have not tested the PR)
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.
Why would you need to test it manually? Can we add some automated tests to cover those scenarios? Is it a big effort?
annotation to false Signed-off-by: Wen Zhou <wenzhou@redhat.com>
pkg/deploy/deploy.go
Outdated
@@ -271,7 +271,8 @@ func manageResource(ctx context.Context, cli client.Client, obj *unstructured.Un | |||
if apierrs.IsNotFound(err) { | |||
// Set the owner reference for garbage collection | |||
// Skip set on CRD, e.g. we should not delete notebook CRD if we delete DSC instance | |||
if found.GetKind() != "CustomResourceDefinition" { | |||
// Skip on resource if has annotation "opendatahub.io/managed: false" | |||
if found.GetKind() != "CustomResourceDefinition" || found.GetAnnotations()["opendatahub.io/managed"] != "false" { |
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.
is the intention here "if it is CustomResourceDefinition OR there is managed=false annotation, then skip setting the reference"? If so should the negation be with AND then?
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 was not sure in this case should annoation take over CRD kind or CRD kind should always be skipped regardless annoation.
now i think probably the later is more safe, so we do not change behavior, and we can decide what we want later.
i will do the change, what i want to do now:
- if it is CRD regardless annotation, skip
- if it is not CRD and has annoation to false, skip
- othercases, set ownerreference
- we still set ownerreference on resources - we only skip reconcile if resource has defined annotation Signed-off-by: Wen Zhou <wenzhou@redhat.com>
/lgtm |
pkg/deploy/deploy.go
Outdated
@@ -287,6 +287,11 @@ func manageResource(ctx context.Context, cli client.Client, obj *unstructured.Un | |||
return nil | |||
} | |||
|
|||
if found.GetAnnotations()["opendatahub.io/managed"] == "false" { |
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.
The other patch is responsible for removing the ownerreferrences and cleaning up the resources when a component is set to Removed
. I think we still want to cleanup the resource with "opendatahub.io/managed" annotation...correct?
If so, we don't need to update any condition.
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.
Is there any particular reason for "opendatahub.io/managed"
to be an annotation instead of a label? With the latter, we could query such resources easier. Can the purpose of this be documented as part of this PR? This could help us decide what's the most feasible approach here.
Also if it's not documented it becomes a super-power known only by chosen ones :)
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.
just found out label opendatahub.io/managed
has been used by several components already.
so if we want to make it a label than annotation, we need to find a different key for it.
Hi @danielezonca @israel-hdez and @Jooho(forRHOAIENG-1262 ), for the annotation is this something that only should be added by the manifests i.e if a user adds this annotation we should revert it? Or do we support this annotation irrespective of it being added by the user or component manifests? |
AFAIK, we didn't define this. I think we need to discuss this. That said, we don't have plans to further update our manifests for the upcoming release. So, for now, we DO need to have the possibility for the user adding the annotation. |
From my understanding, purely from this special case: |
➕ 1️⃣ |
Seems like we need more inputs regarding the general behavior, and immediate fix is needed for Kserve, lets update the condition to
WDYT @israel-hdez @zdtsw @danielezonca @etirelli ? |
It is fine for me, given the limited time we have. And looking forward for the discussion involving the other components. |
yes i agree this, we can limit it to only kserve case till we want to make it a solution might be useful across other components |
Signed-off-by: Wen Zhou <wenzhou@redhat.com>
/test opendatahub-operator-e2e |
/test opendatahub-operator-e2e |
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.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: VaishnaviHire The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
20f4ad0
into
opendatahub-io:incubation
…pendatahub-io#879) * fix(DSC+Kserve): do not reconcile inferenceservice-config for rawdeployment Signed-off-by: Wen Zhou <wenzhou@redhat.com> * fix: wrong logic Signed-off-by: Wen Zhou <wenzhou@redhat.com> * feat(deploy): do not set ownerreference if resource has sepcial annotation to false Signed-off-by: Wen Zhou <wenzhou@redhat.com> * update: change logic to --if kind is CRD do not care annotation * update: change logic - we still set ownerreference on resources - we only skip reconcile if resource has defined annotation Signed-off-by: Wen Zhou <wenzhou@redhat.com> * fix(typo) Signed-off-by: Wen Zhou <wenzhou@redhat.com> * Update: limite scope of annoation to only kserve resource for now Signed-off-by: Wen Zhou <wenzhou@redhat.com> --------- Signed-off-by: Wen Zhou <wenzhou@redhat.com> (cherry picked from commit 20f4ad0)
…pendatahub-io#879) * fix(DSC+Kserve): do not reconcile inferenceservice-config for rawdeployment Signed-off-by: Wen Zhou <wenzhou@redhat.com> * fix: wrong logic Signed-off-by: Wen Zhou <wenzhou@redhat.com> * feat(deploy): do not set ownerreference if resource has sepcial annotation to false Signed-off-by: Wen Zhou <wenzhou@redhat.com> * update: change logic to --if kind is CRD do not care annotation * update: change logic - we still set ownerreference on resources - we only skip reconcile if resource has defined annotation Signed-off-by: Wen Zhou <wenzhou@redhat.com> * fix(typo) Signed-off-by: Wen Zhou <wenzhou@redhat.com> * Update: limite scope of annoation to only kserve resource for now Signed-off-by: Wen Zhou <wenzhou@redhat.com> --------- Signed-off-by: Wen Zhou <wenzhou@redhat.com> (cherry picked from commit 20f4ad0)
* Update Owners and Owwners-aliases (opendatahub-io#869) (cherry picked from commit 7f477a3) * fix(DSC): do not reconcile resource if it has a special annotation (opendatahub-io#879) * fix(DSC+Kserve): do not reconcile inferenceservice-config for rawdeployment Signed-off-by: Wen Zhou <wenzhou@redhat.com> * fix: wrong logic Signed-off-by: Wen Zhou <wenzhou@redhat.com> * feat(deploy): do not set ownerreference if resource has sepcial annotation to false Signed-off-by: Wen Zhou <wenzhou@redhat.com> * update: change logic to --if kind is CRD do not care annotation * update: change logic - we still set ownerreference on resources - we only skip reconcile if resource has defined annotation Signed-off-by: Wen Zhou <wenzhou@redhat.com> * fix(typo) Signed-off-by: Wen Zhou <wenzhou@redhat.com> * Update: limite scope of annoation to only kserve resource for now Signed-off-by: Wen Zhou <wenzhou@redhat.com> --------- Signed-off-by: Wen Zhou <wenzhou@redhat.com> (cherry picked from commit 20f4ad0) * fix(feature): use correct error variable name (opendatahub-io#882) (cherry picked from commit 0d8bd14) * allow setting default deployment mode for Kserve in DSC (opendatahub-io#864) * allow setting default deployment mode for Kserve in DSC Signed-off-by: Vedant Mahabaleshwarkar <vmahabal@redhat.com> * move kserve config logic to separate file + enhancements Signed-off-by: Vedant Mahabaleshwarkar <vmahabal@redhat.com> * revert dev image set in operator CSV Signed-off-by: Vedant Mahabaleshwarkar <vmahabal@redhat.com> * only setup kserve config if component is enabled Signed-off-by: Vedant Mahabaleshwarkar <vmahabal@redhat.com> * bug fix Signed-off-by: Vedant Mahabaleshwarkar <vmahabal@redhat.com> * address PR feedback Signed-off-by: Vedant Mahabaleshwarkar <vmahabal@redhat.com> * cleanup Signed-off-by: Vedant Mahabaleshwarkar <vmahabal@redhat.com> * fix lint error Signed-off-by: Vedant Mahabaleshwarkar <vmahabal@redhat.com> * set default value for Kserve defaultDeploymentMode to be empty Signed-off-by: Vedant Mahabaleshwarkar <vmahabal@redhat.com> * more pr feedback Signed-off-by: Vedant Mahabaleshwarkar <vmahabal@redhat.com> * update bundle Signed-off-by: Vedant Mahabaleshwarkar <vmahabal@redhat.com> * enhance documentation Signed-off-by: Vedant Mahabaleshwarkar <vmahabal@redhat.com> * add readme for dev preview Signed-off-by: Vedant Mahabaleshwarkar <vmahabal@redhat.com> --------- Signed-off-by: Vedant Mahabaleshwarkar <vmahabal@redhat.com> (cherry picked from commit cebd287) * Update bundle --------- Co-authored-by: Wen Zhou <wenzhou@redhat.com> Co-authored-by: Ivan Necas <necasik@gmail.com> Co-authored-by: Vedant Mahabaleshwarkar <vmahabal@redhat.com>
…pendatahub-io#879) * fix(DSC+Kserve): do not reconcile inferenceservice-config for rawdeployment Signed-off-by: Wen Zhou <wenzhou@redhat.com> * fix: wrong logic Signed-off-by: Wen Zhou <wenzhou@redhat.com> * feat(deploy): do not set ownerreference if resource has sepcial annotation to false Signed-off-by: Wen Zhou <wenzhou@redhat.com> * update: change logic to --if kind is CRD do not care annotation * update: change logic - we still set ownerreference on resources - we only skip reconcile if resource has defined annotation Signed-off-by: Wen Zhou <wenzhou@redhat.com> * fix(typo) Signed-off-by: Wen Zhou <wenzhou@redhat.com> * Update: limite scope of annoation to only kserve resource for now Signed-off-by: Wen Zhou <wenzhou@redhat.com> --------- Signed-off-by: Wen Zhou <wenzhou@redhat.com> (cherry picked from commit 20f4ad0)
ref: https://issues.redhat.com/browse/RHOAIENG-3111, https://issues.redhat.com/browse/RHOAIENG-1262
for kserve to work with raw deployment
see #864:
inferenceServiceConfigMap.Data["deploy"] = string(deployDataBytes)
Description
opendatahub.io/managed: 'false'
it will not be reconcile by DSCopendatahub.io/managed: 'false'
it will not be revert after upgrade ODHHow Has This Been Tested?
live build quay.io/wenzhou/opendatahub-operator-catalog:v2.8.3111-1
Merge criteria: