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: moves config map creation logic from Feature pkg #909

Conversation

bartoszmajsak
Copy link
Contributor

@bartoszmajsak bartoszmajsak commented Mar 8, 2024

Refactors cluster resource creation funcs

Cleans up structure of the resource creation logic by:

  • adding CreateConfigMap func to be used in service-mesh refs logic
  • moving MetaOption and related object "decorators" to a single place (meta.go)
  • introducing WithOwnerReference decorator
  • opening up secret creation function for optional meta decorators

Splits service mesh-related config map creation

In addition, it reuses generic purpose CreateConfigMap func introduced as part of this PR.

Adds config map creation test

and moves the suite to the package.

The aim of this commit is to clean up structure of the resource creation
logic by:

- adding CreateConfigMap func to be used in service-mesh refs logic
- moving MetaOption and related object "decorators" to a single place
(meta.go)
- introducing WithOwnerReference decorator
- opening up secret creation function for optional meta decorators
In addition it reuses generic purpose CreateConfigMap func introduced
as part of this PR.
We have missed a few tests because of that...
and moved the suite to the package.
@openshift-ci openshift-ci bot requested review from ruivieira and tarilabs March 8, 2024 21:23
@bartoszmajsak bartoszmajsak requested review from israel-hdez and aslakknutsen and removed request for ruivieira and tarilabs March 8, 2024 21:23
@bartoszmajsak
Copy link
Contributor Author

Might be good to merge #907 first :)

@bartoszmajsak bartoszmajsak changed the title move config map from feature chore: moves config map creation logic from Feature pkg Mar 8, 2024
Makefile Outdated
@@ -321,7 +321,7 @@ toolbox: ## Create a toolbox instance with the proper Golang and Operator SDK ve
toolbox create opendatahub-toolbox --image localhost/opendatahub-toolbox:latest

# Run tests.
TEST_SRC=./controllers/... ./tests/integration/features/... ./pkg/feature/...
TEST_SRC=./controllers/... ./tests/integration/features/... ./pkg/...
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will be gone when #907 is merged.

@@ -110,7 +110,7 @@ func configureServiceMeshFeatures() feature.FeaturesProvider {
PostConditions(
feature.WaitForPodsToBeReady(serviceMeshSpec.ControlPlane.Namespace),
func(f *feature.Feature) error {
return feature.WaitForPodsToBeReady(f.Spec.Auth.Namespace)(f)
return feature.WaitForPodsToBeReady(handler.DSCInitializationSpec.ServiceMesh.Auth.Namespace)(f)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No need to use feature struct here.

@bartoszmajsak
Copy link
Contributor Author

/retest

}
}

func WithLabels(labels ...string) MetaOptions {
Copy link
Contributor

Choose a reason for hiding this comment

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

WithAnnotations is probably a good candidate here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, but we can add it when we need it. Or do you think we should just provide it?

}
}

func WithLabels(labels ...string) MetaOptions {
Copy link
Contributor

Choose a reason for hiding this comment

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

In some other package probably, but maybe a higher level version as well for unified labeling; WithUnifedLables(dsci, dsc, component)?

"config-regs",
"default",
data,
cluster.WithLabels("apps.kubernetes.io/part-of", "opendatahub"),
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the DSL bit of it but could we incorporate the same type of functions into the Feature.Manifest processing for instance, so that we have 1 API here not two depending on what you're doing?

feature.Create()..
  .Metadata(WithLabels(), WithOwnerRef())
  .Manifests()..  

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 like the idea. Can we do it as subsequent PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

of course

pkg/feature/servicemesh/resources.go Outdated Show resolved Hide resolved
Copy link
Contributor

@israel-hdez israel-hdez left a comment

Choose a reason for hiding this comment

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

OK, this makes sense to me, as ConfigMap creation code looks misplaced in the Feature.

@@ -88,7 +88,7 @@ func configureServiceMeshFeatures() feature.FeaturesProvider {

cfgMapErr := feature.CreateFeature("mesh-shared-configmap").
For(handler).
WithResources(servicemesh.ConfigMaps).
WithResources(servicemesh.MeshRefs, servicemesh.AuthRefs).
Copy link
Contributor

Choose a reason for hiding this comment

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

I hope this resolves Wen feedback in a previos PR about that this ConfigMaps wasn't really a good name :-)

@@ -88,7 +88,7 @@ func configureServiceMeshFeatures() feature.FeaturesProvider {

cfgMapErr := feature.CreateFeature("mesh-shared-configmap").
For(handler).
WithResources(servicemesh.ConfigMaps).
WithResources(servicemesh.MeshRefs, servicemesh.AuthRefs).
Copy link
Contributor

Choose a reason for hiding this comment

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

@bartoszmajsak should we perhaps consider splitting servicemesh and auth?

@openshift-ci openshift-ci bot removed the lgtm label Mar 11, 2024
Copy link

openshift-ci bot commented Mar 12, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: aslakknutsen, israel-hdez
Once this PR has been reviewed and has the lgtm label, please assign zdtsw for approval. For more information see the Kubernetes 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

@bartoszmajsak bartoszmajsak merged commit 623285e into opendatahub-io:incubation Mar 12, 2024
6 of 7 checks passed
@bartoszmajsak bartoszmajsak deleted the move-config-map-from-feature branch March 12, 2024 15:06
zdtsw referenced this pull request in zdtsw-forking/rhods-operator Mar 15, 2024
…-services#909)

#### Refactors cluster resource creation funcs

Cleans up the structure of the resource creation logic by:
  
  - adding CreateConfigMap func to be used in service-mesh refs logic
  - moving MetaOption and related object "decorators" to a single place (`meta.go`)
  - introducing `WithOwnerReference` decorator
  - opening up secret creation function for optional meta decorators

#### Splits service mesh-related config map creation

In addition, it reuses the generic purpose `CreateConfigMap` func introduced as part of this PR.

#### Adds config map creation test

and moves the suite to the package.
VaishnaviHire pushed a commit to VaishnaviHire/opendatahub-operator that referenced this pull request Mar 19, 2024
…io#909)

#### Refactors cluster resource creation funcs

Cleans up the structure of the resource creation logic by:

  - adding CreateConfigMap func to be used in service-mesh refs logic
  - moving MetaOption and related object "decorators" to a single place (`meta.go`)
  - introducing `WithOwnerReference` decorator
  - opening up secret creation function for optional meta decorators

#### Splits service mesh-related config map creation

In addition, it reuses the generic purpose `CreateConfigMap` func introduced as part of this PR.

#### Adds config map creation test

and moves the suite to the package.

(cherry picked from commit d7074eb)
@bartoszmajsak bartoszmajsak mentioned this pull request Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants