Uploaded image for project: 'Apache YuniKorn'
  1. Apache YuniKorn
  2. YUNIKORN-64

Add zap encoders for time and duration

    XMLWordPrintableJSON

    Details

      Description

      In YUNIKORN-62 a nil pointer caused a panic. The fix was to change the log call from a Duration to a String.
      The real issue is the fact that the encoders for certain types are not set in the logger. This is most likely an OS or internationalisation configuration related issue. In the code we fail here:

      panic: runtime error: invalid memory address or nil pointer dereference[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x11ac568] goroutine 51 [running]:go.uber.org/zap/zapcore.(*jsonEncoder).AppendDuration(0xc007eca390, 0x77370eba) /Users/wyang/go/pkg/mod/go.uber.org/zap@v1.13.0/zapcore/json_encoder.go:239 
      

      That links to the source code here:

      237  func (enc *jsonEncoder) AppendDuration(val time.Duration) {
      238  	cur := enc.buf.Len()
      239  	enc.EncodeDuration(val, enc)
      

      That can only happen if the EncodeDuration function is nil.

      This links back to a similar zap issue #645 for time stamps. In the comments it says that the encoders are not optional for certain parts. We should make sure that the encoders are set correctly as that looks like it is the correct solution.

        Attachments

          Activity

            People

            • Assignee:
              wilfreds Wilfred Spiegelenburg
              Reporter:
              wilfreds Wilfred Spiegelenburg
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 0.5h
                0.5h