ssp-operator icon indicating copy to clipboard operation
ssp-operator copied to clipboard

feat: allow external DataImportCron to manage DataSources

Open akrejcir opened this issue 10 months ago • 9 comments

What this PR does / why we need it: The DataSources created by SSP can now be managed by a DataImportCron that was not created by SSP.

Which issue(s) this PR fixes: Fixes: https://issues.redhat.com/browse/CNV-49658

Release note:

DataSources created by SSP can now be managed by external DataImportCrons.

akrejcir avatar Feb 04 '25 16:02 akrejcir

Skipping CI for Draft Pull Request. If you want CI signal for your change, please convert it to an actual PR. You can still manually trigger a test run with /test all

openshift-ci[bot] avatar Feb 04 '25 16:02 openshift-ci[bot]

@sourcery-ai review

ksimon1 avatar Apr 11 '25 09:04 ksimon1

Reviewer's Guide by Sourcery

This pull request introduces changes to allow DataSources created by SSP to be managed by external DataImportCrons. The changes include modifications to the reconcile logic to prevent reconciliation of DataSources managed by external DataImportCrons, added tests to verify the new functionality, and error handling to prevent conflicts between DataImportCron templates and external DataImportCrons.

Sequence diagram for dataSourceAutoUpdateEnabled with external DataImportCron

sequenceDiagram
  participant DS as DataSource
  participant K8sClient as Kubernetes Client
  participant DIC as DataImportCron

  DS->>K8sClient: Get DataSource
  K8sClient-->>DS: Returns DataSource with dataImportCronLabel
  DS->>DS: Check if DataImportCron template exists
  alt DataImportCron template does not exist
    DS->>DS: externalCronExists = true
    DS->>DS: Return reconcileDataSource = false, reconcileDataImportCron = false
  else DataImportCron template exists
    DS->>DS: externalCronExists = false
  end

Sequence diagram for dataSourceAutoUpdateEnabled with DataImportCron template

sequenceDiagram
  participant DS as DataSource
  participant K8sClient as Kubernetes Client
  participant DIC as DataImportCron

  DS->>K8sClient: Get DataSource
  K8sClient-->>DS: Returns DataSource
  DS->>DS: Check if DataImportCron template exists
  alt DataImportCron template exists
    DS->>DS: Check if external DataImportCron exists
    alt external DataImportCron exists
      DS->>DS: Return error
    else external DataImportCron does not exist
      DS->>DS: Check if DataSource uses golden image PVC
      alt DataSource uses golden image PVC
        DS->>DS: Return reconcileDataSource = true, reconcileDataImportCron = false
      else DataSource does not use golden image PVC
        DS->>DS: Return reconcileDataSource = false, reconcileDataImportCron = true
      end
    end
  else DataImportCron template does not exist
    DS->>DS: Return reconcileDataSource = true, reconcileDataImportCron = false
  end

File-Level Changes

Change Details Files
Added tests to verify that DataSources are not reconciled when managed by an external DataImportCron.
  • Added a new context for testing with an external DataImportCron.
  • Created an external DataImportCron and DataSource before each test.
  • Added assertions to ensure the DataSource is not reconciled when managed by an external DataImportCron.
  • Added a test case to verify that reconciliation fails if a DataImportCron template is defined for a DataSource managed by an external DataImportCron.
tests/dataSources_test.go
Modified the reconcile logic to prevent reconciliation of DataSources managed by external DataImportCrons and to handle conflicts between DataImportCron templates and external DataImportCrons.
  • Added a new autoUpdateEnabledResult_RENAME struct to encapsulate the results of the dataSourceAutoUpdateEnabled function.
  • Modified the dataSourceAutoUpdateEnabled function to check for the existence of an external DataImportCron and prevent reconciliation if one exists.
  • Added error handling to prevent reconciliation if a DataImportCron template is defined for a DataSource managed by an external DataImportCron.
  • Modified the reconcileDataSource function to only update the DataSource spec if it is not managed by an external DataImportCron.
internal/operands/data-sources/reconcile.go
Added unit tests for the data-sources operand to verify the changes related to external DataImportCrons.
  • Added a new context for testing with an external DataImportCron.
  • Created an external DataImportCron and DataSource before each test.
  • Added a test case to verify that the DataSource is not reconciled when managed by an external DataImportCron.
  • Added a test case to verify that reconciliation fails if a DataImportCron template is defined for a DataSource managed by an external DataImportCron.
internal/operands/data-sources/reconcile_test.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an issue from a review comment by replying to it. You can also reply to a review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull request title to generate a title at any time. You can also comment @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in the pull request body to generate a PR summary at any time exactly where you want it. You can also comment @sourcery-ai summary on the pull request to (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the pull request to resolve all Sourcery comments. Useful if you've already addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull request to dismiss all existing Sourcery reviews. Especially useful if you want to start fresh with a new review - don't forget to comment @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

  • Contact our support team for questions or feedback.
  • Visit our documentation for detailed guides and information.
  • Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.

sourcery-ai[bot] avatar Apr 11 '25 09:04 sourcery-ai[bot]

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Once this PR has been reviewed and has the lgtm label, please assign 0xfelix for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

kubevirt-bot avatar May 13 '25 12:05 kubevirt-bot

/cc @0xFelix @jcanocan @codingben

akrejcir avatar May 13 '25 12:05 akrejcir

@akrejcir: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-upgrade-functests 9390d1138ffacb59adb76181ec58b206054d0450 link true /test e2e-upgrade-functests
ci/prow/e2e-functests 9390d1138ffacb59adb76181ec58b206054d0450 link true /test e2e-functests
ci/prow/e2e-single-node-functests 9390d1138ffacb59adb76181ec58b206054d0450 link true /test e2e-single-node-functests

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

openshift-ci[bot] avatar May 16 '25 17:05 openshift-ci[bot]

When external DataImporCron is created, it does not trigger SSP reconciliation, so the operator has no chance to react to it, and give management of DataSource to CDI. I need to rethink this.

/hold

akrejcir avatar May 19 '25 11:05 akrejcir

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

kubevirt-bot avatar Jul 03 '25 00:07 kubevirt-bot

The functionality implemented in this PR would be more difficult with the upcoming heterogeneous cluster functionality.

Closing this for now, we can reopen if we resume development.

/close

akrejcir avatar Jul 04 '25 12:07 akrejcir

@akrejcir: Closed this PR.

In response to this:

The functionality implemented in this PR would be more difficult with the upcoming heterogeneous cluster functionality.

Closing this for now, we can reopen if we resume development.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

kubevirt-bot avatar Jul 04 '25 12:07 kubevirt-bot