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

Add Execution to the types.ExecuteRequest struct #1307

Open
cobolbaby opened this issue Mar 28, 2023 · 4 comments
Open

Add Execution to the types.ExecuteRequest struct #1307

cobolbaby opened this issue Mar 28, 2023 · 4 comments

Comments

@cobolbaby
Copy link
Contributor

cobolbaby commented Mar 28, 2023

Is your feature request related to a problem? Please describe.

I wish to add Execution metadata to the reportingWriter struct to implement some extended features. However, to achieve this, it is necessary to adjust the structure of the ExecuteRequest. I am not sure whether such a request is acceptable.

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

if executor, ok := as.agent.ExecutorPlugins[jex]; ok {
as.logger.WithField("plugin", jex).Debug("grpc_agent: calling executor plugin")
runningExecutions.Store(execution.GetGroup(), execution)
out, err := executor.Execute(&types.ExecuteRequest{
JobName: job.Name,
Config: exc,
}, &statusAgentHelper{
stream: stream,
execution: execution,
})

@cobolbaby cobolbaby changed the title Expand the reportingWriter struct and add job metadata Add *Execution to the *types.ExecuteRequest struct Mar 29, 2023
@cobolbaby cobolbaby changed the title Add *Execution to the *types.ExecuteRequest struct Add Execution to the types.ExecuteRequest struct Mar 29, 2023
@vcastellm
Copy link
Member

Can you explain what metadata do you want to include?

@cobolbaby
Copy link
Contributor Author

cobolbaby commented Apr 17, 2023

Can you explain what metadata do you want to include?

Currently I need to get the following attributes, such as ExecutionId, ExecutionStartTime, ExecutionNodeName.

dkron/dkron/execution.go

Lines 13 to 40 in 9982ceb

type Execution struct {
// Id is the Key for this execution
Id string `json:"id,omitempty"`
// Name of the job this executions refers to.
JobName string `json:"job_name,omitempty"`
// Start time of the execution.
StartedAt time.Time `json:"started_at,omitempty"`
// When the execution finished running.
FinishedAt time.Time `json:"finished_at,omitempty"`
// If this execution executed successfully.
Success bool `json:"success"`
// Partial output of the execution.
Output string `json:"output,omitempty"`
// Node name of the node that run this execution.
NodeName string `json:"node_name,omitempty"`
// Execution group to what this execution belongs to.
Group int64 `json:"group,omitempty"`
// Retry attempt of this execution.
Attempt uint `json:"attempt,omitempty"`
}

Then pass it to the shell command as a custom environment variable.

func (s *Shell) ExecuteImpl(args *dktypes.ExecuteRequest, cb dkplugin.StatusHelper) ([]byte, error) {
	....

	executionInfo := strings.Split(
		fmt.Sprintf("ENV_JOB_NAME=%s,ENV_EXECUTION_ID=%s,ENV_EXECUTION_NODENAME=%s",
			args.JobName, args.Execution.Id, args.Execution.NodeName), ",")
	env = append(env, executionInfo...)

        cmd, err := buildCmd(command, shell, env, cwd)

@vcastellm
Copy link
Member

@cobolbaby sorry for the delay, can you let us know if you're still interested in this?

@cobolbaby
Copy link
Contributor Author

Yes, this is an important improvement that facilitates integration with other systems.

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

No branches or pull requests

2 participants