Refactor new workflow name for clarity

Signed-off-by: Rafael Chacon <rafael@slack-corp.com>
This commit is contained in:
Rafael Chacon 2018-08-24 16:09:40 -07:00
Родитель f57e338c94
Коммит 0206024bff
3 изменённых файлов: 64 добавлений и 55 удалений

Просмотреть файл

@ -1,24 +1,20 @@
/*
Copyright 2017 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
Copyright 2018 The Vitess Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreedto in writing, software
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreedto in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package keyspaceresharding
package reshardingworkflowgen
// Package resharding contains a workflow for automatic horizontal resharding.
// The workflow assumes that there are as many vtworker processes running as source shards.
// Plus, these vtworker processes must be reachable via RPC.
// This package contains a workflow to generate horizontal resharding workflows
// that automatically discovers available overlapping shards to split/merge.
import (
"flag"
@ -44,7 +40,7 @@ import (
const (
codeVersion = 1
keyspaceReshardingFactoryName = "keyspace_resharding"
keyspaceReshardingFactoryName = "hr_workflow_gen"
phaseName = "create_workflows"
)
@ -151,7 +147,7 @@ func (*Factory) Instantiate(m *workflow.Manager, w *workflowpb.Workflow, rootNod
taskID := fmt.Sprintf("%s/%v", phaseName, i)
task := hw.checkpoint.Tasks[taskID]
taskUINode := &workflow.Node{
Name: fmt.Sprintf("Create workflow to split shards %v to %v", task.Attributes["source_shards"], task.Attributes["destination_shards"]),
Name: fmt.Sprintf("Split shards %v to %v workflow creation", task.Attributes["source_shards"], task.Attributes["destination_shards"]),
PathName: fmt.Sprintf("%v", i),
}
phaseNode.Children = append(phaseNode.Children, taskUINode)
@ -307,7 +303,6 @@ func (hw *keyspaceResharding) runWorkflow() error {
"-destination_shards=" + task.Attributes["destination_shards"],
"-phase_enable_approvals=" + hw.phaseEnableApprovalsParam,
}
log.Infof("These are the params %v", horizontalReshardingParams)
phaseID := path.Dir(task.Id)
phaseUINode, err := hw.rootUINode.GetChildByPath(phaseID)
if err != nil {
@ -320,6 +315,8 @@ func (hw *keyspaceResharding) runWorkflow() error {
return err
}
hw.setUIMessage(phaseUINode, fmt.Sprintf("Created shard split workflow: %v for source shards: %v.", uuid, task.Attributes["source_shards"]))
workflowCmd := "WorkflowCreate " + strings.Join(horizontalReshardingParams, " ")
hw.setUIMessage(phaseUINode, fmt.Sprintf("Created workflow with the following params: %v", workflowCmd))
if !skipStart {
err = hw.manager.Start(ctx, uuid)
if err != nil {

Просмотреть файл

@ -62,47 +62,51 @@ export class NewWorkflowFlags {
this.flags['horizontal_resharding_enable_approvals_migrate_serving_types'].namedPositional = 'migrate_serving_types';
this.flags['horizontal_resharding_phase_enable_approvals'] = new HorizontalReshardingPhaseEnableApprovalFlag(17, 'horizontal_resharding_phase_enable_approvals', 'horizontal_resharding');
this.flags['horizontal_resharding_phase_enable_approvals'] = new HorizontalReshardingPhaseEnableApprovalFlag(17, 'horizontal_resharding_phase_enable_approvals');
this.flags['horizontal_resharding_phase_enable_approvals'].positional = true;
this.flags['horizontal_resharding_phase_enable_approvals'].namedPositional = 'phase_enable_approvals';
// // Flags for keyspace resharding workflow.
this.flags['keyspace_resharding_keyspace'] = new HorizontalReshardingKeyspaceFlag(18, 'keyspace_resharding_keyspace', 'keyspace_resharding');
this.flags['keyspace_resharding_keyspace'].positional = true;
this.flags['keyspace_resharding_keyspace'].namedPositional = 'keyspace';
this.flags['keyspace_resharding_vtworkers'] = new HorizontalReshardingVtworkerFlag(19, 'keyspace_resharding_vtworkers', 'keyspace_resharding');
this.flags['keyspace_resharding_vtworkers'].positional = true;
this.flags['keyspace_resharding_vtworkers'].namedPositional = 'vtworkers';
this.flags['keyspace_resharding_split_cmd'] = new SplitCloneCommand(20, 'keyspace_resharding_split_cmd', 'keyspace_resharding');
this.flags['keyspace_resharding_split_cmd'].positional = true;
this.flags['keyspace_resharding_split_cmd'].namedPositional = 'split_cmd';
this.flags['keyspace_resharding_split_diff_dest_tablet_type'] = new SplitDiffTabletType(21, 'keyspace_resharding_split_diff_dest_tablet_type', 'keyspace_resharding');
this.flags['keyspace_resharding_split_diff_dest_tablet_type'].positional = true;
this.flags['keyspace_resharding_split_diff_dest_tablet_type'].namedPositional = 'split_diff_dest_tablet_type';
this.flags['keyspace_resharding_min_healthy_rdonly_tablets'] = new HorizontalReshardingMinHealthyRdonlyTablets(22, 'keyspace_resharding_min_healthy_rdonly_tablets', 'keyspace_resharding');
this.flags['keyspace_resharding_min_healthy_rdonly_tablets'].positional = true;
this.flags['keyspace_resharding_min_healthy_rdonly_tablets'].namedPositional = 'min_healthy_rdonly_tablets';
this.flags['keyspace_resharding_enable_approvals_copy_schema'] = new HorizontalReshardingEnableApprovalsFlag(23, 'keyspace_resharding_enable_approvals_copy_schema', 'Copy Schema enable approvals', 'keyspace_resharding');
this.flags['keyspace_resharding_enable_approvals_copy_schema'].positional = true;
this.flags['keyspace_resharding_enable_approvals_copy_schema'].namedPositional = 'copy_schema';
this.flags['keyspace_resharding_enable_approvals_clone'] = new HorizontalReshardingEnableApprovalsFlag(24, 'keyspace_resharding_enable_approvals_clone', 'Clone enable approvals', 'keyspace_resharding');
this.flags['keyspace_resharding_enable_approvals_clone'].positional = true;
this.flags['keyspace_resharding_enable_approvals_clone'].namedPositional = 'clone';
this.flags['keyspace_resharding_enable_approvals_wait_filtered_replication'] = new HorizontalReshardingEnableApprovalsFlag(25, 'keyspace_resharding_enable_approvals_wait_filtered_replication', 'Wait filtered replication enable approvals', 'keyspace_resharding');
this.flags['keyspace_resharding_enable_approvals_wait_filtered_replication'].positional = true;
this.flags['keyspace_resharding_enable_approvals_wait_filtered_replication'].namedPositional = 'wait_filtered_replication';
this.flags['keyspace_resharding_enable_approvals_diff'] = new HorizontalReshardingEnableApprovalsFlag(26, 'keyspace_resharding_enable_approvals_diff', 'Diff enable approvals', 'keyspace_resharding');
this.flags['keyspace_resharding_enable_approvals_diff'].positional = true;
this.flags['keyspace_resharding_enable_approvals_diff'].namedPositional = 'diff';
this.flags['keyspace_resharding_enable_approvals_migrate_serving_types'] = new HorizontalReshardingEnableApprovalsFlag(27, 'keyspace_resharding_enable_approvals_migrate_serving_types', 'Migrate serving types enable approvals', 'keyspace_resharding');
this.flags['keyspace_resharding_enable_approvals_migrate_serving_types'].positional = true;
this.flags['keyspace_resharding_enable_approvals_migrate_serving_types'].namedPositional = 'migrate_serving_types';
this.flags['hr_workflow_gen_keyspace'] = new HorizontalReshardingKeyspaceFlag(18, 'hr_workflow_gen_keyspace', 'hr_workflow_gen');
this.flags['hr_workflow_gen_keyspace'].positional = true;
this.flags['hr_workflow_gen_keyspace'].namedPositional = 'keyspace';
this.flags['hr_workflow_gen_vtworkers'] = new HorizontalReshardingVtworkerFlag(19, 'hr_workflow_gen_vtworkers', 'hr_workflow_gen');
this.flags['hr_workflow_gen_vtworkers'].positional = true;
this.flags['hr_workflow_gen_vtworkers'].namedPositional = 'vtworkers';
this.flags['hr_workflow_gen_split_cmd'] = new SplitCloneCommand(20, 'hr_workflow_gen_split_cmd', 'hr_workflow_gen');
this.flags['hr_workflow_gen_split_cmd'].positional = true;
this.flags['hr_workflow_gen_split_cmd'].namedPositional = 'split_cmd';
this.flags['hr_workflow_gen_split_diff_dest_tablet_type'] = new SplitDiffTabletType(21, 'hr_workflow_gen_split_diff_dest_tablet_type', 'hr_workflow_gen');
this.flags['hr_workflow_gen_split_diff_dest_tablet_type'].positional = true;
this.flags['hr_workflow_gen_split_diff_dest_tablet_type'].namedPositional = 'split_diff_dest_tablet_type';
this.flags['hr_workflow_gen_min_healthy_rdonly_tablets'] = new HorizontalReshardingMinHealthyRdonlyTablets(22, 'hr_workflow_gen_min_healthy_rdonly_tablets', 'hr_workflow_gen');
this.flags['hr_workflow_gen_min_healthy_rdonly_tablets'].positional = true;
this.flags['hr_workflow_gen_min_healthy_rdonly_tablets'].namedPositional = 'min_healthy_rdonly_tablets';
this.flags['hr_workflow_gen_enable_approvals_copy_schema'] = new HorizontalReshardingEnableApprovalsFlag(23, 'hr_workflow_gen_enable_approvals_copy_schema', 'Copy Schema enable approvals', 'hr_workflow_gen');
this.flags['hr_workflow_gen_enable_approvals_copy_schema'].positional = true;
this.flags['hr_workflow_gen_enable_approvals_copy_schema'].namedPositional = 'copy_schema';
this.flags['hr_workflow_gen_enable_approvals_clone'] = new HorizontalReshardingEnableApprovalsFlag(24, 'hr_workflow_gen_enable_approvals_clone', 'Clone enable approvals', 'hr_workflow_gen');
this.flags['hr_workflow_gen_enable_approvals_clone'].positional = true;
this.flags['hr_workflow_gen_enable_approvals_clone'].namedPositional = 'clone';
this.flags['hr_workflow_gen_enable_approvals_wait_filtered_replication'] = new HorizontalReshardingEnableApprovalsFlag(25, 'hr_workflow_gen_enable_approvals_wait_filtered_replication', 'Wait filtered replication enable approvals', 'hr_workflow_gen');
this.flags['hr_workflow_gen_enable_approvals_wait_filtered_replication'].positional = true;
this.flags['hr_workflow_gen_enable_approvals_wait_filtered_replication'].namedPositional = 'wait_filtered_replication';
this.flags['hr_workflow_gen_enable_approvals_diff'] = new HorizontalReshardingEnableApprovalsFlag(26, 'hr_workflow_gen_enable_approvals_diff', 'Diff enable approvals', 'hr_workflow_gen');
this.flags['hr_workflow_gen_enable_approvals_diff'].positional = true;
this.flags['hr_workflow_gen_enable_approvals_diff'].namedPositional = 'diff';
this.flags['hr_workflow_gen_enable_approvals_migrate_serving_types'] = new HorizontalReshardingEnableApprovalsFlag(27, 'hr_workflow_gen_enable_approvals_migrate_serving_types', 'Migrate serving types enable approvals', 'hr_workflow_gen');
this.flags['hr_workflow_gen_enable_approvals_migrate_serving_types'].positional = true;
this.flags['hr_workflow_gen_enable_approvals_migrate_serving_types'].namedPositional = 'migrate_serving_types';
this.flags['keyspace_resharding_phase_enable_approvals'] = new HorizontalReshardingPhaseEnableApprovalFlag(28, 'keyspace_resharding_phase_enable_approvals', 'keyspace_resharding');
this.flags['keyspace_resharding_phase_enable_approvals'].positional = true;
this.flags['keyspace_resharding_phase_enable_approvals'].namedPositional = 'phase_enable_approvals';
this.flags['hr_workflow_gen_phase_enable_approvals'] = new HorizontalReshardingPhaseEnableApprovalFlag(28, 'hr_workflow_gen_phase_enable_approvals');
this.flags['hr_workflow_gen_phase_enable_approvals'].positional = true;
this.flags['hr_workflow_gen_phase_enable_approvals'].namedPositional = 'phase_enable_approvals';
this.flags['hr_workflow_gen_skip_start_workflows'] = new ReshardingWorkflowGenSkipStartFlag(30, 'hr_workflow_gen_skip_start_workflows');
this.flags['hr_workflow_gen_skip_start_workflows'].positional = true;
this.flags['hr_workflow_gen_skip_start_workflows'].namedPositional = 'skip_start_workflows';
}
}
@ -146,10 +150,10 @@ export class FactoryNameFlag extends DropDownFlag {
constructor(position: number, id: string, workflows) {
super(position, id, 'Factory Name', 'Specifies the type of workflow to create.', '');
let options = [];
if (workflows.keyspace_resharding) {
if (workflows.hr_workflow_gen) {
options.push({
label: 'Keyspace resharding',
value: 'keyspace_resharding'
label: 'Horizontal Resharding Workflow Generator',
value: 'hr_workflow_gen'
});
}
@ -183,11 +187,17 @@ export class FactoryNameFlag extends DropDownFlag {
}
export class SkipStartFlag extends CheckBoxFlag {
constructor(position: number, id: string, value= false) {
constructor(position: number, id: string, value= true) {
super(position, id, 'Skip Start', 'Create the workflow, but don\'t start it.', value);
}
}
export class ReshardingWorkflowGenSkipStartFlag extends CheckBoxFlag {
constructor(position: number, id: string, value= true) {
super(position, id, 'Skip Start Workflows', 'Skip start in all horizontal resharding workflows to be created.', value);
}
}
export class SleepDurationFlag extends InputFlag {
constructor(position: number, id: string, value= '') {
super(position, id, 'Sleep Duration', 'Time to sleep for, in seconds.', value);
@ -239,9 +249,9 @@ export class HorizontalReshardingVtworkerFlag extends InputFlag {
export class HorizontalReshardingPhaseEnableApprovalFlag extends InputFlag {
// This is a hidden flag
constructor(position: number, id: string, setDisplayOn: string, value= '') {
constructor(position: number, id: string, value= '') {
super(position, id, 'phase enable approval', '', value);
this.setDisplayOn('factory_name', setDisplayOn);
this.setDisplayOn('factory_name', '__hidden__');
}
}
export class HorizontalReshardingMinHealthyRdonlyTablets extends InputFlag {

Просмотреть файл

@ -241,7 +241,7 @@ export class WorkflowListComponent implements OnDestroy, OnInit {
workflowPrepareReshardingFlags(newFlags) {
let factoryName = newFlags['factory_name']['value']
if (factoryName === 'horizontal_resharding' || factoryName == 'keyspace_resharding') {
if (factoryName === 'horizontal_resharding' || factoryName == 'hr_workflow_gen') {
let phaseEnableApprovalCheckBoxNames = [
'enable_approvals_copy_schema',
'enable_approvals_clone',
@ -257,6 +257,8 @@ export class WorkflowListComponent implements OnDestroy, OnInit {
if(newFlags[factoryName + '_' + phaseName]['value']) {
phaseEnableApprovals.push(...phaseEnableApprovalNames[i]);
}
// We don't want this flag to show up in the getArgs
delete newFlags[factoryName + '_' + phaseName];
}
newFlags[factoryName + '_phase_enable_approvals']['value'] = phaseEnableApprovals.join(',');
}