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

chore(feature-tracker): simplifies struct handling #1092

Conversation

bartoszmajsak
Copy link
Contributor

@bartoszmajsak bartoszmajsak commented Jul 2, 2024

Description

Refactors FeatureTracker-related functions to plain functions instead of Feature receivers. This eliminates unnecessary coupling with the Feature struct.

How Has This Been Tested?

make + manual with simple KServe setup (which I hope can be part of an automated test suite one day...)

Screenshot or short clip

Merge criteria

  • You have read the contributors guide.
  • Commit messages are meaningful - have a clear and concise summary and detailed explanation of what was changed and why.
  • Pull Request contains a description of the solution, a link to the JIRA issue, and to any dependent or related Pull Request.
  • 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

Refactors FeatureTracker related functions to plain functions
instead of Feature receivers This improves separation of concerns
and eliminates unnecessary coupling.

Revised the FeatureTracker attachment process to the owning Features.
@openshift-ci openshift-ci bot requested review from grdryn and Sara4994 July 2, 2024 11:48
if tracker, errGet := getFeatureTracker(ctx, f); client.IgnoreNotFound(errGet) != nil {
return errGet
} else {
associatedTracker = tracker
Copy link
Member

Choose a reason for hiding this comment

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

is there any possibility that after associatedTracker = tracker associatedTracker is nil?
otherwise why not just
return client.IgnoreNotFound(f.Client.Delete(ctx, tracker))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In theory, it can be not found in L62, and so it is nil. We do not propagate error on 404 (client.IgnoreNotFound(errGet)), but we handle this case by simply skipping the Delete operation. Calling Delete on nil will panic.

As to part if this can happen at runtime - under the hood it boils down to which operations are performed directly against kube-apiserver and which are taken from the local cache. I think it can be stale and might lead to such situation, so I thought it's better to handle it explicitly.

@openshift-ci openshift-ci bot removed the lgtm label Jul 3, 2024
@openshift-ci openshift-ci bot added the lgtm label Jul 3, 2024
Copy link

openshift-ci bot commented Jul 3, 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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 2d2a56a into opendatahub-io:incubation Jul 3, 2024
8 checks passed
VaishnaviHire pushed a commit to VaishnaviHire/opendatahub-operator that referenced this pull request Jul 24, 2024
* chore(feature-tracker): simplifies struct handling

Refactors FeatureTracker related functions to plain functions
instead of Feature receivers This improves separation of concerns
and eliminates unnecessary coupling.

Revised the FeatureTracker attachment process to the owning Features.

* fix: merge conflict

(cherry picked from commit 2d2a56a)
VaishnaviHire pushed a commit to VaishnaviHire/opendatahub-operator that referenced this pull request Jul 24, 2024
* chore(feature-tracker): simplifies struct handling

Refactors FeatureTracker related functions to plain functions
instead of Feature receivers This improves separation of concerns
and eliminates unnecessary coupling.

Revised the FeatureTracker attachment process to the owning Features.

* fix: merge conflict

(cherry picked from commit 2d2a56a)
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.

2 participants