-
Notifications
You must be signed in to change notification settings - Fork 2k
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
csi: account for nil volume/mount in API-to-structs conversion #10855
Conversation
1704285
to
12dca86
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tested this change locally using the repro in the linked issue and the same panic occurred. A little bit of poking makes me think the issue is related to Volume
within the mount being nil, rather than mount itself which is populated with some default values. Do we need more validation around the VolumeMount to catch this?
That's embarrassing... I should've checked it end-to-end. 🤦 This is the default object we're getting for
Unfortunately if I update that to catch The problem is the premature optimization we're doing in setting up a slice of pre-allocated volume mounts. When we iterate over those later if any of them weren't "filled" we get out |
@jrasell I've pushed up a first pass at fixing it across that file for your thoughts but need to take another look over to ensure we're catching all the possible nil blocks. |
@jrasell I've tested this with empty blocks in I'm not wild about having it work "by accident" though, especially because developers usually have a habit of copying such accidentally-working code and reusing it elsewhere in the same file. So I've gone through and fixed it where it was obviously wrong. We can fix it more generally in #10471 The following demonstrates the problem (https://play.golang.org/p/muZcc6R4QLs): package main
import (
"fmt"
)
type Volume struct {
ID string
}
func main() {
old := []*Volume{{ID: "a"}, {ID: "b"}, {ID: "c"}}
new := make([]*Volume, len(old))
for i, o := range old {
if o.ID == "never" {
new[i] = &Volume{ID: o.ID}
}
}
for _, n := range new {
fmt.Println(n)
}
} |
Fix a nil pointer in the API struct to `nomad/structs` conversion when a `volume_mount` block is empty.
96a1580
to
99f6445
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Fix a nil pointer in the API struct to `nomad/structs` conversion when a `volume_mount` block is empty.
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
Fixes #10834
Fix a nil pointer in the API struct to
nomad/structs
conversion when avolume
orvolume_mount
block is empty.