Commits on Source 13

  • Igor's avatar
    Add --log-format=json for machine-readable output · baa2c069
    Igor authored
    gitlab-runner consumes docker-machine's stdout and stderr line by line and
    re-logs each line as an opaque message. With JSON output it can pick up
    the level and, in a following change, the create phase a line belongs to.
    
    The format is selected by --log-format or MACHINE_LOG_FORMAT and applied
    before cli parsing, like --debug, so the version line logged before
    app.Run uses the right format too. Driver plugin processes return from
    main before that point and keep text output, which the main process
    relays through its own logger.
    baa2c069
  • Igor's avatar
    Tag log entries with the create phase · 122ef475
    Igor authored
    Machine creation is one docker-machine invocation covering pre-create
    checks, the driver's create call, waiting for the instance to run,
    waiting for SSH, OS detection, provisioning, and the Docker connection
    check. Nothing in the output said which of those a given line, or a
    given stretch of wall clock time, belonged to; during INC-13960 that
    breakdown had to be reconstructed by hand from log timestamps.
    
    log.SetPhase marks the phase; every entry logged afterwards, including
    relayed driver plugin output, carries it as "phase" in JSON output. The
    text format ignores it. No durations are computed here: each entry has
    a timestamp and the phase changes on the first line of the next one, so
    consumers get durations by diffing, including for a phase that never
    finished because the process was killed.
    122ef475
  • Igor's avatar
    Replace SetPhase with per-call fields · 75a1916a
    Igor authored
    Global logger state was the wrong tool: a field belongs to the line it
    describes. log.WithField/WithFields return a logger that attaches the
    fields to its entries; the JSON format emits them as keys, the text
    format appends them as "key=value" so nothing is lost when running by
    hand.
    
    The phase now sits on the first line of each create phase only. The
    variable parts of the create-path messages (provisioner, region,
    machine type, zone, operation name, attempt counters) move from the
    message text into fields so they can be filtered on directly.
    75a1916a
  • Igor's avatar
    Modernize the log package · ea92a241
    Igor authored
    maps.Copy for field merging, slices.Sorted(maps.Keys()) for the text
    format's key order, and any instead of interface{} throughout the
    package so the new code and the existing signatures match.
    ea92a241
  • Igor's avatar
    Add a bootstrap phase for certificate generation · e0de26d6
    Igor authored
    Certificate bootstrap ran before the first phase line, so its time
    (about 1.5s per create in the sandbox) was in the total but in no
    phase. BootstrapCertificates only logs when it has to generate certs,
    hence the explicit line.
    e0de26d6
  • Igor's avatar
    Drop the package-level debug flag · e964be02
    Igor authored
    It only existed so SetDebug before SetFormat would carry over, and
    nothing calls them in that order.
    e964be02
  • Igor's avatar
    Carry JSON output and fields across the driver plugin boundary · f97914da
    Igor authored
    Drivers run as a re-exec of this binary, which returned from main before
    the log format was applied, so their output was text and the parent
    relayed it as "(name) message". In JSON mode the zone and machine type
    the driver logs as fields ended up inside the message string.
    
    The parent now passes its format to the plugin through MACHINE_LOG_FORMAT,
    the plugin applies it, and the relay parses JSON lines and re-logs them
    with their fields plus a "machine" field. Text mode and non-JSON lines
    keep the prefix form.
    
    History entries now include fields, rendered as key=value, so the crash
    report keeps the data that moved out of message text.
    f97914da
  • Igor's avatar
    Pass the log format to the plugin through its own env var · 0534be1a
    Igor authored
    The log package has no business knowing about MACHINE_LOG_FORMAT. The
    parent/plugin handshake already uses MACHINE_PLUGIN_* variables declared
    in localbinary; the format is one more of those.
    0534be1a
  • Igor's avatar
    Record the emitted JSON line in history · 2fd1c7f6
    Igor authored
    History mirrors output in both formats instead of flattening JSON
    entries to key=value text.
    2fd1c7f6
  • Igor's avatar
    Drop the sprint and renderFields helpers · 0598e9dd
    Igor authored
    fmt.Sprint is what history always used for these calls, and the
    key=value rendering has one caller.
    0598e9dd
  • Igor's avatar
  • Igor's avatar
    Merge branch 'iwiedler/json-log-format-phases' into 'main' · 284be165
    Igor authored
    Add JSON log format and create phase tagging
    
    See merge request !193
    
    Merged-by: Igor's avatarIgor <iwiedler@gitlab.com>
    Approved-by: default avatarTomasz Maczukin <tomasz@maczukin.pl>
    Reviewed-by: default avatarTomasz Maczukin <tomasz@maczukin.pl>
    Reviewed-by: default avatarGitLab Duo <gitlab-duo@gitlab.com>
    284be165
  • Igor's avatar
    Bump version to 0.16.2-gitlab.55 · fda71033
    Igor authored
    fda71033
Loading
Loading