Skip to content

Commit

Permalink
0.22 status not erroring (#494)
Browse files Browse the repository at this point in the history
* never error on status unmarshalling

* move changelog

Co-authored-by: nfuden <nathan.fudenberg@solo.io>
  • Loading branch information
bewebi and nfuden authored Jun 29, 2022
1 parent 31ccbd9 commit f50f03b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
6 changes: 6 additions & 0 deletions changelog/v0.22.2/never-error-on-statuses.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
changelog:
- type: FIX
issueLink: https://github.com/solo-io/solo-kit/issues/484
resolvesIssue: false
description: |
Dont error on statuses. This allows for downgrades.
10 changes: 2 additions & 8 deletions pkg/api/v1/clients/kube/crd/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,7 @@ func (d Crd) KubeResource(resource resources.InputResource) (*v1.Resource, error
if err != nil {
return nil, MarshalErr(err, "resource spec to map")
}
status, err = customResource.MarshalStatus()
if err != nil {
return nil, MarshalErr(err, "resource status to map")
}
status, _ = customResource.MarshalStatus()

} else {
// Default marshalling
Expand All @@ -108,10 +105,7 @@ func (d Crd) KubeResource(resource resources.InputResource) (*v1.Resource, error

if resource.GetStatus() != nil {
statusProto := resource.GetStatus()
statusMap, err := protoutils.MarshalMapFromProtoWithEnumsAsInts(statusProto)
if err != nil {
return nil, MarshalErr(err, "resource status to map")
}
statusMap, _ := protoutils.MarshalMapFromProtoWithEnumsAsInts(statusProto)
status = statusMap
}
}
Expand Down
12 changes: 5 additions & 7 deletions pkg/api/v1/clients/kube/resource_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,10 @@ func (rc *ResourceClient) convertCrdToResource(resourceCrd *v1.Resource) (resour
resourceCrd.Name, resourceCrd.Namespace, rc.resourceName)
}
}
if err := customResource.UnmarshalStatus(resourceCrd.Status); err != nil {
return nil, errors.Wrapf(err, "unmarshalling crd status on custom resource %v in namespace %v into %v",
resourceCrd.Name, resourceCrd.Namespace, rc.resourceName)
}
// If the status is of a form that we do not recognize, we should ignore it.
// Support backports of custom resources that do not have a status fields
// in the way we want.
_ = customResource.UnmarshalStatus(resourceCrd.Status)

} else {
// Default unmarshalling
Expand All @@ -451,9 +451,7 @@ func (rc *ResourceClient) convertCrdToResource(resourceCrd *v1.Resource) (resour
return nil
}
typedStatus := core.Status{}
if err := protoutils.UnmarshalMapToProto(resourceCrd.Status, &typedStatus); err != nil {
return err
}
_ = protoutils.UnmarshalMapToProto(resourceCrd.Status, &typedStatus)
*status = typedStatus
return nil
}
Expand Down

0 comments on commit f50f03b

Please sign in to comment.