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

[WIP] [FlyteCTL] enable kubectl-like configuration from multiple files #6292

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

machichima
Copy link
Contributor

@machichima machichima commented Mar 1, 2025

Tracking issue

#6237

Why are the changes needed?

flytectl update workflow-execution-config can only accept one --attrFile at a time now, which is not convenient especially over multiple projects / domains.

What changes were proposed in this pull request?

Three different configuration ways are added (analogous to how kubectl works):

  • Setting multiple config files with multiple --attrFile (e.g. flytectl update workflow-execution-config --attrFile file1.yaml --attrFile file2.yaml
  • Pass a directory path to --attrFile (e.g. flytectl update workflow-execution-config --attrFile folder/

How was this patch tested?

Labels

Please add one or more of the following labels to categorize your PR:

  • added: For new features.
  • changed: For changes in existing functionality.
  • deprecated: For soon-to-be-removed features.
  • removed: For features being removed.
  • fixed: For any bug fixed.
  • security: In case of vulnerabilities

This is important to improve the readability of release notes.

Setup process

Screenshots

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Related PRs

Docs link

Summary by Bito

This PR enhances flytectl's workflow execution configuration by enabling multiple attribute file configurations, similar to kubectl. It refactors the configuration structure and command logic to handle file lists instead of single files, simplifies the update process, and improves error messaging. The changes include revised flag definitions, updated data types, and improved test cases.

Unit tests added: True

Estimated effort to review (1-5, lower is better): 4

@flyte-bot
Copy link
Collaborator

flyte-bot commented Mar 1, 2025

Code Review Agent Run #38bf67

Actionable Suggestions - 1
  • flytectl/cmd/config/subcommand/workflowexecutionconfig/attrupdateconfig_flags.go - 1
    • Type mismatch between flag and struct definition · Line 53-53
Review Details
  • Files reviewed - 5 · Commit Range: b8a0b09..2f38c33
    • flytectl/cmd/config/subcommand/workflowexecutionconfig/attrupdateconfig_flags.go
    • flytectl/cmd/config/subcommand/workflowexecutionconfig/update_config.go
    • flytectl/cmd/testutils/test_utils.go
    • flytectl/cmd/update/matchable_workflow_execution_config.go
    • flytectl/cmd/update/matchable_workflow_execution_config_test.go
  • Files skipped - 0
  • Tools
    • Golangci-lint (Linter) - ✖︎ Failed
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

AI Code Review powered by Bito Logo

Copy link

codecov bot commented Mar 1, 2025

Codecov Report

Attention: Patch coverage is 15.90909% with 74 lines in your changes missing coverage. Please review.

Project coverage is 58.42%. Comparing base (ff7e79f) to head (62def7b).
Report is 15 commits behind head on master.

Files with missing lines Patch % Lines
flytectl/cmd/update/update.go 15.68% 43 Missing ⚠️
flytectl/cmd/config/attrupdateconfig_flags.go 22.22% 21 Missing ⚠️
flytectl/cmd/testutils/test_utils.go 0.00% 10 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #6292       +/-   ##
===========================================
+ Coverage   33.82%   58.42%   +24.60%     
===========================================
  Files        1329      938      -391     
  Lines      147808    71150    -76658     
===========================================
- Hits        49992    41571     -8421     
+ Misses      92974    26427    -66547     
+ Partials     4842     3152     -1690     
Flag Coverage Δ
unittests-datacatalog 59.06% <ø> (+11.05%) ⬆️
unittests-flyteadmin 56.30% <ø> (+6.20%) ⬆️
unittests-flytecopilot 30.99% <ø> (ø)
unittests-flytectl 63.98% <15.90%> (+5.89%) ⬆️
unittests-flyteidl 76.12% <ø> (+69.33%) ⬆️
unittests-flyteplugins 61.00% <ø> (+11.98%) ⬆️
unittests-flytepropeller 54.79% <ø> (+18.26%) ⬆️
unittests-flytestdlib 64.04% <ø> (+13.66%) ⬆️

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.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@flyte-bot
Copy link
Collaborator

flyte-bot commented Mar 1, 2025

Changelist by Bito

This pull request implements the following key changes.

Key Change Files Impacted
New Feature - New Flag Configuration Implementation

attrupdateconfig_flags.go - Introduces new flag configuration for attribute update handling.

update_config.go - Defines the AttrUpdateConfig structure to support multiple attribute files.

Testing - Enhanced Flag Configuration Tests

attrupdateconfig_flags_test.go - Contains tests verifying flag set behaviors and proper config decoding.

test_utils.go - Adds utility for verifying specific log counts to support improved test validations.

Other Improvements - Miscellaneous Code Commentary and Minor Updates

updater.go - Updates comment to reflect usage of the new mockery-v2 tool.

matchable_workflow_execution_config.go - Adds a comment clarifying the processing of each attribute file.

Feature Improvement - Refactored Update Command for Multi-file Support

update.go - Refactors command creation and execution logic to support multiple attribute files with enhanced parsing and subcommand execution.

@@ -50,7 +50,7 @@ func (AttrUpdateConfig) mustMarshalJSON(v json.Marshaler) string {
// flags is json-name.json-sub-name... etc.
func (cfg AttrUpdateConfig) GetPFlagSet(prefix string) *pflag.FlagSet {
cmdFlags := pflag.NewFlagSet("AttrUpdateConfig", pflag.ExitOnError)
cmdFlags.StringVar(&DefaultUpdateConfig.AttrFile, fmt.Sprintf("%v%v", prefix, "attrFile"), DefaultUpdateConfig.AttrFile, "attribute file name to be used for updating attribute for the resource type.")
cmdFlags.StringSliceVar(&DefaultUpdateConfig.AttrFile, fmt.Sprintf("%v%v", prefix, "attrFile"), DefaultUpdateConfig.AttrFile, "attribute file name to be used for updating attribute for the resource type.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Type mismatch between flag and struct definition

The type of AttrFile is being changed from string to []string (via StringSliceVar), but the struct definition in the related files still defines it as string. This will cause type mismatch issues when accessing this field.

Code suggestion
Check the AI-generated fix before applying
Suggested change
cmdFlags.StringSliceVar(&DefaultUpdateConfig.AttrFile, fmt.Sprintf("%v%v", prefix, "attrFile"), DefaultUpdateConfig.AttrFile, "attribute file name to be used for updating attribute for the resource type.")
cmdFlags.StringVar(&DefaultUpdateConfig.AttrFile, fmt.Sprintf("%v%v", prefix, "attrFile"), DefaultUpdateConfig.AttrFile, "attribute file name to be used for updating attribute for the resource type.")

Code Review Run #38bf67


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

Signed-off-by: machichima <[email protected]>
@flyte-bot
Copy link
Collaborator

flyte-bot commented Mar 1, 2025

Code Review Agent Run #7699d3

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 2f38c33..f43ae50
    • flytectl/cmd/config/subcommand/workflowexecutionconfig/attrupdateconfig_flags.go
    • flytectl/cmd/config/subcommand/workflowexecutionconfig/attrupdateconfig_flags_test.go
  • Files skipped - 0
  • Tools
    • Golangci-lint (Linter) - ✖︎ Failed
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

AI Code Review powered by Bito Logo

@flyte-bot
Copy link
Collaborator

flyte-bot commented Mar 10, 2025

Code Review Agent Run #988f93

Actionable Suggestions - 1
  • flytectl/cmd/config/attrupdateconfig_flags.go - 1
    • Possible pointer dereferencing issue in elemValueOrNil · Line 22-22
Review Details
  • Files reviewed - 10 · Commit Range: f43ae50..62def7b
    • flytectl/cmd/config/attrupdateconfig_flags.go
    • flytectl/cmd/config/attrupdateconfig_flags_test.go
    • flytectl/cmd/config/subcommand/workflowexecutionconfig/attrupdateconfig_flags.go
    • flytectl/cmd/config/subcommand/workflowexecutionconfig/attrupdateconfig_flags_test.go
    • flytectl/cmd/config/subcommand/workflowexecutionconfig/update_config.go
    • flytectl/cmd/config/update_config.go
    • flytectl/cmd/update/interfaces/updater.go
    • flytectl/cmd/update/matchable_workflow_execution_config.go
    • flytectl/cmd/update/matchable_workflow_execution_config_test.go
    • flytectl/cmd/update/update.go
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

AI Code Review powered by Bito Logo

if reflect.ValueOf(v).IsNil() {
return reflect.Zero(t.Elem()).Interface()
} else {
return reflect.ValueOf(v).Interface()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Possible pointer dereferencing issue in elemValueOrNil

The else branch in elemValueOrNil returns reflect.ValueOf(v).Interface() which doesn't dereference the pointer. This will return the pointer itself rather than the value it points to. Consider using reflect.ValueOf(v).Elem().Interface() to properly dereference the pointer.

Code suggestion
Check the AI-generated fix before applying
Suggested change
return reflect.ValueOf(v).Interface()
return reflect.ValueOf(v).Elem().Interface()

Code Review Run #988f93


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants