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

The fake client Update() should not store omit empty fields #2477

Closed
berlin-ab opened this issue Sep 8, 2023 · 3 comments
Closed

The fake client Update() should not store omit empty fields #2477

berlin-ab opened this issue Sep 8, 2023 · 3 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. kind/support Categorizes issue or PR as a support question.

Comments

@berlin-ab
Copy link
Contributor

The update deserializes the json from the old object into the new object, but if the old object didn't have the json keys to override the new object, the new object keeps its values:

The relevant code is here:

https://github.com/kubernetes-sigs/controller-runtime/blob/main/pkg/client/fake/client.go#L1025

See #2476 for a test case that points out the bug.

@berlin-ab
Copy link
Contributor Author

Fake client [It] should not change the status of typed objects that have a status subresource on update with omitempty fields
/Users/aberlin/workspace/controller-runtime/pkg/client/fake/client_test.go:1430

  [FAILED] Expected
      <v1.NodeStatus>: {
          Capacity: nil,
          Allocatable: nil,
          Phase: "",
          Conditions: nil,
          Addresses: nil,
          DaemonEndpoints: {
              KubeletEndpoint: {Port: 0},
          },
          NodeInfo: {
              MachineID: "",
              SystemUUID: "",
              BootID: "",
              KernelVersion: "",
              OSImage: "",
              ContainerRuntimeVersion: "",
              KubeletVersion: "",
              KubeProxyVersion: "",
              OperatingSystem: "",
              Architecture: "",
          },
          Images: nil,
          VolumesInUse: nil,
          VolumesAttached: nil,
          Config: {Assigned: nil, Active: nil, LastKnownGood: nil, Error: "some string"},
      }
  to be equivalent to
      <v1.NodeStatus>: {
          Capacity: nil,
          Allocatable: nil,
          Phase: "",
          Conditions: nil,
          Addresses: nil,
          DaemonEndpoints: {
              KubeletEndpoint: {Port: 0},
          },
          NodeInfo: {
              MachineID: "",
              SystemUUID: "",
              BootID: "",
              KernelVersion: "",
              OSImage: "",
              ContainerRuntimeVersion: "",
              KubeletVersion: "",
              KubeProxyVersion: "",
              OperatingSystem: "",
              Architecture: "",
          },
          Images: nil,
          VolumesInUse: nil,
          VolumesAttached: nil,
          Config: nil,
      }
      ```

@troy0820
Copy link
Member

troy0820 commented Sep 8, 2023

/kind support bug

@k8s-ci-robot k8s-ci-robot added kind/support Categorizes issue or PR as a support question. kind/bug Categorizes issue or PR as related to a bug. labels Sep 8, 2023
@alvaroaleman
Copy link
Member

Fixed in #2484

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. kind/support Categorizes issue or PR as a support question.
Projects
None yet
Development

No branches or pull requests

4 participants