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 and simplify the config and script template #8902

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

Conversation

leon-inf
Copy link
Contributor

@leon-inf leon-inf commented Feb 8, 2025

No description provided.

@leon-inf leon-inf added this to the Release 1.0.0 milestone Feb 8, 2025
Copy link

codecov bot commented Feb 8, 2025

Codecov Report

Attention: Patch coverage is 69.10198% with 203 lines in your changes missing coverage. Please review.

Project coverage is 60.57%. Comparing base (af6fa75) to head (5c32c2f).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...pps/component/transformer_component_reconfigure.go 70.64% 45 Missing and 19 partials ⚠️
pkg/kbagent/service/reconfigure.go 51.38% 30 Missing and 5 partials ⚠️
...s/apps/component/transformer_component_template.go 81.54% 21 Missing and 10 partials ⚠️
pkg/controller/component/kbagent.go 73.63% 20 Missing and 9 partials ⚠️
pkg/controller/lifecycle/kbagent.go 0.00% 15 Missing ⚠️
pkg/controller/lifecycle/lfa_replica.go 0.00% 15 Missing ⚠️
pkg/controller/lifecycle/lfa_udf.go 0.00% 6 Missing ⚠️
pkg/controller/component/synthesize_component.go 89.47% 3 Missing and 1 partial ⚠️
pkg/kbagent/service/action.go 40.00% 2 Missing and 1 partial ⚠️
pkg/controller/lifecycle/errors.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8902      +/-   ##
==========================================
+ Coverage   60.19%   60.57%   +0.37%     
==========================================
  Files         389      394       +5     
  Lines       47089    47754     +665     
==========================================
+ Hits        28345    28925     +580     
- Misses      16020    16075      +55     
- Partials     2724     2754      +30     
Flag Coverage Δ
unittests 60.57% <69.10%> (+0.37%) ⬆️

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.

@github-actions github-actions bot added the size/XXL Denotes a PR that changes 1000+ lines. label Feb 8, 2025
@leon-inf leon-inf force-pushed the support/config-template branch 4 times, most recently from 408e76f to dae465e Compare February 11, 2025 07:00
@leon-inf leon-inf force-pushed the support/config-template branch from dae465e to 3178cd4 Compare February 11, 2025 09:04

files := strings.Split(updated, ",")
for _, item := range files {
tokens := strings.Split(item, ":")
Copy link
Contributor

Choose a reason for hiding this comment

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

Characters related to parameters may be used with caution. Some special parameters can be any character, such as backup-related parameters:

archive_command = 'if [ $(date +%H%M) -eq 1200 ]; then rm -rf /home/postgres/pgdata/pgroot/arcwal/$(date -d"yesterday" +%Y%m%d); fi; mkdir -p /home/postgres/pgdata/pgroot/arcwal/$(date +%Y%m%d) && gzip -kqc %p > /home/postgres/pgdata/pgroot/arcwal/$(date +%Y%m%d)/%f.gz && sync /home/postgres/pgdata/pgroot/arcwal/$(date +%Y%m%d)/%f.gz'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is handled is the file name, not the file content.

@leon-inf leon-inf force-pushed the support/config-template branch 6 times, most recently from a88f318 to 066ce2c Compare February 17, 2025 10:59
@leon-inf leon-inf force-pushed the support/config-template branch from 066ce2c to 4e48aa5 Compare February 18, 2025 04:17
@leon-inf leon-inf marked this pull request as ready for review February 18, 2025 04:35
@leon-inf leon-inf requested review from Y-Rookie and a team as code owners February 18, 2025 04:35
AddAnnotationsInMap(synthesizedComp.StaticAnnotations).
SetData(data).
GetObject()
return obj, nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

Need to set Component Ownership & Finalizer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@leon-inf leon-inf force-pushed the support/config-template branch from 487127a to d4c5993 Compare February 18, 2025 09:54
@apecloud-bot apecloud-bot added the approved PR Approved Test label Feb 19, 2025
//
// - KB_CONFIG_FILES_CREATED: file1,file2...
// - KB_CONFIG_FILES_REMOVED: file1,file2...
// - KB_CONFIG_FILES_UPDATED: file1:checksum1,file2:checksum2...
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 file1@checksum1,...

or the implementation of templateFileChanges() should be fixed.

//
// - KB_CONFIG_FILES_CREATED: file1,file2...
// - KB_CONFIG_FILES_REMOVED: file1,file2...
// - KB_CONFIG_FILES_UPDATED: file1:checksum1,file2:checksum2...
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

for _, container := range synthesizedComp.PodSpec.Containers {
for _, mount := range container.VolumeMounts {
if mount.Name == volName {
mountPath = mount.MountPath
Copy link
Contributor

Choose a reason for hiding this comment

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

what if there are multiple containers mounting the volume with different mount paths?

if len(tpl.Namespace) > 0 {
return tpl.Namespace
}
return "default"
Copy link
Contributor

Choose a reason for hiding this comment

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

how about defaulting to the namespace of the cluster?

absPath := t.absoluteFilePath(transCtx, tplName, item)
if len(absPath) > 0 {
checksum := sha256.Sum256([]byte(pData[item]))
items[2] = append(items[2], fmt.Sprintf("%s@%x", absPath, checksum))
Copy link
Contributor

Choose a reason for hiding this comment

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

"@" => ":"

return s.handleExecAction(ctx, req, action)
}

func (s *actionService) precondition(ctx context.Context, req *proto.ActionRequest) error {
return reconfigure(ctx, req)
Copy link
Contributor

Choose a reason for hiding this comment

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

the name is poor, maybe checkReconfigure.

}

func checkLocalFileUpToDate(file, checksum string) error {
content, err := os.ReadFile(file)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand how it works, it seems that the volume is not mounted to the kbagent container, so kbagent could not see the files.


files := strings.Split(updated, ",")
for _, item := range files {
tokens := strings.Split(item, ":")
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

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

Successfully merging this pull request may close these issues.

5 participants