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

data_sources: Always run the operand #476

Merged
merged 1 commit into from
Jan 13, 2023

Conversation

lyarwood
Copy link
Member

@lyarwood lyarwood commented Jan 4, 2023

What this PR does / why we need it:

The operand itself deploys DataImportCrons defined by the SSP CR and DataSources based on the provided common-templates bundle. While the latter functionality should likely reside in the common-templates operand the DataImportCrons functionaility is useful in non-OpenShift environments alongside that of the common-instancetypes operand.

This change now ensures the data_sources operand runs on both OpenShift and non-OpenShift environments.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Release note:

The `data_sources` operand is now always deployed, regardless of the underlying environment being OpenShift or OKD.

The operand itself deploys DataImportCrons defined by the SSP CR and
DataSources based on the provided common-templates bundle. While the
latter functionality should likely reside in the common-templates
operand the DataImportCrons functionaility is useful in non-OpenShift
environments alongside that of the common-instancetypes operand.

This change now ensures the data_sources operand runs on both OpenShift
and non-OpenShift environments.

Signed-off-by: Lee Yarwood <lyarwood@redhat.com>
@kubevirt-bot kubevirt-bot added dco-signoff: yes Indicates the PR's author has DCO signed all their commits. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jan 4, 2023
@kubevirt-bot kubevirt-bot added release-note-none Denotes a PR that doesn't merit a release note. size/XS release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. release-note-none Denotes a PR that doesn't merit a release note. labels Jan 4, 2023
@lyarwood
Copy link
Member Author

lyarwood commented Jan 5, 2023

Actually I think I'm going to propose a different approach here with a new operand that isn't dependent on common-templates.

@lyarwood lyarwood closed this Jan 5, 2023
@lyarwood
Copy link
Member Author

Actually I think I'm going to propose a different approach here with a new operand that isn't dependent on common-templates.

Actually I'm not going to have time for that rework for a little while and I'd like to deploy the operand for upstream demos.

@lyarwood lyarwood reopened this Jan 12, 2023
@sonarcloud
Copy link

sonarcloud bot commented Jan 12, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@lyarwood
Copy link
Member Author

/retest

@0xFelix
Copy link
Member

0xFelix commented Jan 13, 2023

Other than that DataImportCronTemplates are defined below CommonTemplates in the SSP CR I don't see any dependency between the data_sources operand and common-templates. Is there really that much to rework here?

See https://github.com/kubevirt/ssp-operator/blob/master/api/v1beta1/ssp_types.go#L48

/approve

@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 0xFelix

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

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 13, 2023
@lyarwood
Copy link
Member Author

lyarwood commented Jan 13, 2023

Other than that DataImportCronTemplates are defined below CommonTemplates in the SSP CR I don't see any dependency between the data_sources operand and common-templates. Is there really that much to rework here?

See https://github.com/kubevirt/ssp-operator/blob/master/api/v1beta1/ssp_types.go#L48

/approve

Yeah apologies, it isn't obvious from the operand itself but we pass templatesBundle.DataSources into New() :

data_sources.New(templatesBundle.DataSources),

This is created by the following template-bundle code so it's not a direct dependency between the operands but definitely between the template functionality and the data_sources operand:

func extractDataSources(templates []templatev1.Template) ([]cdiv1beta1.DataSource, error) {
uniqueNames := map[string]struct{}{}
var dataSources []cdiv1beta1.DataSource
for i := range templates {
template := &templates[i]
usesDataSources, err := vmTemplateUsesSourceRef(template)
if err != nil {
return nil, err
}
if !usesDataSources {
continue
}
name, exists := findDataSourceName(template)
if !exists {
continue
}
namespace, exists := findDataSourceNamespace(template)
if !exists {
continue
}
namespacedName := namespace + "/" + name
if _, duplicateName := uniqueNames[namespacedName]; !duplicateName {
dataSources = append(dataSources, createDataSource(name, namespace))
uniqueNames[namespacedName] = struct{}{}
}
}
return dataSources, nil
}

I'd really like to understand the reasoning behind this and the creation of the DataSources outside of CDI, removing the latter if possible allowing us to break this linkage between the two.

@0xFelix
Copy link
Member

0xFelix commented Jan 13, 2023

/lgtm

Then let's enable the operand for now as is and do the clean up in a separate PR.

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 13, 2023
@kubevirt-bot kubevirt-bot merged commit 6e2394e into kubevirt:master Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants