kubernetes-client icon indicating copy to clipboard operation
kubernetes-client copied to clipboard

Regarding watch event failures and retries

Open tankunsheng opened this issue 5 years ago • 0 comments

Looking at the examples of the implementation of watches for resources. How would the reconciliation work in the event that a creation/update/deletion event fails and needs to be retried again?

It does not seem right to handle the retry from within the code. Is there someway to reschedule a retry?

From the example of the watchDeploymentNotifiers below:

function watchDeploymentNotifiers (client) {
  const stream = client.apis['kubernetes-client.io'].v1.watch.deploymentnotifiers.getStream()
  const jsonStream = new JSONStream()
  stream.pipe(jsonStream)

  const watchers = {}
  jsonStream.on('data', async event => {
    const id = `${event.object.metadata.namespace}/${event.object.metadata.name}`
    if (event.type === 'ADDED') {

      // What happens if the logic fails here and errors out
      // How do I ensure that the watch for this particular resource version is triggered again?

    } else if (event.type === 'DELETED') {
    
    }
  })
}

tankunsheng avatar Nov 27 '20 16:11 tankunsheng