-
Notifications
You must be signed in to change notification settings - Fork 866
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
Feat: vela dry-run render results should be affected by override policy and deploy workflowstep #4815
Conversation
Codecov ReportBase: 61.21% // Head: 61.11% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #4815 +/- ##
==========================================
- Coverage 61.21% 61.11% -0.11%
==========================================
Files 307 308 +1
Lines 46350 46659 +309
==========================================
+ Hits 28375 28517 +142
- Misses 15063 15180 +117
- Partials 2912 2962 +50
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems you are making one copy of dryrun result for each override policy. There are some problems for that.
- Override policy can be used jointly. Therefore, it is possible to use multiple override policies concurrently in one deploy step. This scenario is not taken into consideration AFAIS.
- Declared override policy might not be used in workflow which means the dryrun result will not be actually deployed possibly.
- Override policy can be referenced from the standalone override policy outside the application, it depends on how workflow refers to it.
Generally, I think the PR is a good attempt to tackle the difficult dynamic dryrun problem. But I recommend to consider the workflow deploy more carefully. Otherwise, this feature will cause confusions for users (since they will get different results between dryrun and real runs).
pkg/appfile/dryrun/diff_test.go
Outdated
ctx := context.Background() | ||
Expect(k8sClient.Create(ctx, &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: "vela-system"}})).Should(Succeed()) | ||
//Expect(k8sClient.Create(ctx, &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: "vela-system"}})).Should(Succeed()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason for commenting them? You can remove them if they are not in use anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
already move to suite_test BeforeSuite function, my testcase needs this setting as well. Cannot guarantee which testcase invoked first, if both testcase have this setting, error show.
pkg/appfile/dryrun/diff_test.go
Outdated
@@ -19,13 +19,9 @@ package dryrun | |||
import ( | |||
"bytes" | |||
"context" | |||
"io/ioutil" | |||
|
|||
types2 "github.com/oam-dev/kubevela/apis/types" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest using apitypes to replace types2
references/cli/dryrun_test.go
Outdated
//webserviceYAML := strings.Replace(string(webservice), "{{ include \"systemDefinitionNamespace\" . }}", types.DefaultKubeVelaNS, 1) | ||
//wwd := v1beta1.ComponentDefinition{} | ||
//Expect(yaml.Unmarshal([]byte(webserviceYAML), &wwd)).Should(BeNil()) | ||
//Expect(k8sClient.Create(context.TODO(), &wwd)).Should(BeNil()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just remove them, I think.
references/cli/dryrun_test.go
Outdated
"sigs.k8s.io/yaml" | ||
|
||
"github.com/oam-dev/kubevela/pkg/utils/util" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this line and reformat the imports
pkg/appfile/dryrun/dryrun.go
Outdated
@@ -206,3 +210,33 @@ func (d *Option) PrintDryRun(buff *bytes.Buffer, appName string, comps []*types. | |||
} | |||
return nil | |||
} | |||
|
|||
// ExecuteDryRunWithOverridePolicy is similar to ExecuteDryRun function, but patch components with override policy | |||
func (d *Option) ExecuteDryRunWithOverridePolicy(ctx context.Context, application *v1beta1.Application) (map[string][]*types.ComponentManifest, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this function aware of deploy step?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not using offline, yes
For the 3rd point, could u share a example? |
|
pkg/appfile/dryrun/diff_test.go
Outdated
un.SetNamespace(ns) | ||
Expect(k8sClient.Create(context.Background(), un)).Should(Succeed()) | ||
} | ||
//applyFile := func(filename string, ns string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete the useless codes
pkg/appfile/dryrun/dryrun.go
Outdated
// ExecuteDryRunWithOverridePolicy is similar to ExecuteDryRun function, but patch components with override policy | ||
func (d *Option) ExecuteDryRunWithOverridePolicy(ctx context.Context, application *v1beta1.Application) (map[string][]*types.ComponentManifest, error) { | ||
|
||
compsForEechOverridePolicy := make(map[string][]*types.ComponentManifest) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is "Eech" one typo? I guess you want "Each".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am re-implementing this feature, btw, thanks for the head-ups
pkg/appfile/dryrun/dryrun.go
Outdated
|
||
compsForEechOverridePolicy := make(map[string][]*types.ComponentManifest) | ||
for _, policy := range application.Spec.Policies { | ||
if policy.Type == v1alpha1.OverridePolicyType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if policy.Type != v1alpha1.OverridePolicyType { continue }
/your main logic here/
Then you get less indent.
…policy and deploy workflowstep Signed-off-by: cezhang <c1zhang.dev@gmail.com>
@Somefive @wonderflow please help take a quick review on the new impl |
@cezhang What's the current behavior? Can you provide some examples that aligns with the design: #5184 (reply in thread) |
Great impl. Several suggestions for the change:
2~4 are recommended but we can leave their implementations for the future. |
…e orphan policy or workflow Signed-off-by: cezhang <c1zhang.dev@gmail.com>
Signed-off-by: cezhang <c1zhang.dev@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally LGTM after minor fixes, great job!
|
||
fileType := filepath.Ext(filename) | ||
switch fileType { | ||
case ".yaml", ".yml": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only one case for fileType?
switch fileType { | ||
case ".yaml", ".yml": | ||
// only support one object in one yaml file | ||
fileContent, err = yaml.YAMLToJSON(fileContent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we only support one object in one yaml file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, only handle one object per file for now(yaml format, actually). Plan to add more support from up coming improvement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, I strongly suggest supporting multiple files here. Although it is not necessary to be contained in this PR. And the multiple file loading could be moved into kubevela/pkg and be reused across various projects.
ApplicationFiles []string | ||
DefinitionFile string | ||
OfflineMode bool | ||
MergeOrphanFiles bool | ||
} | ||
|
||
// NewDryRunCommand creates `dry-run` command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add some explanation about the working mechanism.
- Add some examples commands.
- Dry Run with policy and workflow will only take
override/topology
policies anddeploy
workflow step into considerations. Other workflow step will be ignored.
Signed-off-by: cezhang <c1zhang.dev@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, great job!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, please fix the CI
Backport failed for Please cherry-pick the changes locally. git fetch origin release-1.7
git worktree add -d .worktree/backport-4815-to-release-1.7 origin/release-1.7
cd .worktree/backport-4815-to-release-1.7
git checkout -b backport-4815-to-release-1.7
ancref=$(git merge-base b71a8a353ac5a9357819b9a5bb55b4671feb8b05 a7cae693883b4fd24122611afe88d66c1cb12002)
git cherry-pick -x $ancref..a7cae693883b4fd24122611afe88d66c1cb12002 |
…cy and deploy workflowstep (kubevela#4815) * [Feature] vela dry-run render results should be affected by override policy and deploy workflowstep Signed-off-by: cezhang <c1zhang.dev@gmail.com> * multiple input files support; policy,workflow support; new flag: merge orphan policy or workflow Signed-off-by: cezhang <c1zhang.dev@gmail.com> * add more tests Signed-off-by: cezhang <c1zhang.dev@gmail.com> * fix comment issues Signed-off-by: cezhang <c1zhang.dev@gmail.com> * add tests Signed-off-by: cezhang <c1zhang.dev@gmail.com> * fix e2e Signed-off-by: cezhang <c1zhang.dev@gmail.com> * fix tests Signed-off-by: cezhang <c1zhang.dev@gmail.com> Signed-off-by: cezhang <c1zhang.dev@gmail.com>
…cy and deploy workflowstep (#4815) (#5314) * [Feature] vela dry-run render results should be affected by override policy and deploy workflowstep Signed-off-by: cezhang <c1zhang.dev@gmail.com> * multiple input files support; policy,workflow support; new flag: merge orphan policy or workflow Signed-off-by: cezhang <c1zhang.dev@gmail.com> * add more tests Signed-off-by: cezhang <c1zhang.dev@gmail.com> * fix comment issues Signed-off-by: cezhang <c1zhang.dev@gmail.com> * add tests Signed-off-by: cezhang <c1zhang.dev@gmail.com> * fix e2e Signed-off-by: cezhang <c1zhang.dev@gmail.com> * fix tests Signed-off-by: cezhang <c1zhang.dev@gmail.com> Signed-off-by: cezhang <c1zhang.dev@gmail.com> Signed-off-by: cezhang <c1zhang.dev@gmail.com> Co-authored-by: cezhang <c1zhang.dev@gmail.com>
…cy and deploy workflowstep (kubevela#4815) * [Feature] vela dry-run render results should be affected by override policy and deploy workflowstep Signed-off-by: cezhang <c1zhang.dev@gmail.com> * multiple input files support; policy,workflow support; new flag: merge orphan policy or workflow Signed-off-by: cezhang <c1zhang.dev@gmail.com> * add more tests Signed-off-by: cezhang <c1zhang.dev@gmail.com> * fix comment issues Signed-off-by: cezhang <c1zhang.dev@gmail.com> * add tests Signed-off-by: cezhang <c1zhang.dev@gmail.com> * fix e2e Signed-off-by: cezhang <c1zhang.dev@gmail.com> * fix tests Signed-off-by: cezhang <c1zhang.dev@gmail.com> Signed-off-by: cezhang <c1zhang.dev@gmail.com>
…cy and deploy workflowstep (kubevela#4815) * [Feature] vela dry-run render results should be affected by override policy and deploy workflowstep Signed-off-by: cezhang <c1zhang.dev@gmail.com> * multiple input files support; policy,workflow support; new flag: merge orphan policy or workflow Signed-off-by: cezhang <c1zhang.dev@gmail.com> * add more tests Signed-off-by: cezhang <c1zhang.dev@gmail.com> * fix comment issues Signed-off-by: cezhang <c1zhang.dev@gmail.com> * add tests Signed-off-by: cezhang <c1zhang.dev@gmail.com> * fix e2e Signed-off-by: cezhang <c1zhang.dev@gmail.com> * fix tests Signed-off-by: cezhang <c1zhang.dev@gmail.com> Signed-off-by: cezhang <c1zhang.dev@gmail.com>
Feat: vela dry-run render results should be affected by override policy and deploy workflowstep
Signed-off-by: cezhang c1zhang.dev@gmail.com
Description of your changes
Fixes #4410
I have:
make reviewable
to ensure this PR is ready for review.backport release-x.y
labels to auto-backport this PR if necessary.How has this code been tested
Special notes for your reviewer
Example:
Input application
Result from dryrun command considering override policy: