Skip to content
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

Merged
merged 1 commit into from
Jun 26, 2019
Merged

Conversation

fenxiong
Copy link
Contributor

@fenxiong fenxiong commented Jun 25, 2019

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.

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 {
Copy link
Contributor

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

Copy link
Contributor Author

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")
Copy link
Contributor

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?

Copy link
Contributor Author

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

@fenxiong fenxiong force-pushed the fix-unmarshal branch 2 times, most recently from c13f6a9 to 256538a Compare June 26, 2019 16:45
Previously task resource unmarshal error was ignored. This PR fixes it. Also fixes unit tests that start failing on mac after exposing the error.
@fenxiong fenxiong merged commit c305dc8 into aws:dev Jun 26, 2019
@fenxiong fenxiong added this to the 1.29.1 milestone Jul 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants