Skip to content
This repository has been archived by the owner on Sep 14, 2020. It is now read-only.

01-minimal example does not work as expected. #261

Closed
zakkg3 opened this issue Dec 3, 2019 · 3 comments
Closed

01-minimal example does not work as expected. #261

zakkg3 opened this issue Dec 3, 2019 · 3 comments
Labels
documentation Documentation improvements

Comments

@zakkg3
Copy link

zakkg3 commented Dec 3, 2019

Expected Behavior

As the https://github.com/zalando-incubator/kopf/blob/master/examples/01-minimal/README.md says:

kubectl get kopfexamples
NAME             DURATION   CHILDREN   MESSAGE
kopf-example-1   1m                    hello world

and

$ kubectl get KopfExample kopf-example-1 -o yaml
apiVersion: zalando.org/v1
kind: KopfExample
metadata:
  ...
spec:
  duration: 1m
  field: value
  items:
  - item1
  - item2
status:
  message: hello world

Actual Behavior

as documented : Whatever is returned from any handler, is stored in the object’s status under that handler id (which is the function name by default).
so I get:

#  kubectl get KopfExample kopf-example-1 -o yaml 
...
status:
  create_fn:
    message: hello world

and then the message is not picked up:

kubectl get kopfexamples
NAME             DURATION   CHILDREN   MESSAGE
kopf-example-1   1m

Steps to Reproduce the Problem

  1. run the minimal example.

Specifications

  • Platform: metal K8s
  • Kubernetes version: (use kubectl version) 1.15.5
  • Python version: (use python --version) 3.8
  • Python packages installed: (use pip freeze --all) k8s and kopf

Am I doing something wrong? do I miss something?
thanks!

@zakkg3 zakkg3 changed the title 01-minimal example does not work as spected. 01-minimal example does not work as expected. Dec 3, 2019
@nolar nolar added the documentation Documentation improvements label Dec 3, 2019
@nolar
Copy link
Contributor

nolar commented Dec 3, 2019

Thanks for reporting. Indeed, that is the definition of crd.yaml. It should be:

  additionalPrinterColumns:
    - name: Duration
      type: string
      priority: 0
      JSONPath: .spec.duration
      description: For how long the pod should sleep.
    - name: Children
      type: string
      priority: 0
      JSONPath: .status.create_fn.children
      description: The children pods created.
    - name: Message
      type: string
      priority: 0
      JSONPath: .status.create_fn.message
      description: As returned from the handler (sometimes).

(With .create_fn. in two fields).

@zakkg3
Copy link
Author

zakkg3 commented Dec 3, 2019

Yes, that will fix all the examples :). Thanks for the super-fast answer. we are thinking about use this framework, and with this response, I think we will go this path. thanks!

zakkg3 pushed a commit to zakkg3/kopf that referenced this issue Dec 3, 2019
nolar added a commit that referenced this issue Dec 13, 2019
Fix bug #261, JSONPath should include the function name
@nolar
Copy link
Contributor

nolar commented Dec 23, 2019

Released as kopf==0.24.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Documentation improvements
Projects
None yet
Development

No branches or pull requests

2 participants