Skip to content

Commit 8e7f3ae

Browse files
eyupcanakmantehut
authored andcommitted
cli: fix job dispatch and periodic force against older servers (#28014)
job dispatch and job periodic force fail with "failed to create result paginator" when a newer CLI talks to an older server. #27631 switched JobIDByPrefix to a server-side filter using the "is not nil" operator, which older servers (go-bexpr v0.1.15, pre-1.11.3) cannot parse. The CLI now keeps that filter as the fast path and falls back to an unfiltered prefix list plus a client-side match when an old server rejects it. Fixes #27680
1 parent 71382e2 commit 8e7f3ae

28 files changed

Lines changed: 128 additions & 37 deletions

.changelog/27680.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
cli: Fixed `job dispatch` and `job periodic force` failing with a paginator error against servers older than the CLI
3+
```

api/api.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ const (
4444
// by the API which indicates the caller does not have permission to
4545
// perform the action.
4646
PermissionDeniedErrorContent = "Permission denied"
47+
48+
// ResultPaginatorErrorContent is the string content of an error returned by
49+
// the API when it cannot build the paginator for a list query, for example
50+
// when the server is unable to evaluate the requested filter expression.
51+
// This duplicates the message of structs.ErrResultPaginatorCreation, which
52+
// the server emits. The api module cannot import structs, so keep them in sync.
53+
ResultPaginatorErrorContent = "failed to create result paginator"
4754
)
4855

4956
// QueryOptions are used to parametrize a query

command/alloc_exec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func (l *AllocExecCommand) Run(args []string) int {
168168

169169
var allocStub *api.AllocationListStub
170170
if job {
171-
jobID, ns, err := l.JobIDByPrefix(client, args[0], "")
171+
jobID, ns, err := l.JobIDByPrefix(client, args[0])
172172
if err != nil {
173173
l.Ui.Error(err.Error())
174174
return 1

command/alloc_fs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func (f *AllocFSCommand) Run(args []string) int {
171171
// If -job is specified, use random allocation, otherwise use provided allocation
172172
allocID := args[0]
173173
if job {
174-
jobID, ns, err := f.JobIDByPrefix(client, args[0], "")
174+
jobID, ns, err := f.JobIDByPrefix(client, args[0])
175175
if err != nil {
176176
f.Ui.Error(err.Error())
177177
return 1

command/alloc_logs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func (l *AllocLogsCommand) Run(args []string) int {
172172
// If -job is specified, use random allocation, otherwise use provided allocation
173173
allocID := args[0]
174174
if l.job {
175-
jobID, ns, err := l.JobIDByPrefix(client, args[0], "")
175+
jobID, ns, err := l.JobIDByPrefix(client, args[0])
176176
if err != nil {
177177
l.Ui.Error(err.Error())
178178
return 1

command/job_action.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func (c *JobActionCommand) Run(args []string) int {
182182
return 1
183183
}
184184

185-
jobID, ns, err := c.JobIDByPrefix(client, job, "")
185+
jobID, ns, err := c.JobIDByPrefix(client, job)
186186
if err != nil {
187187
c.Ui.Error(err.Error())
188188
return 1

command/job_allocs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (c *JobAllocsCommand) Run(args []string) int {
9999

100100
// Check if the job exists
101101
jobIDPrefix := strings.TrimSpace(args[0])
102-
jobID, namespace, err := c.JobIDByPrefix(client, jobIDPrefix, "")
102+
jobID, namespace, err := c.JobIDByPrefix(client, jobIDPrefix)
103103
if err != nil {
104104
c.Ui.Error(err.Error())
105105
return 1

command/job_deployments.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func (c *JobDeploymentsCommand) Run(args []string) int {
104104

105105
// Check if the job exists
106106
jobIDPrefix := strings.TrimSpace(args[0])
107-
jobID, namespace, err := c.JobIDByPrefix(client, jobIDPrefix, "")
107+
jobID, namespace, err := c.JobIDByPrefix(client, jobIDPrefix)
108108
if err != nil {
109109
c.Ui.Error(err.Error())
110110
return 1

command/job_dispatch.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,9 @@ func (c *JobDispatchCommand) Run(args []string) int {
202202
}
203203

204204
jobIDPrefix := strings.TrimSpace(args[0])
205-
jobID, namespace, err := c.JobIDByPrefix(client, jobIDPrefix,
206-
`ParentID == "" and ParameterizedJob is not nil`)
205+
jobID, namespace, err := c.jobIDByPrefix(client, jobIDPrefix,
206+
`ParentID == "" and ParameterizedJob is not nil`,
207+
func(j *api.JobListStub) bool { return j.ParentID == "" && j.ParameterizedJob })
207208
if err != nil {
208209
var noPrefixErr *NoJobWithPrefixError
209210
if errors.As(err, &noPrefixErr) {

command/job_eval.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func (c *JobEvalCommand) Run(args []string) int {
107107

108108
// Check if the job exists
109109
jobIDPrefix := strings.TrimSpace(args[0])
110-
jobID, namespace, err := c.JobIDByPrefix(client, jobIDPrefix, "")
110+
jobID, namespace, err := c.JobIDByPrefix(client, jobIDPrefix)
111111
if err != nil {
112112
c.Ui.Error(err.Error())
113113
return 1

0 commit comments

Comments
 (0)