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

Super strange issue, async-related? #24

Closed
miracle2k opened this issue Aug 12, 2017 · 1 comment
Closed

Super strange issue, async-related? #24

miracle2k opened this issue Aug 12, 2017 · 1 comment

Comments

@miracle2k
Copy link
Owner

@joar Wonder if you have any insight here. There is a bug in the current code for me. If I kubectl edit a PersistentVolume, k8s-snapshots will not recognize that change. It will understand if I edit a PersistentVolumeClaim.

So I was looking into this, and I noticed that for both watch threads, it is actually quering the same resource, namely the last one that is starting watching (here, I turned it around, that is why it's watching the volumes, not the claims):

2017-08-12T13:51:46.197303Z foreign                        [urllib3.connectionpool] message=https://130.211.108.245:443 "GET /api/v1/persistentvolumes?watch=true HTTP/1.1" 200 None severity=DEBUG
2017-08-12T13:51:46.202315Z foreign                        [urllib3.connectionpool] message=https://130.211.108.245:443 "GET /api/v1/persistentvolumes?watch=true HTTP/1.1" 200 None severity=DEBUG

Correspondingly, if I log the actual events we receive, they are always PersistentVolume updates, even if it's a PersistentVolumeClaim watch thread:

got an event WatchEvent(type='ADDED', object=<PersistentVolume pvc-79960dea-d1c1-11e6-b958-42010af000bd>) <class 'pykube.objects.PersistentVolumeClaim'>
got an event WatchEvent(type='ADDED', object=<PersistentVolume pvc-77403b9f-d5e1-11e6-b958-42010af000bd>) <class 'pykube.objects.PersistentVolume'>
got an event WatchEvent(type='ADDED', object=<PersistentVolume pvc-e7242b6a-08da-11e7-924e-42010af000dd>) <class 'pykube.objects.PersistentVolumeClaim'>

Now the thing that kind of blows my mind:

If I change Kubernetes.watch from:

def watch(
            self,
            resource_type: Type[Resource],
    ) -> Iterable[_WatchEvent]:
        """
        Sync wrapper for :any:`pykube.query.Query().watch().object_stream()`
        """
        return resource_type.objects(self.client_factory()).watch().object_stream()

to

def watch(
            self,
            resource_type: Type[Resource],
    ) -> Iterable[_WatchEvent]:
        """
        Sync wrapper for :any:`pykube.query.Query().watch().object_stream()`
        """
        api = self.client_factory()
        return resource_type.objects(api).watch().object_stream()

It works. EVERY TIME. Recording to proof it: http://recordit.co/HIBKNSNlXS

How can that be?

@miracle2k
Copy link
Owner Author

Found it! kelproject/pykube#138

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant