Skip to content

How to stop watch? #399

@joolfe

Description

@joolfe

Hi,

I'm using the watch to see the status of a Job in kubernetes with some code like this:

const stream = client.apis.batch.v1.watch.namespaces(namespace).jobs(jobNode.metadata.name).getStream();
	    const jsonStream = new JSONStream()
	       stream.pipe(jsonStream)
	    jsonStream.on('data', event => {
	      console.log('---- Event: ', event.type);
	      console.log(event.object.status);
	      console.log('---- END ----');
	      if( event.type == 'MODIFIED'){
	      	if( event.object.status.hasOwnProperty('completionTime')  ){
	      		console.log("--- JOB COMPLETE ---");
	      		console.log(stream);
	      		stream.destroy();
	      		jsonStream.destroy();
	      	}
	      }
	    })

When the job is complete i want to close the stream and free resources but everything that i have test is not working :-( how can i stop the stream??

Best Regards.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions