(ctx context.Context, jobId string)
| 938 | } |
| 939 | |
| 940 | func doTerminateJobManager(ctx context.Context, jobId string) error { |
| 941 | var shouldTerminate bool |
| 942 | var job *waveobj.Job |
| 943 | err := wstore.DBUpdateFn(ctx, jobId, func(j *waveobj.Job) { |
| 944 | job = j |
| 945 | if j.JobManagerStatus == JobManagerStatus_Done { |
| 946 | shouldTerminate = false |
| 947 | return |
| 948 | } |
| 949 | j.TerminateOnReconnect = true |
| 950 | shouldTerminate = true |
| 951 | }) |
| 952 | if err != nil { |
| 953 | return fmt.Errorf("failed to set TerminateOnReconnect: %w", err) |
| 954 | } |
| 955 | |
| 956 | if !shouldTerminate { |
| 957 | log.Printf("[job:%s] already terminated, skipping", jobId) |
| 958 | return nil |
| 959 | } |
| 960 | |
| 961 | return remoteTerminateJobManager(ctx, job) |
| 962 | } |
| 963 | |
| 964 | func DisconnectJob(ctx context.Context, jobId string) error { |
| 965 | job, err := wstore.DBMustGet[*waveobj.Job](ctx, jobId) |
no test coverage detected