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

kopf.timer / kopf.daemon disable kopf.on* handlers #1122

Open
sc0rp10 opened this issue Aug 7, 2024 · 0 comments
Open

kopf.timer / kopf.daemon disable kopf.on* handlers #1122

sc0rp10 opened this issue Aug 7, 2024 · 0 comments
Labels
question Further information is requested

Comments

@sc0rp10
Copy link

sc0rp10 commented Aug 7, 2024

Keywords

timer, daeemon, handler

Problem

Hello, I try to build an own operator that creates few simple resources by some CRD, those need to be updated by some external data. I check for that data periodically, using timer/daemon.

My handlers.py is deadly simple - I just copied example from kopf website:

import kopf
import logging

@kopf.on.create('ephemeralvolumeclaims')
def create_fn(body, **kwargs):
    logging.info(f"A handler is called with body: {body}")

@kopf.timer('ephemeralvolumeclaims', interval=1.0)
def ping_kex(spec, **kwargs):
    logging.info(f"A timer is called")
CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: ephemeralvolumeclaims.kopf.dev
spec:
  scope: Namespaced
  group: kopf.dev
  names:
    kind: EphemeralVolumeClaim
    plural: ephemeralvolumeclaims
    singular: ephemeralvolumeclaim
    shortNames:
      - evcs
      - evc
  versions:
    - name: v1
      served: true
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              x-kubernetes-preserve-unknown-fields: true
            status:
              type: object
              x-kubernetes-preserve-unknown-fields: true
Object
apiVersion: kopf.dev/v1
kind: EphemeralVolumeClaim
metadata:
  name: my-claim

When I run this file without timer or daemon, everything works like a charm, but once I add timer/daemon, my on* handlers stopped working without any information.

What can be wrong with this configuration? What is the best approach to have some periodic watch for some external system to provide my k8s resources with some information from that system?

UPD: I use macOS and run kopf directly from macos as kopf run ...

@sc0rp10 sc0rp10 added the question Further information is requested label Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant