scylla-operator icon indicating copy to clipboard operation
scylla-operator copied to clipboard

Strict validation fails on embedded metadata with creationTimestamp

Open tnozicka opened this issue 2 years ago • 2 comments

The crd gen is only generating schema for a subset of generic metadata and creationTimestamp is not one of them. It doesn't need to be but the go structs reference it. The issue arises on decoding when API server is returning it with null value and if strict validation is enabled it will fail.

sm, err = f.ScyllaClient().ScyllaV1alpha1().ScyllaDBMonitorings(sc.Namespace).Create(
	ctx,
	sm,
	metav1.CreateOptions{
		FieldManager:    f.FieldManager(),
		FieldValidation: metav1.FieldValidationStrict,
	},
)
o.Expect(err).NotTo(o.HaveOccurred())
  [FAILED] Unexpected error:
      <*errors.StatusError | 0xc000620000>: 
      ScyllaDBMonitoring in version "v1alpha1" cannot be handled as a ScyllaDBMonitoring: strict decoding error: unknown field "spec.components.prometheus.storage.volumeClaimTemplate.metadata.creationTimestamp"
      {
          ErrStatus: {
              TypeMeta: {Kind: "", APIVersion: ""},
              ListMeta: {
                  SelfLink: "",
                  ResourceVersion: "",
                  Continue: "",
                  RemainingItemCount: nil,
              },
              Status: "Failure",
              Message: "ScyllaDBMonitoring in version \"v1alpha1\" cannot be handled as a ScyllaDBMonitoring: strict decoding error: unknown field \"spec.components.prometheus.storage.volumeClaimTemplate.metadata.creationTimestamp\"",
              Reason: "BadRequest",
              Details: nil,
              Code: 400,
          },
      }
  occurred
  In [It] at: github.com/scylladb/scylla-operator/test/e2e/set/scylladbmonitoring/scylladbmonitoring.go:69 @ 05/15/23 10:23:58.886

This issue is tracking making creationTimestamp to be really optional https://github.com/kubernetes/kubernetes/issues/67610 - with that we may reenable it. Or we need to patch the schema manually to accept it (codegen has schemapatch module).

tnozicka avatar May 15 '23 12:05 tnozicka