Skip to content
This repository has been archived by the owner on May 6, 2021. It is now read-only.

Filter builds by labels to get lower traffic #130

Open
vpavlin opened this issue Feb 22, 2018 · 10 comments
Open

Filter builds by labels to get lower traffic #130

vpavlin opened this issue Feb 22, 2018 · 10 comments

Comments

@vpavlin
Copy link
Member

vpavlin commented Feb 22, 2018

Jenkins Idler in OSIO production generates (consumes) quite a lot of nework traffic

screenshot from 2018-02-22 12-08-01

We could lower that traffic by filtering builds by labels the same way we do for DC events (

v.Add("labelSelector", "app=jenkins")
)

This would require a change to Jenkins Sync plugin (https://github.com/fabric8io/jenkins-sync-plugin/) (adding a label similar to https://github.com/jenkinsci/openshift-sync-plugin/blob/d3b43c767085d1224859345907d41d1e4f917ead/src/main/java/io/fabric8/jenkins/openshiftsync/Constants.java#L33, but "hardcoding" value like "type=jenkins-pipeline")

That way we could filter on that label and not get all the s2i builds happening in the cluster

@hrishin
Copy link
Member

hrishin commented Feb 22, 2018

@vpavlin @hferentschik
This may be happening because of Jenkins sync plugin polling behavior. It would be better if we can catch HTTP queries for a particular resource rather than just labels.
For instance, I have fixed the fabric8io/jenkins-sync-plugin#16 Build resource polling. But this change is not present in Jenkins Image yet.

@vpavlin
Copy link
Member Author

vpavlin commented Feb 22, 2018

No, this is strictly about Idler calling OpenShift GET /builds API with watch parameter, which means OpenShift sends all build events to Idler (JenkinsPipeline, Docker, S2I...). We only care about

strategy:
    jenkinsPipelineStrategy:

which we filter for when we receive the event, but I'd prefer if the filtering happened on OpenShift API server (i.e. only event for builds with specific labels would be sent)

Hope it makes more sense now.

@hferentschik
Copy link
Contributor

Sounds reasonable. So right now we don't have any way to filter what we are interested in using watch? The less we have to process the better. We should create a matching issue in the sync plugin and reference it here. Once was have something to limit our watch with, it should be easy to use.

@vpavlin
Copy link
Member Author

vpavlin commented Feb 22, 2018

The only filtering I know about is based on labels - as we do for DCs. If you know about any other way, that would be great

@aslakknutsen
Copy link
Contributor

The traffic provided in the example above has little to do with the Build actually. That's primarily caused by the DC Watch and evidence of the Idle loop that happened last week.

Before/After loop:
screenshot from 2018-02-26 12-02-53

More "normal" traffic:
screenshot from 2018-02-26 12-02-13

Labeling to only get pipelines would help some, but even then it seems like the majority of Build events are simple 'timestamp' updates or similar. The last 24h there has been 1.6Mil Build Events on roughly only a handful of actual builds.

My guess is, that as long as Jenkins is running, the Jenkins Sync plugin will update the Openshift Build model about every second to set some 'ran for time' or updating it with status Running or whatever, this change is in effect triggering the OS Build Events that are consumed by Idler and generates about 99.99% of the traffic we're seeing. (@hrishin)

On top of my head, I would assume Idler really only cares about BuildStart and BuildStopped. Everything else is noise.

@hrishin
Copy link
Member

hrishin commented Feb 28, 2018

My guess is, that as long as Jenkins is running, the Jenkins Sync plugin will update the Openshift Build model about every second to set some 'ran for time' or updating it with status Running or whatever, this change is in effect triggering the OS Build Events that are consumed by Idler and generates about 99.99% of the traffic we're seeing.

There might be a good possibility that Jenkins sync plugin updating the Build resource timestamp.

https://github.com/fabric8io/jenkins-sync-plugin/blob/job-to-bc/src/main/java/io/fabric8/jenkins/openshiftsync/BuildSyncRunListener.java#L373

https://github.com/fabric8io/jenkins-sync-plugin/blob/job-to-bc/src/main/java/io/fabric8/jenkins/openshiftsync/BuildSyncRunListener.java#L324

What behavior are we expecting if the plugin is doing so? or along with a timestamp can we consider the build number to evaluate idling condition? maybe that can get added from sync plugin as a label to build metadata if it's not exist.

@aslakknutsen
Copy link
Contributor

aslakknutsen commented Feb 28, 2018

It's easy to see what OSO Is spewing out via the Build events API if you watch the network traffic via the Pipeline view on OSiO. It essentially ends up in what seems to be an endless loop of reporting the same thing over and over and over... I'm just suspecting it's the Sync plugin.

screenshot from 2018-02-28 12-15-41

There are a few different actual versions of the BuildEvents as Jenkins progress in the stages etc, but at minimum 10 identical Events with no changes in the data being sent beyond the Resource Version in OSO (One can question why OS don't 'invalidate an identical Object' value wise as a new events, but.. ). Since the revision id is different it would imply 'something' is updating it over and over.

This is not just a problem for the Idler mind you, it's an issue for the pipeline view, the oso proxy, the user etc as endless amounts of pointless traffic is sent over the wire.

Based on how the idler works atm, it will be listening to the same build events about the build being 'in approval stage' about every second until it gets sick of it all and idles it after 45min. :)

@aslakknutsen
Copy link
Contributor

What behavior are we expecting if the plugin is doing so?

@hrishin A good first step would be; Don't update Openshift if nothing changed.

@hrishin
Copy link
Member

hrishin commented May 7, 2018

A good first step would be; Don't update Openshift if nothing changed.

Update: it has been fixed on Jenkins sync plugin side.
cc: @aslakknutsen @piyush1594

@piyush-garg
Copy link
Contributor

piyush-garg commented May 7, 2018

Yaa this has been fixed in openshift sync plugin by openshiftio/openshift.io#3266

@hrishin hrishin added this to the M milestone Dec 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants