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: refactor 1.0 parameter api #8441

Open
wants to merge 52 commits into
base: main
Choose a base branch
from

Conversation

sophon-zt
Copy link
Contributor

No description provided.

@sophon-zt sophon-zt linked an issue Nov 11, 2024 that may be closed by this pull request
@github-actions github-actions bot added the size/XXL Denotes a PR that changes 1000+ lines. label Nov 11, 2024
@@ -143,6 +143,8 @@ func (r *ClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
&clusterServiceTransformer{},
// handle the restore for cluster
&clusterRestoreTransformer{},
// rerender parameters after v-scale and h-scale
&clusterParametersTransformer{},
Copy link
Contributor

Choose a reason for hiding this comment

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

It should be moved out of the cluster controller since the apps package has no knowledge about the parameters and doesn't depend on it too.

return nil
}

configRender, paramsDefs, err := intctrlutil.ResolveCmpdParametersDefs(transCtx, transCtx.Client, transCtx.CompDef)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto

@@ -318,7 +318,7 @@ type ComponentDefinitionSpec struct {
// +listType=map
// +listMapKey=name
// +optional
Configs []ComponentConfigSpec `json:"configs,omitempty"`
Configs []ComponentTemplateSpec `json:"configs,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

The ComponentConfigSpec could be deleted from this package?

// Specifies the initialization parameters.
//
// +optional
InitParameters ComponentParameters `json:"initParameters,omitempty"`
Copy link
Contributor

@leon-inf leon-inf Nov 12, 2024

Choose a reason for hiding this comment

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

It should be added into spec.components.configs, and be used as init values to render config templates.

@sophon-zt sophon-zt force-pushed the support/improvement-10-config-related-api-issue8298 branch from 7455b95 to cd36433 Compare November 18, 2024 07:46
@sophon-zt sophon-zt marked this pull request as ready for review November 18, 2024 07:47
Copy link

codecov bot commented Nov 19, 2024

Codecov Report

Attention: Patch coverage is 65.76577% with 532 lines in your changes missing coverage. Please review.

Project coverage is 59.61%. Comparing base (33bb8c8) to head (58a161a).

Files with missing lines Patch % Lines
controllers/parameters/policy_util.go 10.52% 85 Missing ⚠️
controllers/parameters/reconcile_task.go 69.77% 47 Missing and 21 partials ⚠️
.../parameters/componentdrivenparameter_controller.go 53.57% 53 Missing and 12 partials ⚠️
...ollers/parameters/componentparameter_controller.go 54.54% 43 Missing and 12 partials ⚠️
controllers/parameters/reconfigure_controller.go 10.52% 51 Missing ⚠️
controllers/parameters/config_util.go 51.47% 29 Missing and 4 partials ⚠️
controllers/parameters/parameter_util.go 82.55% 21 Missing and 9 partials ⚠️
...lers/parameters/parametersdefinition_controller.go 67.74% 21 Missing and 9 partials ⚠️
pkg/configuration/config_manager/handler_util.go 61.03% 23 Missing and 7 partials ⚠️
controllers/parameters/parameter_controller.go 85.07% 16 Missing and 4 partials ⚠️
... and 12 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8441      +/-   ##
==========================================
- Coverage   60.34%   59.61%   -0.73%     
==========================================
  Files         357      361       +4     
  Lines       42589    42132     -457     
==========================================
- Hits        25699    25116     -583     
- Misses      14566    14735     +169     
+ Partials     2324     2281      -43     
Flag Coverage Δ
unittests 59.61% <65.76%> (-0.73%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@sophon-zt sophon-zt force-pushed the support/improvement-10-config-related-api-issue8298 branch from 6ac1501 to 115978a Compare November 20, 2024 03:33
@@ -146,6 +147,7 @@ func init() {
model.AddScheme(snapshotv1beta1.AddToScheme)
model.AddScheme(extensionsv1alpha1.AddToScheme)
model.AddScheme(workloadsv1.AddToScheme)
model.AddScheme(parametersv1alpha1.AddToScheme)
Copy link
Contributor

Choose a reason for hiding this comment

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

From the perspective of their functionality and relationships, apps should no longer depend on parameters.

@@ -161,6 +162,7 @@ func kindsForDelete() ([]client.ObjectList, []client.ObjectList) {
&corev1.SecretList{},
&dpv1alpha1.BackupPolicyList{},
&dpv1alpha1.BackupScheduleList{},
&parametersv1alpha1.ComponentParameterList{},
Copy link
Contributor

Choose a reason for hiding this comment

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

Should delete parameter resources in parameters controller.

@@ -216,15 +217,15 @@ func (t *componentStatusTransformer) isAllConfigSynced(transCtx *componentTransf

configurationKey := client.ObjectKey{
Copy link
Contributor

Choose a reason for hiding this comment

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

This condition for component status should be removed, since there are no more custom resources to maintain for config/script templates.

var configmaps []*corev1.ConfigMap
cachedObjs := resolveRerenderDependOnObjects(dag)
for _, tpls := range [][]appsv1.ComponentTemplateSpec{synthesizeComp.ScriptTemplates, synthesizeComp.ConfigTemplates} {
objects, err := configctrl.RenderTemplate(reconcileCtx, cluster, synthesizeComp, comp, cachedObjs, tpls)
Copy link
Contributor

Choose a reason for hiding this comment

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

Cloud you move the rendering out of the configuration and define it in a separate package, so that both apps and configuration can use it independently?

Copy link
Contributor

Choose a reason for hiding this comment

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

And, when rendering config/script templates, simply replace the variables defined by the API, no need to provide unexposed objects and built-in functions.

return nil
}

return configctrl.BuildReloadActionContainer(reconcileCtx, cluster, synthesizeComp, transCtx.CompDef, configmaps)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be switched to the reconfigure action.

Copy link
Contributor Author

@sophon-zt sophon-zt Nov 20, 2024

Choose a reason for hiding this comment

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

OK, this will be implemented in another pr: merge reloadAction into kbagent.

@sophon-zt sophon-zt force-pushed the support/improvement-10-config-related-api-issue8298 branch from 9c98199 to 949fa18 Compare November 21, 2024 04:38
@@ -378,3 +383,5 @@ const (
// FailedComponentPhase indicates that there are some pods of the component not in a 'Running' state.
FailedComponentPhase ComponentPhase = "Failed"
)

type ComponentParameters map[string]*string
Copy link
Contributor

Choose a reason for hiding this comment

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

// Better with {name:, value:}, perhaps a parameter will come from a secret or config map?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XXL Denotes a PR that changes 1000+ lines.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Improvement] 1.0 config-related api
3 participants