Skip to content
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

feat: reworks Feature to be generic data container #1052

Conversation

bartoszmajsak
Copy link
Contributor

@bartoszmajsak bartoszmajsak commented Jun 12, 2024

Description

Important

For the high-level overview please have a look at README.md which is part of this PR. It's a good starting point :)

Feature Struct Improvements

  • Eliminates the .Spec field which was a single point of coupling with various domain structs used across the project.
  • Introduces a generic map to store keys relevant to a given feature, which are utilized in templates and other functions.

Feature Builder Changes

Feature Builder Changes

  • Renamed a few functions to better reflect their intent:
    • entry builder function feature.CreateFeature becomes feature.Define
    • Load() becomes Create()
  • .WithData builder function serves as an entry point to define the contents of a given feature. This chain method allows adding key-values to the feature's context. These values are later used in templates and can also be accessed in pre/post conditions and for programmatic resource creation.

Additional Changes

  • Simplifies and decouples the use of FeatureHandler. It is no longer necessary to pass it to the Feature builder to group features together.
  • Introduces a new FeatureRegistry interface, allowing convenient addition of feature sets to the handler via the FeatureProvider function.
  • Introduces a convention for defining FeatureData for specific parts of the platform (e.g., Serverless or Service Mesh setup). This approach enhances readability and promotes the reuse of commonly used data entries.
  • Adds a README.md file providing a high-level overview of the Feature DSL.

JIRA issue:

https://issues.redhat.com/browse/RHOAIENG-4579

How Has This Been Tested?

Besides automated tests, I enabled KServe component and tested sample ISVC using this script

Warning

There seems to be regression in KServe/ODH Model Controller deployment as described in opendatahub-io/odh-model-controller#233 opendatahub-io/odh-model-controller#234. Follow workarounds to see that it all works as intended.

Merge criteria:

  • Have a meaningful commit messages.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

@bartoszmajsak
Copy link
Contributor Author

Important

Deliberately put do-not-merge/hold label as I want to solicit feedback from multiple people and avoid one LGTM resulting in auto-merge. I consider it ready to review. This was in my backlog for a long time and the code I wasn't really happy with, so I want to end up with something which is flexible and easy to use.

@bartoszmajsak bartoszmajsak requested review from AjayJagan and removed request for ajaypratap003 and Sara4994 June 12, 2024 13:17
pkg/upgrade/upgrade.go Outdated Show resolved Hide resolved
pkg/feature/cert.go Outdated Show resolved Hide resolved
@bartoszmajsak bartoszmajsak force-pushed the feature-spec-container branch from d5f0313 to d51444a Compare June 14, 2024 10:14
@bartoszmajsak bartoszmajsak force-pushed the feature-spec-container branch 3 times, most recently from a148731 to 6d1ead1 Compare June 18, 2024 09:34
Copy link
Contributor

@AjayJagan AjayJagan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for this @bartoszmajsak .

@bartoszmajsak
Copy link
Contributor Author

I think it's been incubating for long enough, removing hold label. Thank you everyone for feedback here and through other channels. Waiting for the final round of review!

@bartoszmajsak bartoszmajsak force-pushed the feature-spec-container branch 2 times, most recently from 50d83fc to 58fc075 Compare July 9, 2024 20:29
@bartoszmajsak bartoszmajsak force-pushed the feature-spec-container branch 2 times, most recently from 8d2da19 to 0265341 Compare July 10, 2024 09:43
@bartoszmajsak
Copy link
Contributor Author

/retest

Feature Struct Improvements

- Eliminates the `.Spec` field, eliminating a single point of coupling with
  various domain structs used across the project.
- Introduces a generic map to store keys relevant to a given feature,
  which are utilized in templates and other functions.

Feature Builder Changes

- Renamed few functions to better reflect their intent
    - entry builder function `feature.CreateFeature` becomes
  `feature.Define`
   - Load() becomes Create()
- `.WithData` builder function serves as an entry point to define the
  contents of a given feature. This chain method allows adding key-values
  to the feature's context. These values are later used in templates and
  can also be accessed in pre/post conditions and for programmatic
  resource creation.

Additional Changes

- Simplifies and decouples the use of `FeatureHandler`. It is no longer
  necessary to patss it to the Feature builder to group features together.
- Introduces a new `FeatureRegistry` interface, allowing convenient
  addition of feature sets to the handler via the `FeatureProvider` function.
- Introduces a convention for defining `FeatureData` for specific parts of
  the platform (e.g., Serverless or Service Mesh setup). This approach
  enhances readability and promotes the reuse of commonly used data entries.
- Adds a `README.md` file providing a high-level overview of the `Feature DSL`.
@bartoszmajsak bartoszmajsak force-pushed the feature-spec-container branch from 0265341 to e45dbea Compare July 10, 2024 11:25
Copy link

openshift-ci bot commented Jul 10, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AjayJagan, israel-hdez, 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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 973ff74 into opendatahub-io:incubation Jul 10, 2024
8 checks passed
bartoszmajsak added a commit to bartoszmajsak/opendatahub-operator that referenced this pull request Jul 12, 2024
With the opendatahub-io#1052 refactoring, the order of features added to the Registry was
accidentally changed. It results in failing of metrics collection
feature which expects SMCP to be created first, but the creation runs
afterwards. The setup is eventually consistent, as the reconcile will
retry, so this not a bug per se, but results in unnecassary errors.

This fix ensures features are ordered as before and levarages
`.EnabledWhen` instead of wrapping features in `if`s.
openshift-merge-bot bot pushed a commit that referenced this pull request Jul 12, 2024
With the #1052 refactoring, the order of features added to the Registry was
accidentally changed. It results in failing of metrics collection
feature which expects SMCP to be created first, but the creation runs
afterwards. The setup is eventually consistent, as the reconcile will
retry, so this not a bug per se, but results in unnecassary errors.

This fix ensures features are ordered as before and levarages
`.EnabledWhen` instead of wrapping features in `if`s.
bartoszmajsak added a commit to bartoszmajsak/opendatahub-operator that referenced this pull request Jul 23, 2024
If the authorization provider namespace is not specified in the DSCI the
default is constructed to be `application-namespace-auth-provider`, e.g.
`opendatahub-auth-provider`.

With the opendatahub-io#1052 refactoring, the regression has been introduced where the value is
directly read from the spec instead of being dynamically constructed
based on the rule described above.

This is manifested with the following error, as the feature mistakenly
waits for pods across all namespaces (because of list option for
namespace being `corev1.NamespaceAll == ""`). This obviously rarely is
true, especially for large clusters.

```json
Failed applying [enable-proxy-injection-in-authorino-deployment]: 1 error occurred:
* client rate limiter Wait returned an error: context deadline exceeded
```

leading to failure of reconciling this feature.

The fix is to read the namespace from `FeatureData` instead, where the defaulting
logic is defined.
bartoszmajsak added a commit to bartoszmajsak/opendatahub-operator that referenced this pull request Jul 23, 2024
If the authorization provider namespace is not specified in the DSCI the
default is constructed to be `application-namespace-auth-provider`, e.g.
`opendatahub-auth-provider`.

With the opendatahub-io#1052 refactoring, the regression has been introduced where the value is
directly read from the spec instead of being dynamically constructed
based on the rule described above.

This is manifested with the following error, as the feature mistakenly
waits for pods across all namespaces (because of list option for
namespace being `corev1.NamespaceAll == ""`). This obviously rarely is
true, especially for large clusters.

```json
Failed applying [enable-proxy-injection-in-authorino-deployment]: 1 error occurred:
* client rate limiter Wait returned an error: context deadline exceeded
```

leading to failure of reconciling this feature.

The fix is to read the namespace from `FeatureData` instead, where the defaulting
logic is defined.

