-
Notifications
You must be signed in to change notification settings - Fork 260
write empty json object to empty cni statefile if exists #933
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
Conversation
tamilmani1989
left a comment
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
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| fi, err := os.Stat(filename) | ||
| if err != nil { | ||
| if errors.Is(err, os.ErrNotExist) { | ||
| return nil |
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.
Add a log line?
| // empty file on the host filesystem, crashing older CNI because it doesn't know | ||
| // how to handle empty statefiles. | ||
| func WriteObjectToCNIStatefile() error { | ||
| filename := "/var/run/azure-vnet.json" |
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.
Hi @rbtr 👋 what's the best way I can make this different for OS windows?
I was thinking about making a statefile_windows.go with this same code but different filename, that seems to copy alot however.
Any ideas? I just want to defer to you since you know alot more about go than I do, I can only think about an if statement if the OS is windows, just wondering if that's enough
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.
This was a hack for older CNIs, pre 1.4.7 or so; if you're adding support to Windows now then this might not even be necessary.
If it is necessary, is the only thing that's different on Windows the filepath? That could be injected from an early OS check all the way down in to this function. OR, probably more correctly, this shouldn't be a hardcoded const and should come from env or config (with a default for each OS).
Reason for Change:
Issue Fixed:
Requirements:
Notes: