Giter Site home page Giter Site logo

Comments (6)

Arnavion avatar Arnavion commented on July 4, 2024 1

Okay, from experimentation, it looks like the old core Events are translated into events/v1 Events with eventTime: null. Creating new Events (or editing existing ones) with eventTime: null or without eventTime is rejected by the API server. New events/v1 Events that were generated by the API server as such must have eventTime: non-null.

There is also the case of reportingController etc fields - they are required in new events/v1 Events, but unlike eventTime they are omitted entirely instead of being set to null for old core Events. Also unlike the eventTime field they are marked as optional in the OpenAPI spec.

So I think I'll treat this as an OpenAPI spec bug that should mark Event::eventTime as an optional field just like it did for reportingController etc, rather than allow MicroTime to be deserializable from null.

from k8s-openapi.

Arnavion avatar Arnavion commented on July 4, 2024

It can, but it produces a zero time.Time, which per https://pkg.go.dev/time#Time represents "January 1, year 1, 00:00:00.000000000 UTC".

k8s-openapi types the Event::event_time field as Option<MicroTime> because the spec says the field is optional.

Is 0001-01-01T00:00:00.000000000Z a more useful value than None ? In golang where nonsensical "zero" values for structs are the norm since optionals require pointer types, sure. But I'm not sure I want to carry that forward into Rust when we have a proper Option.

from k8s-openapi.

foriequal0 avatar foriequal0 commented on July 4, 2024

core/v1 Event spec says eventTime is optional, but events.k8s.io/v1 Event spec says it's required.
so api.get() or api.list() on events.k8s.io/v1 Event woud fail when there's any event that is converted from old type.

from k8s-openapi.

foriequal0 avatar foriequal0 commented on July 4, 2024

Oh, I forgot to mention that events.k8s.io/v1 Event usually contains core/v1 Events that are automatically converted.

from k8s-openapi.

foriequal0 avatar foriequal0 commented on July 4, 2024

I attached kubectl get event, not kubecl get events.events.k8s.io
this is the latter.

{
    "apiVersion": "events.k8s.io/v1",
    "deprecatedCount": 1,
    "deprecatedFirstTimestamp": "2023-02-16T18:25:07Z",
    "deprecatedLastTimestamp": "2023-02-16T18:25:07Z",
    "deprecatedSource": {
        "component": "default-scheduler"
    },
    "eventTime": null,
    "kind": "Event",
    "metadata": {
        "creationTimestamp": "2023-02-16T18:25:07Z",
        "name": "some-pod.174461445d6d3cff",
        "namespace": "test-530513",
        "resourceVersion": "320932",
        "uid": "f3ac47c9-cc86-4193-a2ed-2e4428b7ad77"
    },
    "note": "Successfully assigned test-530513/some-pod to test-pgd-control-plane",
    "reason": "Scheduled",
    "regarding": {
        "apiVersion": "v1",
        "kind": "Pod",
        "name": "some-pod",
        "namespace": "test-530513",
        "resourceVersion": "320930",
        "uid": "ace87ee8-15fb-46ae-9dae-c77422c2010f"
    },
    "type": "Normal"
}

from k8s-openapi.

Arnavion avatar Arnavion commented on July 4, 2024

Does the API server accept a JSON blob that doesn't contain an eventTime field at all as an events.k8s.io/v1 Event ? Or does it require the field to be present?

from k8s-openapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.