Skip to content

Commit

Permalink
[release-v0.38] prepare for release v0.38.0-rc.1 (#5822)
Browse files Browse the repository at this point in the history
* packaging: fix grafana-agent-flow.river (#5802) (#5809)

* packaging: fix grafana-agent-flow.river (#5802)

Add needed label in default `grafana-agent-flow.river` default configuration used in downstream packages.

* Update CHANGELOG.md

(cherry picked from commit eac661f)

* misc: fix changelog entry (#5812)

PR #5802 accidentally added the changelog entry to a published release.

(cherry picked from commit bc3babc)

* feat(module/git): allow module.git use cached content when failed to fetch (#5712)

Signed-off-by: hainenber <[email protected]>
(cherry picked from commit 39b78a8)

* Fix converter output for prometheus.exporter.windows to not unnecessarily add empty blocks (#5817)

(cherry picked from commit 165914b)

* delete obsolete broken windows test (#5818)

(cherry picked from commit bcbc7ab)

* prepare for release v0.38.0-rc.1 (#5821)

(cherry picked from commit 7d775c1)

---------

Co-authored-by: Brice Waegeneire <[email protected]>
Co-authored-by: Đỗ Trọng Hải <[email protected]>
Co-authored-by: Erik Baranowski <[email protected]>
  • Loading branch information
4 people authored Nov 20, 2023
1 parent e77ac5f commit 55a2c85
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 105 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ internal API changes are not present.
Main (unreleased)
-----------------

v0.38.0-rc.1 (2023-11-20)
-------------------------

### Enhancements

- Allow agent to start with `module.git` config if cached before. (@hainenber)

### Bugfixes

- Fix default configuration file `grafana-agent-flow.river` used in downstream packages. (@bricewge)

- Fix converter output for prometheus.exporter.windows to not unnecessarily add empty blocks. (@erikbaranowski)

v0.38.0-rc.0 (2023-11-16)
-------------------------

Expand Down
18 changes: 16 additions & 2 deletions component/module/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package git

import (
"context"
"errors"
"path/filepath"
"reflect"
"sync"
Expand Down Expand Up @@ -91,8 +92,15 @@ func New(o component.Options, args Arguments) (*Component, error) {
argsChanged: make(chan struct{}, 1),
}

// Only acknowledge the error from Update if it's not a
// vcs.UpdateFailedError; vcs.UpdateFailedError means that the Git repo
// exists but we were just unable to update it.
if err := c.Update(args); err != nil {
return nil, err
if errors.As(err, &vcs.UpdateFailedError{}) {
level.Error(c.log).Log("msg", "failed to update repository", "err", err)
} else {
return nil, err
}
}
return c, nil
}
Expand Down Expand Up @@ -193,10 +201,16 @@ func (c *Component) Update(args component.Arguments) (err error) {
}

// Create or update the repo field.
// Failure to update repository makes the module loader temporarily use cached contents on disk
if c.repo == nil || !reflect.DeepEqual(repoOpts, c.repoOpts) {
r, err := vcs.NewGitRepo(context.Background(), repoPath, repoOpts)
if err != nil {
return err
if errors.As(err, &vcs.UpdateFailedError{}) {
level.Error(c.log).Log("msg", "failed to update repository", "err", err)
c.updateHealth(err)
} else {
return err
}
}
c.repo = r
c.repoOpts = repoOpts
Expand Down
28 changes: 18 additions & 10 deletions component/module/git/internal/vcs/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,24 @@ func NewGitRepo(ctx context.Context, storagePath string, opts GitRepoOptions) (*
}

// Fetch the latest contents. This may be a no-op if we just did a clone.
err = repo.FetchContext(ctx, &git.FetchOptions{
fetchRepoErr := repo.FetchContext(ctx, &git.FetchOptions{
RemoteName: "origin",
Force: true,
Auth: opts.Auth.Convert(),
})
if err != nil && !errors.Is(err, git.NoErrAlreadyUpToDate) {
return nil, UpdateFailedError{
Repository: opts.Repository,
Inner: err,
if fetchRepoErr != nil && !errors.Is(fetchRepoErr, git.NoErrAlreadyUpToDate) {
workTree, err := repo.Worktree()
if err != nil {
return nil, err
}
return &GitRepo{
opts: opts,
repo: repo,
workTree: workTree,
}, UpdateFailedError{
Repository: opts.Repository,
Inner: fetchRepoErr,
}
}

// Finally, hard reset to our requested revision.
Expand All @@ -92,7 +100,7 @@ func NewGitRepo(ctx context.Context, storagePath string, opts GitRepoOptions) (*
opts: opts,
repo: repo,
workTree: workTree,
}, nil
}, err
}

func isRepoCloned(dir string) bool {
Expand All @@ -103,15 +111,16 @@ func isRepoCloned(dir string) bool {
// Update updates the repository by fetching new content and re-checking out to
// latest version of Revision.
func (repo *GitRepo) Update(ctx context.Context) error {
err := repo.repo.FetchContext(ctx, &git.FetchOptions{
var err error
fetchRepoErr := repo.repo.FetchContext(ctx, &git.FetchOptions{
RemoteName: "origin",
Force: true,
Auth: repo.opts.Auth.Convert(),
})
if err != nil && !errors.Is(err, git.NoErrAlreadyUpToDate) {
if fetchRepoErr != nil && !errors.Is(fetchRepoErr, git.NoErrAlreadyUpToDate) {
return UpdateFailedError{
Repository: repo.opts.Repository,
Inner: err,
Inner: fetchRepoErr,
}
}

Expand All @@ -120,7 +129,6 @@ func (repo *GitRepo) Update(ctx context.Context) error {
if err != nil {
return InvalidRevisionError{Revision: repo.opts.Revision}
}

err = repo.workTree.Reset(&git.ResetOptions{
Commit: hash,
Mode: git.HardReset,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package build

import (
"strings"

"github.com/grafana/agent/component/discovery"
"github.com/grafana/agent/component/prometheus/exporter/windows"
"github.com/grafana/agent/pkg/integrations/windows_exporter"
Expand All @@ -13,12 +15,12 @@ func (b *IntegrationsConfigBuilder) appendWindowsExporter(config *windows_export

func toWindowsExporter(config *windows_exporter.Config) *windows.Arguments {
return &windows.Arguments{
EnabledCollectors: splitByCommaNullOnEmpty(config.EnabledCollectors),
EnabledCollectors: strings.Split(config.EnabledCollectors, ","),
Dfsr: windows.DfsrConfig{
SourcesEnabled: splitByCommaNullOnEmpty(config.Dfsr.SourcesEnabled),
SourcesEnabled: strings.Split(config.Dfsr.SourcesEnabled, ","),
},
Exchange: windows.ExchangeConfig{
EnabledList: splitByCommaNullOnEmpty(config.Exchange.EnabledList),
EnabledList: strings.Split(config.Exchange.EnabledList, ","),
},
IIS: windows.IISConfig{
AppBlackList: config.IIS.AppBlackList,
Expand All @@ -40,7 +42,7 @@ func toWindowsExporter(config *windows_exporter.Config) *windows.Arguments {
Where: config.MSMQ.Where,
},
MSSQL: windows.MSSQLConfig{
EnabledClasses: splitByCommaNullOnEmpty(config.MSSQL.EnabledClasses),
EnabledClasses: strings.Split(config.MSSQL.EnabledClasses, ","),
},
Network: windows.NetworkConfig{
BlackList: config.Network.BlackList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ prometheus.remote_write "metrics_default" {
}
}

prometheus.exporter.windows "integrations_windows_exporter" {
exchange { }

network {
exclude = ".+"
}
}
prometheus.exporter.windows "integrations_windows_exporter" { }

prometheus.scrape "integrations_windows" {
targets = prometheus.exporter.windows.integrations_windows_exporter.targets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@ http {
}
}

prometheus.exporter.windows "integrations_windows_exporter" {
exchange { }

network {
exclude = ".+"
}
}
prometheus.exporter.windows "integrations_windows_exporter" { }

prometheus.scrape "integrations_windows_exporter" {
targets = prometheus.exporter.windows.integrations_windows_exporter.targets
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ title: Grafana Agent
description: Grafana Agent is a flexible, performant, vendor-neutral, telemetry collector
weight: 350
cascade:
AGENT_RELEASE: v0.38.0-rc.0
AGENT_RELEASE: v0.38.0-rc.1
OTEL_VERSION: v0.87.0
---

Expand Down
4 changes: 2 additions & 2 deletions packaging/grafana-agent-flow/grafana-agent-flow.river
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ logging {
level = "warn"
}

prometheus.exporter.unix {
prometheus.exporter.unix "default" {
include_exporter_metrics = true
disable_collectors = ["mdadm"]
}

prometheus.scrape "default" {
targets = concat(
prometheus.exporter.unix.targets,
prometheus.exporter.unix.default.targets,
[{
// Self-collect metrics
job = "agent",
Expand Down
70 changes: 0 additions & 70 deletions pkg/integrations/windows_exporter/config_windows_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/operator/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package operator

// Supported versions of the Grafana Agent.
var (
DefaultAgentVersion = "v0.38.0-rc.0"
DefaultAgentVersion = "v0.38.0-rc.1"
DefaultAgentBaseImage = "grafana/agent"
DefaultAgentImage = DefaultAgentBaseImage + ":" + DefaultAgentVersion
)
Expand Down
2 changes: 1 addition & 1 deletion tools/gen-versioned-files/agent-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.38.0-rc.0
v0.38.0-rc.1

0 comments on commit 55a2c85

Please sign in to comment.