Refactored CronWorkflow message.

- Moved Parameters to it's own field
- Using WorkflowTemplate directly, instead of nesting it inside of
WorkflowExecution.
- Updated related code to use new structure.
This commit is contained in:
Aleksandr Melnikov
2020-03-30 11:59:13 -07:00
parent 9045b1a3eb
commit 59cbf7d15e
6 changed files with 133 additions and 122 deletions

View File

@@ -349,18 +349,19 @@ func (m *ListCronWorkflowsResponse) GetTotalCount() int32 {
}
type CronWorkflow struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Schedule string `protobuf:"bytes,2,opt,name=schedule,proto3" json:"schedule,omitempty"`
Timezone string `protobuf:"bytes,3,opt,name=timezone,proto3" json:"timezone,omitempty"`
Suspend bool `protobuf:"varint,4,opt,name=suspend,proto3" json:"suspend,omitempty"`
ConcurrencyPolicy string `protobuf:"bytes,5,opt,name=concurrencyPolicy,proto3" json:"concurrencyPolicy,omitempty"`
StartingDeadlineSeconds int64 `protobuf:"varint,6,opt,name=startingDeadlineSeconds,proto3" json:"startingDeadlineSeconds,omitempty"`
SuccessfulJobsHistoryLimit int32 `protobuf:"varint,7,opt,name=successfulJobsHistoryLimit,proto3" json:"successfulJobsHistoryLimit,omitempty"`
FailedJobsHistoryLimit int32 `protobuf:"varint,8,opt,name=failedJobsHistoryLimit,proto3" json:"failedJobsHistoryLimit,omitempty"`
WorkflowExecution *WorkflowExecution `protobuf:"bytes,9,opt,name=workflowExecution,proto3" json:"workflowExecution,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Schedule string `protobuf:"bytes,2,opt,name=schedule,proto3" json:"schedule,omitempty"`
Timezone string `protobuf:"bytes,3,opt,name=timezone,proto3" json:"timezone,omitempty"`
Suspend bool `protobuf:"varint,4,opt,name=suspend,proto3" json:"suspend,omitempty"`
ConcurrencyPolicy string `protobuf:"bytes,5,opt,name=concurrencyPolicy,proto3" json:"concurrencyPolicy,omitempty"`
StartingDeadlineSeconds int64 `protobuf:"varint,6,opt,name=startingDeadlineSeconds,proto3" json:"startingDeadlineSeconds,omitempty"`
SuccessfulJobsHistoryLimit int32 `protobuf:"varint,7,opt,name=successfulJobsHistoryLimit,proto3" json:"successfulJobsHistoryLimit,omitempty"`
FailedJobsHistoryLimit int32 `protobuf:"varint,8,opt,name=failedJobsHistoryLimit,proto3" json:"failedJobsHistoryLimit,omitempty"`
Parameters []*WorkflowExecutionParameter `protobuf:"bytes,9,rep,name=parameters,proto3" json:"parameters,omitempty"`
WorkflowTemplate *WorkflowTemplate `protobuf:"bytes,10,opt,name=workflowTemplate,proto3" json:"workflowTemplate,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CronWorkflow) Reset() { *m = CronWorkflow{} }
@@ -444,9 +445,16 @@ func (m *CronWorkflow) GetFailedJobsHistoryLimit() int32 {
return 0
}
func (m *CronWorkflow) GetWorkflowExecution() *WorkflowExecution {
func (m *CronWorkflow) GetParameters() []*WorkflowExecutionParameter {
if m != nil {
return m.WorkflowExecution
return m.Parameters
}
return nil
}
func (m *CronWorkflow) GetWorkflowTemplate() *WorkflowTemplate {
if m != nil {
return m.WorkflowTemplate
}
return nil
}
@@ -466,52 +474,53 @@ func init() {
}
var fileDescriptor_989cccaad551a50c = []byte{
// 708 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0x41, 0x4f, 0x1b, 0x39,
0x14, 0xc7, 0x35, 0x84, 0x40, 0xf2, 0x96, 0xdd, 0x55, 0xcc, 0x6e, 0x18, 0x86, 0x08, 0x65, 0xe7,
0xb2, 0xd1, 0x6a, 0x95, 0x00, 0xab, 0x85, 0xdd, 0x56, 0x45, 0xaa, 0x00, 0xb5, 0x42, 0x1c, 0xd0,
0x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a, 0xf0, 0xeb, 0x58, 0xcb, 0x24, 0x6b,
0xc6, 0x6b, 0x72, 0x23, 0x9d, 0x04, 0xb2, 0x6d, 0x40, 0x36, 0xc8, 0x0f, 0x82, 0x90, 0x37, 0x16,
0x94, 0x32, 0xf5, 0x4f, 0x2a, 0xc6, 0x60, 0x4a, 0x07, 0x72, 0xd6, 0x27, 0xaa, 0x83, 0xae, 0xe1,
0x6e, 0x18, 0x96, 0xbf, 0x48, 0x6d, 0x46, 0x16, 0x45, 0x3e, 0x5a, 0xf0, 0xfb, 0xc4, 0x67, 0x88,
0xfc, 0x61, 0xbc, 0x6e, 0x7a, 0xa2, 0x9c, 0x72, 0x3d, 0x79, 0x17, 0xeb, 0xfd, 0x77, 0xb1, 0x7e,
0x10, 0xbf, 0x8b, 0xee, 0x43, 0x83, 0x71, 0xdf, 0xf9, 0x7f, 0x56, 0x8c, 0x34, 0x27, 0x0d, 0xdd,
0x77, 0x6b, 0x2e, 0x98, 0x2d, 0xff, 0xf9, 0x1e, 0x00, 0x00, 0xff, 0xff, 0x7e, 0xac, 0xa1, 0xb6,
0xb2, 0x07, 0x00, 0x00,
// 734 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0xdd, 0x4e, 0xdb, 0x48,
0x14, 0xc7, 0x65, 0x42, 0x20, 0x39, 0xcb, 0x7e, 0x30, 0x2c, 0x60, 0x4c, 0xc4, 0x66, 0x7d, 0xb3,
0xd1, 0x6a, 0x95, 0x00, 0xab, 0x42, 0x3f, 0x54, 0x2a, 0x04, 0xa8, 0x15, 0xe2, 0x02, 0x19, 0xaa,
0x5e, 0xa2, 0x89, 0x73, 0x92, 0x8e, 0x6a, 0xcf, 0xb8, 0x9e, 0x31, 0x34, 0x54, 0xdc, 0xb4, 0x55,
0xef, 0x7a, 0x55, 0xf5, 0x4d, 0xfa, 0x0e, 0x7d, 0x80, 0xde, 0xf4, 0x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 0xcb, 0xba, 0xd7, 0x70, 0x1b, 0x1e, 0x06,
0xb2, 0xa1, 0x41, 0x56, 0xc9, 0x4f, 0x82, 0x90, 0xb7, 0x06, 0xcc, 0xe6, 0xdc, 0x83, 0x54, 0x74,
0x83, 0x11, 0xfe, 0x65, 0xad, 0x0c, 0x55, 0x7b, 0x9e, 0x63, 0xaf, 0x6a, 0x96, 0x7f, 0x49, 0x6d,
0x4c, 0x16, 0x49, 0x3e, 0x19, 0x30, 0x3f, 0xf4, 0x12, 0x23, 0x7f, 0xeb, 0x5e, 0xd7, 0x5d, 0x70,
0xd6, 0x42, 0x3d, 0xb9, 0x55, 0xeb, 0xd9, 0xad, 0x5a, 0xdf, 0x8b, 0x6f, 0x55, 0x7b, 0x5b, 0x63,
0x3c, 0xb0, 0xee, 0x8d, 0x8b, 0x91, 0xce, 0xa4, 0xa1, 0xb2, 0x6e, 0xcd, 0x29, 0x5d, 0xf2, 0xff,
0x1f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x8f, 0x32, 0xd1, 0x1d, 0xf0, 0x07, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.

View File

@@ -88,6 +88,6 @@ message CronWorkflow {
int64 startingDeadlineSeconds = 6;
int32 successfulJobsHistoryLimit = 7;
int32 failedJobsHistoryLimit = 8;
WorkflowExecution workflowExecution = 9;
repeated WorkflowExecutionParameter parameters = 9;
WorkflowTemplate workflowTemplate = 10;
}

View File

@@ -14,8 +14,7 @@ import (
)
func (c *Client) UpdateCronWorkflow(namespace string, name string, cronWorkflow *CronWorkflow) (*CronWorkflow, error) {
workflow := cronWorkflow.WorkflowExecution
workflowTemplate, err := c.GetWorkflowTemplate(namespace, workflow.WorkflowTemplate.UID, workflow.WorkflowTemplate.Version)
workflowTemplate, err := c.GetWorkflowTemplate(namespace, cronWorkflow.WorkflowTemplate.UID, cronWorkflow.WorkflowTemplate.Version)
if err != nil {
log.WithFields(log.Fields{
"Namespace": namespace,
@@ -29,7 +28,7 @@ func (c *Client) UpdateCronWorkflow(namespace string, name string, cronWorkflow
opts := &WorkflowExecutionOptions{}
re, _ := regexp.Compile(`[^a-zA-Z0-9-]{1,}`)
opts.GenerateName = strings.ToLower(re.ReplaceAllString(workflowTemplate.Name, `-`)) + "-"
for _, param := range workflow.Parameters {
for _, param := range cronWorkflow.WorkflowExecutionParameters {
opts.Parameters = append(opts.Parameters, WorkflowExecutionParameter{
Name: param.Name,
Value: param.Value,
@@ -54,7 +53,7 @@ func (c *Client) UpdateCronWorkflow(namespace string, name string, cronWorkflow
if err != nil {
log.WithFields(log.Fields{
"Namespace": namespace,
"CronWorkflow": workflow,
"CronWorkflow": cronWorkflow,
"Error": err.Error(),
}).Error("Error parsing workflow.")
return nil, err
@@ -74,9 +73,9 @@ func (c *Client) UpdateCronWorkflow(namespace string, name string, cronWorkflow
cronWorkflow.Name = argoCreatedCronWorkflow.Name
cronWorkflow.CreatedAt = argoCreatedCronWorkflow.CreationTimestamp.UTC()
cronWorkflow.UID = string(argoCreatedCronWorkflow.ObjectMeta.UID)
cronWorkflow.WorkflowExecution.WorkflowTemplate = workflowTemplate
cronWorkflow.WorkflowTemplate = workflowTemplate
// Manifests could get big, don't return them in this case.
cronWorkflow.WorkflowExecution.WorkflowTemplate.Manifest = ""
cronWorkflow.WorkflowTemplate.Manifest = ""
return cronWorkflow, nil
}
@@ -84,9 +83,7 @@ func (c *Client) UpdateCronWorkflow(namespace string, name string, cronWorkflow
}
func (c *Client) CreateCronWorkflow(namespace string, cronWorkflow *CronWorkflow) (*CronWorkflow, error) {
workflow := cronWorkflow.WorkflowExecution
workflowTemplate, err := c.GetWorkflowTemplate(namespace, workflow.WorkflowTemplate.UID, workflow.WorkflowTemplate.Version)
workflowTemplate, err := c.GetWorkflowTemplate(namespace, cronWorkflow.WorkflowTemplate.UID, cronWorkflow.WorkflowTemplate.Version)
if err != nil {
log.WithFields(log.Fields{
"Namespace": namespace,
@@ -100,7 +97,7 @@ func (c *Client) CreateCronWorkflow(namespace string, cronWorkflow *CronWorkflow
opts := &WorkflowExecutionOptions{}
re, _ := regexp.Compile(`[^a-zA-Z0-9-]{1,}`)
opts.GenerateName = strings.ToLower(re.ReplaceAllString(workflowTemplate.Name, `-`)) + "-"
for _, param := range workflow.Parameters {
for _, param := range cronWorkflow.WorkflowExecutionParameters {
opts.Parameters = append(opts.Parameters, WorkflowExecutionParameter{
Name: param.Name,
Value: param.Value,
@@ -125,7 +122,7 @@ func (c *Client) CreateCronWorkflow(namespace string, cronWorkflow *CronWorkflow
if err != nil {
log.WithFields(log.Fields{
"Namespace": namespace,
"CronWorkflow": workflow,
"CronWorkflow": cronWorkflow,
"Error": err.Error(),
}).Error("Error parsing workflow.")
return nil, err
@@ -145,9 +142,9 @@ func (c *Client) CreateCronWorkflow(namespace string, cronWorkflow *CronWorkflow
cronWorkflow.Name = argoCreatedCronWorkflow.Name
cronWorkflow.CreatedAt = argoCreatedCronWorkflow.CreationTimestamp.UTC()
cronWorkflow.UID = string(argoCreatedCronWorkflow.ObjectMeta.UID)
cronWorkflow.WorkflowExecution.WorkflowTemplate = workflowTemplate
cronWorkflow.WorkflowTemplate = workflowTemplate
// Manifests could get big, don't return them in this case.
cronWorkflow.WorkflowExecution.WorkflowTemplate.Manifest = ""
cronWorkflow.WorkflowTemplate.Manifest = ""
return cronWorkflow, nil
}
@@ -176,7 +173,6 @@ func (c *Client) GetCronWorkflow(namespace, name string) (cronWorkflow *CronWork
StartingDeadlineSeconds: cwf.Spec.StartingDeadlineSeconds,
SuccessfulJobsHistoryLimit: cwf.Spec.SuccessfulJobsHistoryLimit,
FailedJobsHistoryLimit: cwf.Spec.FailedJobsHistoryLimit,
WorkflowExecution: nil,
}
return
@@ -211,7 +207,6 @@ func (c *Client) ListCronWorkflows(namespace string) (cronWorkflows []*CronWorkf
StartingDeadlineSeconds: cwf.Spec.StartingDeadlineSeconds,
SuccessfulJobsHistoryLimit: cwf.Spec.SuccessfulJobsHistoryLimit,
FailedJobsHistoryLimit: cwf.Spec.FailedJobsHistoryLimit,
WorkflowExecution: nil,
})
}
return

View File

@@ -36,19 +36,20 @@ type Metric struct {
}
type CronWorkflow struct {
ID uint64
CreatedAt time.Time `db:"created_at"`
UID string
Name string
GenerateName string
Schedule string
Timezone string
Suspend bool
ConcurrencyPolicy string
StartingDeadlineSeconds *int64
SuccessfulJobsHistoryLimit *int32
FailedJobsHistoryLimit *int32
WorkflowExecution *WorkflowExecution
ID uint64
CreatedAt time.Time `db:"created_at"`
UID string
Name string
GenerateName string
Schedule string
Timezone string
Suspend bool
ConcurrencyPolicy string
StartingDeadlineSeconds *int64
SuccessfulJobsHistoryLimit *int32
FailedJobsHistoryLimit *int32
WorkflowExecutionParameters []*WorkflowExecutionParameter
WorkflowTemplate *WorkflowTemplate
}
type WorkflowTemplate struct {

View File

@@ -37,8 +37,8 @@ func apiCronWorkflow(cwf *v1.CronWorkflow) (cronWorkflow *api.CronWorkflow) {
cronWorkflow.FailedJobsHistoryLimit = *cwf.FailedJobsHistoryLimit
}
if cwf.WorkflowExecution != nil {
cronWorkflow.WorkflowExecution = GenApiWorkflowExecution(cwf.WorkflowExecution)
if cwf.WorkflowTemplate != nil {
cronWorkflow.WorkflowTemplate = GenApiWorkflowTemplate(cwf.WorkflowTemplate)
}
return
@@ -51,28 +51,29 @@ func (c *CronWorkflowServer) CreateCronWorkflow(ctx context.Context, req *api.Cr
return nil, err
}
workflow := &v1.WorkflowExecution{
WorkflowTemplate: &v1.WorkflowTemplate{
UID: req.CronWorkflow.WorkflowExecution.WorkflowTemplate.Uid,
Version: req.CronWorkflow.WorkflowExecution.WorkflowTemplate.Version,
},
workflowTemplate := &v1.WorkflowTemplate{
UID: req.CronWorkflow.WorkflowTemplate.Uid,
Version: req.CronWorkflow.WorkflowTemplate.Version,
}
for _, param := range req.CronWorkflow.WorkflowExecution.Parameters {
workflow.Parameters = append(workflow.Parameters, v1.WorkflowExecutionParameter{
var workflowExecutionParams []*v1.WorkflowExecutionParameter
for _, param := range req.CronWorkflow.Parameters {
workflowExecutionParams = append(workflowExecutionParams, &v1.WorkflowExecutionParameter{
Name: param.Name,
Value: ptr.String(param.Value),
})
}
cronWorkflow := v1.CronWorkflow{
Schedule: req.CronWorkflow.Schedule,
Timezone: req.CronWorkflow.Timezone,
Suspend: req.CronWorkflow.Suspend,
ConcurrencyPolicy: req.CronWorkflow.ConcurrencyPolicy,
StartingDeadlineSeconds: &req.CronWorkflow.StartingDeadlineSeconds,
SuccessfulJobsHistoryLimit: &req.CronWorkflow.SuccessfulJobsHistoryLimit,
FailedJobsHistoryLimit: &req.CronWorkflow.FailedJobsHistoryLimit,
WorkflowExecution: workflow,
Schedule: req.CronWorkflow.Schedule,
Timezone: req.CronWorkflow.Timezone,
Suspend: req.CronWorkflow.Suspend,
ConcurrencyPolicy: req.CronWorkflow.ConcurrencyPolicy,
StartingDeadlineSeconds: &req.CronWorkflow.StartingDeadlineSeconds,
SuccessfulJobsHistoryLimit: &req.CronWorkflow.SuccessfulJobsHistoryLimit,
FailedJobsHistoryLimit: &req.CronWorkflow.FailedJobsHistoryLimit,
WorkflowExecutionParameters: workflowExecutionParams,
WorkflowTemplate: workflowTemplate,
}
cwf, err := client.CreateCronWorkflow(req.Namespace, &cronWorkflow)
@@ -91,28 +92,29 @@ func (c *CronWorkflowServer) UpdateCronWorkflow(ctx context.Context, req *api.Up
if err != nil || !allowed {
return nil, err
}
workflow := &v1.WorkflowExecution{
WorkflowTemplate: &v1.WorkflowTemplate{
UID: req.CronWorkflow.WorkflowExecution.WorkflowTemplate.Uid,
Version: req.CronWorkflow.WorkflowExecution.WorkflowTemplate.Version,
},
workflowTemplate := &v1.WorkflowTemplate{
UID: req.CronWorkflow.WorkflowTemplate.Uid,
Version: req.CronWorkflow.WorkflowTemplate.Version,
}
for _, param := range req.CronWorkflow.WorkflowExecution.Parameters {
workflow.Parameters = append(workflow.Parameters, v1.WorkflowExecutionParameter{
var workflowExecutionParams []*v1.WorkflowExecutionParameter
for _, param := range req.CronWorkflow.Parameters {
workflowExecutionParams = append(workflowExecutionParams, &v1.WorkflowExecutionParameter{
Name: param.Name,
Value: ptr.String(param.Value),
})
}
cronWorkflow := v1.CronWorkflow{
Schedule: req.CronWorkflow.Schedule,
Timezone: req.CronWorkflow.Timezone,
Suspend: req.CronWorkflow.Suspend,
ConcurrencyPolicy: req.CronWorkflow.ConcurrencyPolicy,
StartingDeadlineSeconds: &req.CronWorkflow.StartingDeadlineSeconds,
SuccessfulJobsHistoryLimit: &req.CronWorkflow.SuccessfulJobsHistoryLimit,
FailedJobsHistoryLimit: &req.CronWorkflow.FailedJobsHistoryLimit,
WorkflowExecution: workflow,
Schedule: req.CronWorkflow.Schedule,
Timezone: req.CronWorkflow.Timezone,
Suspend: req.CronWorkflow.Suspend,
ConcurrencyPolicy: req.CronWorkflow.ConcurrencyPolicy,
StartingDeadlineSeconds: &req.CronWorkflow.StartingDeadlineSeconds,
SuccessfulJobsHistoryLimit: &req.CronWorkflow.SuccessfulJobsHistoryLimit,
FailedJobsHistoryLimit: &req.CronWorkflow.FailedJobsHistoryLimit,
WorkflowExecutionParameters: workflowExecutionParams,
WorkflowTemplate: workflowTemplate,
}
cwf, err := client.UpdateCronWorkflow(req.Namespace, req.Name, &cronWorkflow)

View File

@@ -57,6 +57,10 @@ func apiWorkflowExecution(wf *v1.WorkflowExecution) (workflow *api.WorkflowExecu
return
}
func GenApiWorkflowTemplate(wft *v1.WorkflowTemplate) *api.WorkflowTemplate {
return apiWorkflowTemplate(wft)
}
func apiWorkflowTemplate(wft *v1.WorkflowTemplate) *api.WorkflowTemplate {
return &api.WorkflowTemplate{
Uid: wft.UID,