-
Notifications
You must be signed in to change notification settings - Fork 618
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
Fix task resource unmarshal error case #2098
Conversation
agent/taskresource/types/types.go
Outdated
func unmarshalResource(key string, value json.RawMessage, result map[string][]taskresource.TaskResource) error { | ||
switch key { | ||
case CgroupKey: | ||
if err := unmarshlCgroup(key, value, result); err != 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.
these could all be simplified to:
return umarshalThing(key,value,result)
// this...
if err != nil {
return err
} else {
return nil
}
// ...is the same as
return err
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.
updated
@@ -113,12 +113,12 @@ func (c *CgroupResource) GetTerminalReason() string { | |||
|
|||
// MarshalJSON marshals CgroupResource object | |||
func (c *CgroupResource) MarshalJSON() ([]byte, error) { | |||
return nil, errors.New("unsupported platform") |
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.
We'd want this to fail loudly on windows if this path got crossed, right?
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.
yeah. keeping the error and fixes the state file instead
c13f6a9
to
256538a
Compare
Previously task resource unmarshal error was ignored. This PR fixes it. Also fixes unit tests that start failing on mac after exposing the error.
Summary
Previously task resource unmarshal error was ignored rather than returned. This PR fixes it.
Also fixes unit tests that start failing on mac after exposing the error. I had to fix a lot of state files used in state manager unit tests because they were using cgroup, but cgroup is not supported on non-linux platform.
Implementation details
Testing
New tests cover the changes:
Description for the changelog
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.