Add query options to Nomad API queries to make sure we query the correct namespace
This commit is contained in:

committed by
Maximilian Pass

parent
ce2b82d43d
commit
66821dbfc8
@ -44,6 +44,7 @@ type apiQuerier interface {
|
|||||||
type nomadApiClient struct {
|
type nomadApiClient struct {
|
||||||
client *nomadApi.Client
|
client *nomadApi.Client
|
||||||
namespace string
|
namespace string
|
||||||
|
queryOptions *nomadApi.QueryOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nc *nomadApiClient) init(nomadURL *url.URL, nomadNamespace string) (err error) {
|
func (nc *nomadApiClient) init(nomadURL *url.URL, nomadNamespace string) (err error) {
|
||||||
@ -53,11 +54,14 @@ func (nc *nomadApiClient) init(nomadURL *url.URL, nomadNamespace string) (err er
|
|||||||
Namespace: nomadNamespace,
|
Namespace: nomadNamespace,
|
||||||
})
|
})
|
||||||
nc.namespace = nomadNamespace
|
nc.namespace = nomadNamespace
|
||||||
|
nc.queryOptions = &nomadApi.QueryOptions{
|
||||||
|
Namespace: nc.namespace,
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nc *nomadApiClient) DeleteRunner(runnerId string) (err error) {
|
func (nc *nomadApiClient) DeleteRunner(runnerId string) (err error) {
|
||||||
allocation, _, err := nc.client.Allocations().Info(runnerId, nil)
|
allocation, _, err := nc.client.Allocations().Info(runnerId, nc.queryOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -76,7 +80,7 @@ func (nc *nomadApiClient) ExecuteCommand(allocationID string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (nc *nomadApiClient) loadRunners(jobId string) (allocationListStub []*nomadApi.AllocationListStub, err error) {
|
func (nc *nomadApiClient) loadRunners(jobId string) (allocationListStub []*nomadApi.AllocationListStub, err error) {
|
||||||
allocationListStub, _, err = nc.client.Jobs().Allocations(jobId, true, nil)
|
allocationListStub, _, err = nc.client.Jobs().Allocations(jobId, true, nc.queryOptions)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,6 +106,6 @@ func (nc *nomadApiClient) EvaluationStream(evalID string, ctx context.Context) (
|
|||||||
nomadApi.TopicEvaluation: {evalID},
|
nomadApi.TopicEvaluation: {evalID},
|
||||||
},
|
},
|
||||||
0,
|
0,
|
||||||
nil)
|
nc.queryOptions)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -12,13 +12,13 @@ const (
|
|||||||
|
|
||||||
// LoadJobList loads the list of jobs from the Nomad api.
|
// LoadJobList loads the list of jobs from the Nomad api.
|
||||||
func (nc *nomadApiClient) LoadJobList() (list []*nomadApi.JobListStub, err error) {
|
func (nc *nomadApiClient) LoadJobList() (list []*nomadApi.JobListStub, err error) {
|
||||||
list, _, err = nc.client.Jobs().List(nil)
|
list, _, err = nc.client.Jobs().List(nc.queryOptions)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// JobScale returns the scale of the passed job.
|
// JobScale returns the scale of the passed job.
|
||||||
func (nc *nomadApiClient) JobScale(jobId string) (jobScale uint, err error) {
|
func (nc *nomadApiClient) JobScale(jobId string) (jobScale uint, err error) {
|
||||||
status, _, err := nc.client.Jobs().ScaleStatus(jobId, nil)
|
status, _, err := nc.client.Jobs().ScaleStatus(jobId, nc.queryOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user