feat(tekton): enable kernel image sync step with configurable stages - #4940
feat(tekton): enable kernel image sync step with configurable stages#4940wuhuizuo wants to merge 1 commit into
Conversation
- Add stages param to request-kernel-image-sync step action - Enable request-kernel-image-sync step in tidbx delivery task
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
I have already done a preliminary review for you, and I hope to help you do a better job.
Summary
This PR enhances the Tekton CI pipeline by making the kernel image sync step configurable with respect to target stages (dev/prod), replacing hardcoded values with a flexible stages parameter. It also re-enables the kernel image sync step in the delivery task and cleans up an unused workspace. The implementation is straightforward and aligns well with the stated goals, improving maintainability and configurability. Overall, the changes are well-structured but there are a few critical and improvement points to consider.
Critical Issues
-
Parameter name mismatch in
request-kernel-image-sync.yaml- File/Line:
tekton/v1/step-actions/request-kernel-image-sync.yaml, lines ~24-29 and 41 - Issue: The env variable
TARGET_STAGESis set from$(params.stage), but the parameter is declared asstages(plural). This discrepancy will cause the env var to be empty, breaking the logic that loops over$TARGET_STAGES. - Fix: Change the env var assignment to use
$(params.stages):- name: TARGET_STAGES value: $(params.stages)
- File/Line:
-
Shell word-splitting for stages may cause issues
- File/Line:
request-kernel-image-sync.yaml, line ~43 - Issue: The
for stage in $TARGET_STAGES; dorelies on shell word splitting to iterate over stages. Ifstagescontains multiple stages separated by spaces (like"dev prod"), this works, but if the input has commas or extra spaces, it could break. Also, no trimming or validation is done. - Fix: Ideally, document the expected format strictly as space-separated, or use a more robust parsing approach (e.g., IFS manipulation). For example:
Or at least note in the param description the accepted format clearly.
IFS=' ' read -r -a stage_array <<< "$TARGET_STAGES" for stage in "${stage_array[@]}"; do ... done
- File/Line:
Code Improvements
-
Delivery task cleanup: remove large commented-out block instead of leaving it in the code
- File/Line:
pingcap-notify-to-deliver-images-to-cloud-tidbx.yaml, lines ~37-100 - Issue: The previously disabled
notify-to-sync-imagesstep is removed, but the entire script block is left commented out, making the file unnecessarily long and harder to read. - Fix: Since the step is removed, delete this entire commented-out script block to improve maintainability and readability.
- File/Line:
-
Explicitly document the accepted format for the
stagesparameter- File/Line:
request-kernel-image-sync.yaml, paramstagesdescription - Issue: The description says
"dev prod"or"dev"etc., but does not specify how strings are split or if other separators are accepted. Ambiguity can lead to misuse. - Fix: Update the description:
description: target stage(s), space-separated (e.g., "dev", "prod", or "dev prod")
- File/Line:
-
Add error handling in the script for invalid or empty stages
- File/Line:
request-kernel-image-sync.yaml, script section - Issue: If
TARGET_STAGESis empty or contains invalid stages, the script silently skips or fails without clear error messages. - Fix: Add a check early in the script:
if [ -z "$TARGET_STAGES" ]; then echo "Error: TARGET_STAGES is empty. Please provide at least one stage." exit 1 fi
- File/Line:
Best Practices
-
Testing coverage
- No evidence of added or updated tests covering the new
stagesparameter or the re-enabled step. Consider adding unit or integration tests validating the multi-stage sync behavior in Tekton pipelines.
- No evidence of added or updated tests covering the new
-
Documentation for the delivery task changes
- The PR description mentions removing the
notify-configworkspace, but the updated task YAML lacks any comments describing the removal or the rationale. Adding a short comment block about the removal helps future maintainers.
- The PR description mentions removing the
-
Consistent naming
- The param is named
stagesbut the env var isTARGET_STAGES. While not a bug, aligning naming conventions might improve clarity (e.g., useSTAGESorTARGET_STAGESconsistently in both declarations and usage).
- The param is named
Summary of actionable fixes:
# In tekton/v1/step-actions/request-kernel-image-sync.yaml
env:
- name: TARGET_STAGES
value: $(params.stages) # fix param name mismatch
parameters:
- name: stages
type: string
description: target stage(s), space-separated (e.g., "dev", "prod", or "dev prod")
default: "dev"
# In the script section, add:
if [ -z "$TARGET_STAGES" ]; then
echo "Error: TARGET_STAGES is empty. Please provide at least one stage."
exit 1
fi
# Optional: safer iteration over stages
IFS=' ' read -r -a stage_array <<< "$TARGET_STAGES"
for stage in "${stage_array[@]}"; do
...
done
# In tekton/v1/tasks/delivery/pingcap-notify-to-deliver-images-to-cloud-tidbx.yaml
# Remove the large commented-out notify-to-sync-images script block entirelyAddressing these will ensure the PR achieves its goal without runtime errors and improves maintainability.
What
stagesparam to therequest-kernel-image-syncstep action so target stages (dev/prod) are configurable instead of hardcoded.request-kernel-image-syncstep in thepingcap-notify-to-deliver-images-to-cloud-tidbxdelivery task and wire it to both dev and prod stages.notify-configworkspace from the delivery task.Related
Closes follow-up of #4936/#4938.