Fixes https://issues.redhat.com/browse/RHOAIENG-10268
openshift-merge-bot bot pushed a commit that referenced this pull request Jul 23, 2024
…e value (#1135)

* fix: fixes authz patch injection feature precondition

If the authorization provider namespace is not specified in the DSCI the
default is constructed to be `application-namespace-auth-provider`, e.g.
`opendatahub-auth-provider`.

With the #1052 refactoring, the regression has been introduced where the value is
directly read from the spec instead of being dynamically constructed
based on the rule described above.

This is manifested with the following error, as the feature mistakenly
waits for pods across all namespaces (because of list option for
namespace being `corev1.NamespaceAll == ""`). This obviously rarely is
true, especially for large clusters.

```json
Failed applying [enable-proxy-injection-in-authorino-deployment]: 1 error occurred:
* client rate limiter Wait returned an error: context deadline exceeded
```

leading to failure of reconciling this feature.

The fix is to read the namespace from `FeatureData` instead, where the defaulting
logic is defined.

Fixes https://issues.redhat.com/browse/RHOAIENG-10268

* Update controllers/dscinitialization/servicemesh_setup.go

Co-authored-by: Wen Zhou <[email protected]>

---------

Co-authored-by: Wen Zhou <[email protected]>
VaishnaviHire pushed a commit to VaishnaviHire/opendatahub-operator that referenced this pull request Jul 24, 2024
Feature Struct Improvements

- Eliminates the `.Spec` field, eliminating a single point of coupling with
  various domain structs used across the project.
- Introduces a generic map to store keys relevant to a given feature,
  which are utilized in templates and other functions.

Feature Builder Changes

- Renamed few functions to better reflect their intent
    - entry builder function `feature.CreateFeature` becomes
  `feature.Define`
   - Load() becomes Create()
- `.WithData` builder function serves as an entry point to define the
  contents of a given feature. This chain method allows adding key-values
  to the feature's context. These values are later used in templates and
  can also be accessed in pre/post conditions and for programmatic
  resource creation.

Additional Changes

- Simplifies and decouples the use of `FeatureHandler`. It is no longer
  necessary to patss it to the Feature builder to group features together.
- Introduces a new `FeatureRegistry` interface, allowing convenient
  addition of feature sets to the handler via the `FeatureProvider` function.
- Introduces a convention for defining `FeatureData` for specific parts of
  the platform (e.g., Serverless or Service Mesh setup). This approach
  enhances readability and promotes the reuse of commonly used data entries.
- Adds a `README.md` file providing a high-level overview of the `Feature DSL`.

(cherry picked from commit 973ff74)
VaishnaviHire pushed a commit to VaishnaviHire/opendatahub-operator that referenced this pull request Jul 24, 2024
…o#1118)

With the opendatahub-io#1052 refactoring, the order of features added to the Registry was
accidentally changed. It results in failing of metrics collection
feature which expects SMCP to be created first, but the creation runs
afterwards. The setup is eventually consistent, as the reconcile will
retry, so this not a bug per se, but results in unnecassary errors.

This fix ensures features are ordered as before and levarages
`.EnabledWhen` instead of wrapping features in `if`s.

(cherry picked from commit d6f25c7)
VaishnaviHire pushed a commit to VaishnaviHire/opendatahub-operator that referenced this pull request Jul 24, 2024
…e value (opendatahub-io#1135)

* fix: fixes authz patch injection feature precondition

If the authorization provider namespace is not specified in the DSCI the
default is constructed to be `application-namespace-auth-provider`, e.g.
`opendatahub-auth-provider`.

With the opendatahub-io#1052 refactoring, the regression has been introduced where the value is
directly read from the spec instead of being dynamically constructed
based on the rule described above.

This is manifested with the following error, as the feature mistakenly
waits for pods across all namespaces (because of list option for
namespace being `corev1.NamespaceAll == ""`). This obviously rarely is
true, especially for large clusters.

```json
Failed applying [enable-proxy-injection-in-authorino-deployment]: 1 error occurred:
* client rate limiter Wait returned an error: context deadline exceeded
```

leading to failure of reconciling this feature.

The fix is to read the namespace from `FeatureData` instead, where the defaulting
logic is defined.

Fixes https://issues.redhat.com/browse/RHOAIENG-10268

* Update controllers/dscinitialization/servicemesh_setup.go

Co-authored-by: Wen Zhou <[email protected]>

---------

Co-authored-by: Wen Zhou <[email protected]>
(cherry picked from commit 7034768)
VaishnaviHire pushed a commit to VaishnaviHire/opendatahub-operator that referenced this pull request Jul 24, 2024
Feature Struct Improvements

- Eliminates the `.Spec` field, eliminating a single point of coupling with
  various domain structs used across the project.
- Introduces a generic map to store keys relevant to a given feature,
  which are utilized in templates and other functions.

Feature Builder Changes

- Renamed few functions to better reflect their intent
    - entry builder function `feature.CreateFeature` becomes
  `feature.Define`
   - Load() becomes Create()
- `.WithData` builder function serves as an entry point to define the
  contents of a given feature. This chain method allows adding key-values
  to the feature's context. These values are later used in templates and
  can also be accessed in pre/post conditions and for programmatic
  resource creation.

Additional Changes

- Simplifies and decouples the use of `FeatureHandler`. It is no longer
  necessary to patss it to the Feature builder to group features together.
- Introduces a new `FeatureRegistry` interface, allowing convenient
  addition of feature sets to the handler via the `FeatureProvider` function.
- Introduces a convention for defining `FeatureData` for specific parts of
  the platform (e.g., Serverless or Service Mesh setup). This approach
  enhances readability and promotes the reuse of commonly used data entries.
- Adds a `README.md` file providing a high-level overview of the `Feature DSL`.

(cherry picked from commit 973ff74)
VaishnaviHire pushed a commit to VaishnaviHire/opendatahub-operator that referenced this pull request Jul 24, 2024
…o#1118)

With the opendatahub-io#1052 refactoring, the order of features added to the Registry was
accidentally changed. It results in failing of metrics collection
feature which expects SMCP to be created first, but the creation runs
afterwards. The setup is eventually consistent, as the reconcile will
retry, so this not a bug per se, but results in unnecassary errors.

This fix ensures features are ordered as before and levarages
`.EnabledWhen` instead of wrapping features in `if`s.

(cherry picked from commit d6f25c7)
VaishnaviHire pushed a commit to VaishnaviHire/opendatahub-operator that referenced this pull request Jul 24, 2024
…e value (opendatahub-io#1135)

* fix: fixes authz patch injection feature precondition

If the authorization provider namespace is not specified in the DSCI the
default is constructed to be `application-namespace-auth-provider`, e.g.
`opendatahub-auth-provider`.

With the opendatahub-io#1052 refactoring, the regression has been introduced where the value is
directly read from the spec instead of being dynamically constructed
based on the rule described above.

This is manifested with the following error, as the feature mistakenly
waits for pods across all namespaces (because of list option for
namespace being `corev1.NamespaceAll == ""`). This obviously rarely is
true, especially for large clusters.

```json
Failed applying [enable-proxy-injection-in-authorino-deployment]: 1 error occurred:
* client rate limiter Wait returned an error: context deadline exceeded
```

leading to failure of reconciling this feature.

The fix is to read the namespace from `FeatureData` instead, where the defaulting
logic is defined.

Fixes https://issues.redhat.com/browse/RHOAIENG-10268

* Update controllers/dscinitialization/servicemesh_setup.go

Co-authored-by: Wen Zhou <[email protected]>

---------

Co-authored-by: Wen Zhou <[email protected]>
(cherry picked from commit 7034768)
@bartoszmajsak bartoszmajsak deleted the feature-spec-container branch July 30, 2024 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

6 participants