-
Notifications
You must be signed in to change notification settings - Fork 140
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(feature): cleanup funcs should not rely on feature's data #1184
Merged
openshift-merge-bot
merged 1 commit into
opendatahub-io:incubation
from
bartoszmajsak:cleanup-fix
Aug 16, 2024
Merged
fix(feature): cleanup funcs should not rely on feature's data #1184
openshift-merge-bot
merged 1 commit into
opendatahub-io:incubation
from
bartoszmajsak:cleanup-fix
Aug 16, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Initially, `Cleanup` functions did not rely on loading Feature's data for invocation, as certain data was held as fields of the Feature struct, making it implicitly available. With the refactoring of Feature to become a "glorified map" container, this behavior has changed, leading to errors under certain circumstances. With `DSCI.ServiceMesh` now being a pointer to a struct, there is a corner case where the (now needed) ServiceMesh spec is `nil`, leading to a panic. When the reconciliation of DSC is triggered, it is invoked for each component, even if it is never defined or changed. In a simple case where DSCI does not have a specified ServiceMesh (`nil` instead of the default), and DSC has a single `Managed` component that is not KServe/Serverless, the reconciliation will trigger the removal of KServe resources regardless. This, in turn, will call for the removal of Serverless features, which rely on SMCP config when they are applied. With data now being loaded in the cleanup step, this leads to an error, as there is no SMCP config to read from. By default, the cleanup logic removes the owner FeatureTracker for each Feature, and this does not require loading Feature's data, as FeatureTracker is used as `OwnerReference` for each resources created for a given Feature. The API allows defining custom functions that can be invoked in addition. There is one custom cleanup function requiring the Service Mesh control plane spec to remove part of the config introduced by its patch. The code in question only worked because it had default values to work on and was not failing if patched object was not found. The refactoring wrongly enforced loading of Feature data during cleanup for this single case, and this cascaded to other Feature sets where it was unnecessary exposing this faulty behaviour. With this change, no reference to Feature is enforced at the API level by introducing the `CleanupFunc(ctx, client)` type for defining custom cleanup logic. The custom patch function has been reworked to comply with this.
zdtsw
requested review from
VaishnaviHire
and removed request for
grdryn and
Sara4994
August 16, 2024 13:06
zdtsw
approved these changes
Aug 16, 2024
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: zdtsw 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 |
openshift-merge-bot
bot
merged commit Aug 16, 2024
a88cef0
into
opendatahub-io:incubation
8 checks passed
zdtsw
pushed a commit
to zdtsw-forking/rhods-operator
that referenced
this pull request
Aug 29, 2024
…tahub-io#1184) Initially, `Cleanup` functions did not rely on loading Feature's data for invocation, as certain data was held as fields of the Feature struct, making it implicitly available. With the refactoring of Feature to become a "glorified map" container, this behavior has changed, leading to errors under certain circumstances. With `DSCI.ServiceMesh` now being a pointer to a struct, there is a corner case where the (now needed) ServiceMesh spec is `nil`, leading to a panic. When the reconciliation of DSC is triggered, it is invoked for each component, even if it is never defined or changed. In a simple case where DSCI does not have a specified ServiceMesh (`nil` instead of the default), and DSC has a single `Managed` component that is not KServe/Serverless, the reconciliation will trigger the removal of KServe resources regardless. This, in turn, will call for the removal of Serverless features, which rely on SMCP config when they are applied. With data now being loaded in the cleanup step, this leads to an error, as there is no SMCP config to read from. By default, the cleanup logic removes the owner FeatureTracker for each Feature, and this does not require loading Feature's data, as FeatureTracker is used as `OwnerReference` for each resources created for a given Feature. The API allows defining custom functions that can be invoked in addition. There is one custom cleanup function requiring the Service Mesh control plane spec to remove part of the config introduced by its patch. The code in question only worked because it had default values to work on and was not failing if patched object was not found. The refactoring wrongly enforced loading of Feature data during cleanup for this single case, and this cascaded to other Feature sets where it was unnecessary exposing this faulty behaviour. With this change, no reference to Feature is enforced at the API level by introducing the `CleanupFunc(ctx, client)` type for defining custom cleanup logic. The custom patch function has been reworked to comply with this. (cherry picked from commit a88cef0)
openshift-merge-bot bot
pushed a commit
to red-hat-data-services/rhods-operator
that referenced
this pull request
Aug 29, 2024
…tahub-io#1184) Initially, `Cleanup` functions did not rely on loading Feature's data for invocation, as certain data was held as fields of the Feature struct, making it implicitly available. With the refactoring of Feature to become a "glorified map" container, this behavior has changed, leading to errors under certain circumstances. With `DSCI.ServiceMesh` now being a pointer to a struct, there is a corner case where the (now needed) ServiceMesh spec is `nil`, leading to a panic. When the reconciliation of DSC is triggered, it is invoked for each component, even if it is never defined or changed. In a simple case where DSCI does not have a specified ServiceMesh (`nil` instead of the default), and DSC has a single `Managed` component that is not KServe/Serverless, the reconciliation will trigger the removal of KServe resources regardless. This, in turn, will call for the removal of Serverless features, which rely on SMCP config when they are applied. With data now being loaded in the cleanup step, this leads to an error, as there is no SMCP config to read from. By default, the cleanup logic removes the owner FeatureTracker for each Feature, and this does not require loading Feature's data, as FeatureTracker is used as `OwnerReference` for each resources created for a given Feature. The API allows defining custom functions that can be invoked in addition. There is one custom cleanup function requiring the Service Mesh control plane spec to remove part of the config introduced by its patch. The code in question only worked because it had default values to work on and was not failing if patched object was not found. The refactoring wrongly enforced loading of Feature data during cleanup for this single case, and this cascaded to other Feature sets where it was unnecessary exposing this faulty behaviour. With this change, no reference to Feature is enforced at the API level by introducing the `CleanupFunc(ctx, client)` type for defining custom cleanup logic. The custom patch function has been reworked to comply with this. (cherry picked from commit a88cef0)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Initially,
Cleanup
functions did not rely on loading Feature's data for invocation, as certain data was held as fields of the Feature struct, making it implicitly available. With the refactoring of Feature to become a "glorified map" container, this behavior has changed, leading to errors under certain circumstances.With
DSCI.ServiceMesh
now being a pointer to a struct, there is a corner case where the (now needed) ServiceMesh spec isnil
, leading to a panic.When the reconciliation of DSC is triggered, it is invoked for each component, even if it is never defined or changed. In a simple case where DSCI does not have a specified ServiceMesh (
nil
instead of the default), and DSC has a singleManaged
component that is not KServe/Serverless, the reconciliation will trigger the removal of KServe resources regardless. This, in turn, will call for the removal of Serverless features, which rely on SMCP config when they are applied. With data now being loaded in the cleanup step, this leads to an error, as there is no SMCP config to read from.By default, the cleanup logic removes the owner FeatureTracker for each Feature, and this does not require loading Feature's data, as FeatureTracker is used as
OwnerReference
for each resource created for a given Feature.In addition, the API allows defining custom functions that can be invoked during the clean up phase. There is one custom cleanup function requiring the Service Mesh control plane spec to remove part of the config introduced by its patch. The code in question only worked because it had default values to work on and was not failing if the patched object was not found.
The refactoring wrongly enforced the loading of Feature data during cleanup for this single case, and this cascaded to other Feature sets where it was unnecessary, exposing this faulty behavior.
With this change, no reference to Feature is enforced at the API level by introducing the
CleanupFunc(ctx, client)
type for defining custom cleanup logic. The custom patch function has been reworked to comply with this.How Has This Been Tested?
Create following DSCI and DSC:
Observe PANIC
Deploy image
quay.io/bmajsak/opendatahub-operator:cleanup-fix
with this fix.... no error \o/
Screenshot or short clip
PANIC
Merge criteria