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: remove the need of passing rest config #895

Merged

Conversation

bartoszmajsak
Copy link
Contributor

@bartoszmajsak bartoszmajsak commented Mar 6, 2024

As we are already using client.Client interface we do not have to instantiate other typed clients to e.g. list resources using their own
funcs. Generic client.Client is sufficient for these needs.

Additionally this change adds ctx propogation for these calls.

By removing reference to non-existing func. This function has been in
use outside of this component.
As we are already using client.Client interface we do not have to
instantiate other typed clients to e.g. list resources using their own
funcs. Generic client.Client is sufficient for these needs.

Additionally this change adds ctx propogation for these calls.
@openshift-ci openshift-ci bot requested review from gmfrasca and ykaliuta March 6, 2024 14:56
@bartoszmajsak bartoszmajsak requested review from zdtsw and removed request for gmfrasca March 6, 2024 14:57
@@ -37,7 +37,6 @@ can be found [here](https://github.com/opendatahub-io/opendatahub-operator/tree/
GetManagementState() operatorv1.ManagementState
SetImageParamsMap(imageMap map[string]string) map[string]string
UpdatePrometheusConfig(cli client.Client, enable bool, component string) error
WaitForDeploymentAvailable(ctx context.Context, r *rest.Config, c string, n string, i int, t int) error
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would challenge the usefulness of keeping this code snippet if it's not automatically sourced. It's been already outdated (but looks way nicer this way! simple!)

Copy link
Member

Choose a reason for hiding this comment

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

there is a ticket on update "docs"
this should be part of that task.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does it mean it will be automated? For example asciidoc with Antora toolchain makes it a breeze.

Copy link
Member

Choose a reason for hiding this comment

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

i think so :D

@bartoszmajsak bartoszmajsak changed the title remove rest cfg chore: remove the need of passing rest cofnig Mar 6, 2024
@bartoszmajsak bartoszmajsak changed the title chore: remove the need of passing rest cofnig chore: remove the need of passing rest config Mar 6, 2024
@@ -169,7 +167,7 @@ func (d *Dashboard) ReconcileComponent(ctx context.Context,
if platform == deploy.ManagedRhods {
if enabled {
// first check if the service is up, so prometheus won't fire alerts when it is just startup
if err := monitoring.WaitForDeploymentAvailable(ctx, resConf, ComponentNameSupported, dscispec.ApplicationsNamespace, 20, 3); err != nil {
if err := monitoring.WaitForDeploymentAvailable(ctx, cli, ComponentNameSupported, dscispec.ApplicationsNamespace, 20, 3); err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

20, 3 - do we really need that configurable for every component? I would assume most just copy-paste the values. Can't we const it and simplify this function?

@@ -80,7 +79,7 @@ type ManifestsConfig struct {
}

type ComponentInterface interface {
ReconcileComponent(ctx context.Context, cli client.Client, resConf *rest.Config, owner metav1.Object, DSCISpec *dsciv1.DSCInitializationSpec, currentComponentStatus bool) error
ReconcileComponent(ctx context.Context, cli client.Client, owner metav1.Object, DSCISpec *dsciv1.DSCInitializationSpec, currentComponentStatus bool) error
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I find it a bit puzzling to have currentComponentStatus bool as a contract to all components where it's only used for one component and one case and others just _ ignore it. I think we should simplify it.

Copy link
Member

Choose a reason for hiding this comment

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

i agree with you.
it was a bit hard to understand when it was introduced, we can have a follow up PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We came up with the fix with @aslakknutsen - see #896

@zdtsw zdtsw added the incubating Added to issues that are currently incubating in ODH label Mar 8, 2024
func getClusterServiceVersion(ctx context.Context, c client.Client, watchNameSpace string) (*ofapi.ClusterServiceVersion, error) {
clusterServiceVersionList := &ofapi.ClusterServiceVersionList{}
if err := c.List(ctx, clusterServiceVersionList, client.InNamespace(watchNameSpace)); err != nil {
return nil, fmt.Errorf("failed listign cluster service versions: %w", err)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return nil, fmt.Errorf("failed listign cluster service versions: %w", err)
return nil, fmt.Errorf("failed listing ClusterServiceVersions: %w", err)

@openshift-ci openshift-ci bot added the lgtm label Mar 8, 2024
Copy link

openshift-ci bot commented Mar 8, 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-ci openshift-ci bot added the approved label Mar 8, 2024
@VaishnaviHire VaishnaviHire merged commit ca7fa98 into opendatahub-io:incubation Mar 8, 2024
6 of 7 checks passed
zdtsw pushed a commit to zdtsw-forking/rhods-operator that referenced this pull request Mar 15, 2024
* chore: fixes ComponentInterface docs

By removing reference to non-existing func. This function has been in
use outside of this component.

* fix: removes rest config

As we are already using client.Client interface we do not have to
instantiate other typed clients to e.g. list resources using their own
funcs. Generic client.Client is sufficient for these needs.

Additionally this change adds ctx propogation for these calls.
VaishnaviHire pushed a commit to VaishnaviHire/opendatahub-operator that referenced this pull request Mar 19, 2024
* chore: fixes ComponentInterface docs

By removing reference to non-existing func. This function has been in
use outside of this component.

* fix: removes rest config

As we are already using client.Client interface we do not have to
instantiate other typed clients to e.g. list resources using their own
funcs. Generic client.Client is sufficient for these needs.

Additionally this change adds ctx propogation for these calls.

(cherry picked from commit 2ec8958)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved incubating Added to issues that are currently incubating in ODH lgtm odh-2.9
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants