-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
A nomad jobspec provided as JSON results in a panic when the jobspec does not contain an ID property #17418
Comments
Thanks for the report @rcousens! This is actually a bug in the Nomad API client, where a Line 461 in da9ec8c
I was able to reproduce this by using a sample JSON file like this: JSON job{
"Job": {
"Affinities": null,
"AllAtOnce": false,
"Constraints": null,
"ConsulNamespace": "",
"ConsulToken": "",
"CreateIndex": 14,
"Datacenters": [
"dc1"
],
"DispatchIdempotencyToken": "",
"Dispatched": false,
"JobModifyIndex": 14,
"Meta": null,
"Migrate": null,
"ModifyIndex": 14,
"Multiregion": null,
"Name": "foo",
"Namespace": "default",
"NodePool": "default",
"NomadTokenID": "",
"ParameterizedJob": null,
"ParentID": "",
"Payload": null,
"Periodic": null,
"Priority": 50,
"Region": "global",
"Reschedule": null,
"Spreads": null,
"Stable": false,
"Status": "pending",
"StatusDescription": "",
"Stop": false,
"SubmitTime": 1685759953739812000,
"TaskGroups": [
{
"Affinities": null,
"Constraints": [
{
"LTarget": "${attr.consul.version}",
"Operand": "semver",
"RTarget": ">= 1.7.0"
}
],
"Consul": {
"Namespace": ""
},
"Count": 1,
"EphemeralDisk": {
"Migrate": false,
"SizeMB": 300,
"Sticky": false
},
"MaxClientDisconnect": null,
"Meta": null,
"Migrate": {
"HealthCheck": "checks",
"HealthyDeadline": 300000000000,
"MaxParallel": 1,
"MinHealthyTime": 10000000000
},
"Name": "foo",
"Networks": null,
"ReschedulePolicy": {
"Attempts": 0,
"Delay": 30000000000,
"DelayFunction": "exponential",
"Interval": 0,
"MaxDelay": 3600000000000,
"Unlimited": true
},
"RestartPolicy": {
"Attempts": 2,
"Delay": 15000000000,
"Interval": 1800000000000,
"Mode": "fail"
},
"Scaling": null,
"Services": [
{
"Address": "192.168.1.2",
"AddressMode": "auto",
"CanaryMeta": null,
"CanaryTags": null,
"CheckRestart": null,
"Checks": null,
"Connect": null,
"EnableTagOverride": false,
"Meta": null,
"Name": "test",
"OnUpdate": "require_healthy",
"PortLabel": "mysql",
"Provider": "consul",
"TaggedAddresses": null,
"Tags": null,
"TaskName": ""
}
],
"ShutdownDelay": null,
"Spreads": null,
"StopAfterClientDisconnect": null,
"Tasks": [
{
"Affinities": null,
"Artifacts": null,
"Config": {
"args": [
"1"
],
"command": "/bin/sleep"
},
"Constraints": null,
"DispatchPayload": null,
"Driver": "raw_exec",
"Env": null,
"Identity": null,
"KillSignal": "",
"KillTimeout": 5000000000,
"Kind": "",
"Leader": false,
"Lifecycle": null,
"LogConfig": {
"Disabled": false,
"Enabled": null,
"MaxFileSizeMB": 10,
"MaxFiles": 3
},
"Meta": null,
"Name": "foo",
"Resources": {
"CPU": 20,
"Cores": 0,
"Devices": null,
"DiskMB": 0,
"IOPS": 0,
"MemoryMB": 10,
"MemoryMaxMB": 0,
"Networks": null
},
"RestartPolicy": {
"Attempts": 2,
"Delay": 15000000000,
"Interval": 1800000000000,
"Mode": "fail"
},
"ScalingPolicies": null,
"Services": null,
"ShutdownDelay": 0,
"Templates": null,
"User": "",
"Vault": null,
"VolumeMounts": null
}
],
"Update": {
"AutoPromote": false,
"AutoRevert": false,
"Canary": 0,
"HealthCheck": "checks",
"HealthyDeadline": 300000000000,
"MaxParallel": 1,
"MinHealthyTime": 10000000000,
"ProgressDeadline": 600000000000,
"Stagger": 30000000000
},
"Volumes": null
}
],
"Type": "service",
"Update": {
"AutoPromote": false,
"AutoRevert": false,
"Canary": 0,
"HealthCheck": "",
"HealthyDeadline": 0,
"MaxParallel": 1,
"MinHealthyTime": 0,
"ProgressDeadline": 0,
"Stagger": 30000000000
},
"VaultNamespace": "",
"VaultToken": "",
"Version": 0
}
} And running
Since this is an issue with Nomad I will move this to the Thanks again for the report! |
Debug Output
Gist with debug output
Panic Output
See Gist with debug output
Expected Behavior
Nomad should have invalidated the jobspec and complained about a missing ID field
Actual Behavior
Provider crashed
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
Important Factoids
The crash ultimately comes from here though I don't know that it's the responsibility of the API client to validate the job has a non nil ID property: nomad API client
Because job.ID is escaped and passed as a pointer, the failure to validate the spec contains an "ID" property causes a crash with a nil pointer dereference
References
Source of crash in provider
The text was updated successfully, but these errors were encountered: