Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-17058

Agent2 passive check timeouts can 'leak' plugin capacity

XMLWordPrintable

    • Sprint 59 (Dec 2019)
    • 0.25

      When executing single passive checks client creates unbuffered output channel, sends request to scheduler and waits for timeout seconds for the result (see the code fragment below). After timeout there are no readers for the output channel anymore, which causes check to be stuck when writing back result/error.

      To fix:
      1. create buffered (1) channel so plugin could write the response even with no readers listening.
      2. use larger timeout (1 minute). The plugin/scheduler must handle the timeout anyway, so here timeout handling is somewhat redundant.

      func (m *Manager) PerformTask(key string, timeout time.Duration) (result string, err error) {
      	var lastLogsize uint64
      	var mtime int
      
      	w := make(resultWriter)
      	m.UpdateTasks(0, w, 0, nil, []*plugin.Request{{Key: key, LastLogsize: &lastLogsize, Mtime: &mtime}})
      
      	select {
      	case r := <-w:
      		if r.Error == nil {
      			if r.Value != nil {
      				result = *r.Value
      			} else {
      				// single metric requests do not support empty values, return error instead
      				err = errors.New("No values have been gathered yet.")
      			}
      		} else {
      			err = r.Error
      		}
      	case <-time.After(timeout):
      		err = fmt.Errorf("Timeout occurred while gathering data.")
      	}
      	return
      }
      

            wiper Andris Zeila
            wiper Andris Zeila
            Team A
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: