Skip to content

Commit

Permalink
[release-v0.40] Prepare release v0.40.2 (#6620)
Browse files Browse the repository at this point in the history
* Set permissions on the Grafana Agent [Flow] folder... (#6540)

* Set permissions on the  folder when installing via the windows installer rather than relying on the parent folder permissions.

Signed-off-by: erikbaranowski <39704712+erikbaranowski@users.noreply.github.com>

---------

Signed-off-by: erikbaranowski <39704712+erikbaranowski@users.noreply.github.com>
(cherry picked from commit 9e4d3b5)

* Loader reuse existing nodes on reload (#6288)

* Move UpdateBlock from componentNode interface to blockNode interface.

This change means that all blockNodes have now the possibility to update their managed block with the update River block content.

* Update the loader to update the managed block of a config node  on reload if it already existed in the graph.
With this optimization, we re-use existing nodes and update them instead of creating a new node.
This is especially useful for modules.

* add two new tests to check that on reload the config nodes behave as expected

* add updateblock to declare node

* update loader logic to detect duplicated blocks and reuse already defined blocks

* add updateblock to import config node

* update changelog

* move function and remove unnecessary check

(cherry picked from commit 2e9d5a2)

* fix(static/metrics/instance): fix duplicate metrics registration panic when recreating the instance (#6608)

Signed-off-by: hainenber <dotronghai96@gmail.com>
(cherry picked from commit 7a61067)

* chore(build): upgrade base image to frequently updated ECR-hosted Ubuntu (#6612)

Signed-off-by: hainenber <dotronghai96@gmail.com>
(cherry picked from commit fe513a4)

* prepare for 0.40.2 release (#6619)

(cherry picked from commit ed54148)

* Port promtail changes part 1 (#6559)

* Port promtail changes part 1

* changelog

(cherry picked from commit 1a642cf)

* remove accidentally committed web/ui/build folder

* fix issue with cherry-picking CHANGELOG.md

* fix bad conflict resolution

* fix test which failed due to bad merge conflict resolution

* On new windows installs, remove default read permissions from agent c… (#6622)

* On new windows installs, remove default read permissions from agent config

Signed-off-by: erikbaranowski <39704712+erikbaranowski@users.noreply.github.com>

* only apply permissions for a new install

Signed-off-by: erikbaranowski <39704712+erikbaranowski@users.noreply.github.com>

* Update CHANGELOG.md

Co-authored-by: Robert Fratto <robertfratto@gmail.com>

---------

Signed-off-by: erikbaranowski <39704712+erikbaranowski@users.noreply.github.com>
Co-authored-by: Robert Fratto <robertfratto@gmail.com>
(cherry picked from commit e8a3d29)

---------

Co-authored-by: Erik Baranowski <39704712+erikbaranowski@users.noreply.github.com>
Co-authored-by: William Dumont <william.dumont@grafana.com>
Co-authored-by: Đỗ Trọng Hải <41283691+hainenber@users.noreply.github.com>
Co-authored-by: Piotr <17101802+thampiotr@users.noreply.github.com>
  • Loading branch information
5 people committed Mar 5, 2024
1 parent 048c587 commit caf49e8
Show file tree
Hide file tree
Showing 39 changed files with 588 additions and 136 deletions.
116 changes: 58 additions & 58 deletions .drone/drone.yml

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,28 @@ This document contains a historical list of changes between releases. Only
changes that impact end-user behavior are listed; changes to documentation or
internal API changes are not present.

v0.40.2 (2024-03-05)
--------------------

### Bugfixes

- Set permissions on the `Grafana Agent [Flow]` folder when installing via the
windows installer rather than relying on the parent folder permissions. (@erikbaranowski)

- Set restricted viewing permissions on the `agent-config.yaml` (static mode) or
`config.river` (flow mode) when installing via the Windows installer if the
configuration file does not already exist. (@erikbaranowski)

- Fix an issue where the import config node would not run after a config reload. (@wildum)

- Fix an issue where Loki could reject a batch of logs when structured metadata feature is used. (@thampiotr)

- Fix a duplicate metrics registration panic when recreating static
mode metric instance's write handler. (@rfratto, @hainenber)

### Other changes

- Change the Docker base image for Linux containers to `public.ecr.aws/ubuntu/ubuntu:mantic`. (@hainenber)

v0.40.1 (2024-02-27)
--------------------
Expand Down
4 changes: 2 additions & 2 deletions cmd/grafana-agent-operator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# default when running `docker buildx build` or when DOCKER_BUILDKIT=1 is set
# in environment variables.

FROM --platform=$BUILDPLATFORM grafana/agent-build-image:0.30.4 as build
FROM --platform=$BUILDPLATFORM grafana/agent-build-image:0.33.0 as build
ARG BUILDPLATFORM
ARG TARGETPLATFORM
ARG TARGETOS
Expand All @@ -22,7 +22,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
RELEASE_BUILD=${RELEASE_BUILD} VERSION=${VERSION} \
make operator

FROM ubuntu:mantic
FROM public.ecr.aws/ubuntu/ubuntu:mantic

LABEL org.opencontainers.image.source="https://github.com/grafana/agent"

Expand Down
4 changes: 2 additions & 2 deletions cmd/grafana-agent/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# default when running `docker buildx build` or when DOCKER_BUILDKIT=1 is set
# in environment variables.

FROM --platform=$BUILDPLATFORM grafana/agent-build-image:0.30.4 as build
FROM --platform=$BUILDPLATFORM grafana/agent-build-image:0.33.0 as build
ARG BUILDPLATFORM
ARG TARGETPLATFORM
ARG TARGETOS
Expand All @@ -30,7 +30,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
GOEXPERIMENT=${GOEXPERIMENT} \
make agent

FROM ubuntu:mantic
FROM public.ecr.aws/ubuntu/ubuntu:mantic

LABEL org.opencontainers.image.source="https://github.com/grafana/agent"

Expand Down
2 changes: 1 addition & 1 deletion cmd/grafana-agent/Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM grafana/agent-build-image:0.30.4-windows as builder
FROM grafana/agent-build-image:0.33.0-windows as builder
ARG VERSION
ARG RELEASE_BUILD=1

Expand Down
4 changes: 2 additions & 2 deletions cmd/grafana-agentctl/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# default when running `docker buildx build` or when DOCKER_BUILDKIT=1 is set
# in environment variables.

FROM --platform=$BUILDPLATFORM grafana/agent-build-image:0.30.4 as build
FROM --platform=$BUILDPLATFORM grafana/agent-build-image:0.33.0 as build
ARG BUILDPLATFORM
ARG TARGETPLATFORM
ARG TARGETOS
Expand All @@ -23,7 +23,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
GO_TAGS="netgo promtail_journal_enabled" \
make agentctl

FROM ubuntu:mantic
FROM public.ecr.aws/ubuntu/ubuntu:mantic

LABEL org.opencontainers.image.source="https://github.com/grafana/agent"

Expand Down
2 changes: 1 addition & 1 deletion cmd/grafana-agentctl/Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM grafana/agent-build-image:0.30.4-windows as builder
FROM grafana/agent-build-image:0.33.0-windows as builder
ARG VERSION
ARG RELEASE_BUILD=1

Expand Down
14 changes: 11 additions & 3 deletions component/common/loki/client/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func newBatch(maxStreams int, entries ...loki.Entry) *batch {

// add an entry to the batch
func (b *batch) add(entry loki.Entry) error {
b.totalBytes += len(entry.Line)
b.totalBytes += entrySize(entry.Entry)

// Append the entry to an already existing stream (if any)
labels := labelsMapToString(entry.Labels, ReservedLabelTenantID)
Expand Down Expand Up @@ -150,8 +150,8 @@ func (b *batch) sizeBytes() int {

// sizeBytesAfter returns the size of the batch after the input entry
// will be added to the batch itself
func (b *batch) sizeBytesAfter(line string) int {
return b.totalBytes + len(line)
func (b *batch) sizeBytesAfter(entry logproto.Entry) int {
return b.totalBytes + entrySize(entry)
}

// age of the batch since its creation
Expand Down Expand Up @@ -201,3 +201,11 @@ func (b *batch) reportAsSentData(h SentDataMarkerHandler) {
h.UpdateSentData(seg, data)
}
}

func entrySize(entry logproto.Entry) int {
structuredMetadataSize := 0
for _, label := range entry.StructuredMetadata {
structuredMetadataSize += label.Size()
}
return len(entry.Line) + structuredMetadataSize
}
3 changes: 2 additions & 1 deletion component/common/loki/client/batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ func TestBatch_add(t *testing.T) {
inputEntries: []loki.Entry{
{Labels: model.LabelSet{}, Entry: logEntries[0].Entry},
{Labels: model.LabelSet{}, Entry: logEntries[1].Entry},
{Labels: model.LabelSet{}, Entry: logEntries[7].Entry},
},
expectedSizeBytes: len(logEntries[0].Entry.Line) + len(logEntries[1].Entry.Line),
expectedSizeBytes: entrySize(logEntries[0].Entry) + entrySize(logEntries[0].Entry) + entrySize(logEntries[7].Entry),
},
"multiple streams with multiple log entries": {
inputEntries: []loki.Entry{
Expand Down
2 changes: 1 addition & 1 deletion component/common/loki/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ func (c *client) run() {

// If adding the entry to the batch will increase the size over the max
// size allowed, we do send the current batch and then create a new one
if batch.sizeBytesAfter(e.Line) > c.cfg.BatchSize {
if batch.sizeBytesAfter(e.Entry) > c.cfg.BatchSize {
c.sendBatch(tenantID, batch)

batches[tenantID] = newBatch(c.maxStreams, e)
Expand Down
12 changes: 12 additions & 0 deletions component/common/loki/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"testing"
"time"

"github.com/grafana/loki/pkg/push"

"github.com/go-kit/log"
"github.com/grafana/dskit/backoff"
"github.com/grafana/dskit/flagext"
Expand All @@ -34,6 +36,16 @@ var logEntries = []loki.Entry{
{Labels: model.LabelSet{"__tenant_id__": "tenant-1"}, Entry: logproto.Entry{Timestamp: time.Unix(5, 0).UTC(), Line: "line5"}},
{Labels: model.LabelSet{"__tenant_id__": "tenant-2"}, Entry: logproto.Entry{Timestamp: time.Unix(6, 0).UTC(), Line: "line6"}},
{Labels: model.LabelSet{}, Entry: logproto.Entry{Timestamp: time.Unix(6, 0).UTC(), Line: "line0123456789"}},
{
Labels: model.LabelSet{},
Entry: logproto.Entry{
Timestamp: time.Unix(7, 0).UTC(),
Line: "line7",
StructuredMetadata: push.LabelsAdapter{
{Name: "trace_id", Value: "12345"},
},
},
},
}

func TestClient_Handle(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion component/common/loki/client/queue_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ func (c *queueClient) appendSingleEntry(segmentNum int, lbs model.LabelSet, e lo

// If adding the entry to the batch will increase the size over the max
// size allowed, we do send the current batch and then create a new one
if batch.sizeBytesAfter(e.Line) > c.cfg.BatchSize {
if batch.sizeBytesAfter(e) > c.cfg.BatchSize {
c.sendQueue.enqueue(queuedBatch{
TenantID: tenantID,
Batch: batch,
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.40.1
AGENT_RELEASE: v0.40.2
OTEL_VERSION: v0.87.0
---

Expand Down
28 changes: 27 additions & 1 deletion packaging/grafana-agent-flow/windows/install_script.nsis
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,13 @@ Section "install"
Pop $0

# Configure the out path and copy files to it.
SetOutPath "$INSTDIR"
IfFileExists "$INSTDIR" Exists NotExists
NotExists:
SetOutPath "$INSTDIR"
Call SetFolderPermissions
Exists:
SetOutPath "$INSTDIR"

File "..\..\..\dist.temp\grafana-agent-flow-windows-amd64.exe"
File "..\..\..\dist.temp\grafana-agent-service-windows-amd64.exe"
File "logo.ico"
Expand Down Expand Up @@ -109,6 +115,14 @@ Function CreateConfig
Return
CreateNewConfig:
File "config.river"

# Set permissions on the config file
AccessControl::DisableFileInheritance "$INSTDIR\config.river"
AccessControl::SetFileOwner "$INSTDIR\config.river" "Administrators"
AccessControl::ClearOnFile "$INSTDIR\config.river" "Administrators" "FullAccess"
AccessControl::SetOnFile "$INSTDIR\config.river" "SYSTEM" "FullAccess"
AccessControl::GrantOnFile "$INSTDIR\config.river" "Everyone" "ListDirectory"
AccessControl::GrantOnFile "$INSTDIR\config.river" "Everyone" "ReadAttributes"
Return
FunctionEnd

Expand Down Expand Up @@ -164,6 +178,18 @@ Function InitializeRegistry
Return
FunctionEnd

Function SetFolderPermissions
# Set permissions on the install directory
AccessControl::DisableFileInheritance $INSTDIR
AccessControl::SetFileOwner $INSTDIR "Administrators"
AccessControl::ClearOnFile $INSTDIR "Administrators" "FullAccess"
AccessControl::SetOnFile $INSTDIR "SYSTEM" "FullAccess"
AccessControl::GrantOnFile $INSTDIR "Everyone" "ListDirectory"
AccessControl::GrantOnFile $INSTDIR "Everyone" "GenericExecute"
AccessControl::GrantOnFile $INSTDIR "Everyone" "GenericRead"
AccessControl::GrantOnFile $INSTDIR "Everyone" "ReadAttributes"
FunctionEnd

# Automatically called when uninstalling.
Function un.onInit
SetShellVarContext all
Expand Down
27 changes: 26 additions & 1 deletion packaging/grafana-agent/windows/install_script.nsis
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ Function Install
nsExec::ExecToLog 'sc stop "Grafana Agent"'
Pop $0
# Files for the install directory - to build the installer, these should be in the same directory as the install script (this file)
setOutPath $INSTDIR
IfFileExists "$INSTDIR" Exists NotExists
NotExists:
SetOutPath "$INSTDIR"
Call SetFolderPermissions
Exists:
SetOutPath "$INSTDIR"
# Files added here should be removed by the uninstaller (see section "uninstall")
file "grafana-agent-windows-amd64.exe"
file "logo.ico"
Expand Down Expand Up @@ -186,9 +191,29 @@ Function WriteConfig
FileWrite $9 ` enabled: true`
${EndIf}
FileClose $9 # and close the file

# Set permissions on the config file
AccessControl::DisableFileInheritance "$INSTDIR\agent-config.yaml"
AccessControl::SetFileOwner "$INSTDIR\agent-config.yaml" "Administrators"
AccessControl::ClearOnFile "$INSTDIR\agent-config.yaml" "Administrators" "FullAccess"
AccessControl::SetOnFile "$INSTDIR\agent-config.yaml" "SYSTEM" "FullAccess"
AccessControl::GrantOnFile "$INSTDIR\agent-config.yaml" "Everyone" "ListDirectory"
AccessControl::GrantOnFile "$INSTDIR\agent-config.yaml" "Everyone" "ReadAttributes"
Return
FunctionEnd

Function SetFolderPermissions
# Set permissions on the install directory
AccessControl::DisableFileInheritance $INSTDIR
AccessControl::SetFileOwner $INSTDIR "Administrators"
AccessControl::ClearOnFile $INSTDIR "Administrators" "FullAccess"
AccessControl::SetOnFile $INSTDIR "SYSTEM" "FullAccess"
AccessControl::GrantOnFile $INSTDIR "Everyone" "ListDirectory"
AccessControl::GrantOnFile $INSTDIR "Everyone" "GenericExecute"
AccessControl::GrantOnFile $INSTDIR "Everyone" "GenericRead"
AccessControl::GrantOnFile $INSTDIR "Everyone" "ReadAttributes"
FunctionEnd

# Uninstaller
Function un.onInit
SetShellVarContext all
Expand Down
9 changes: 5 additions & 4 deletions pkg/flow/internal/controller/block_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import (
type BlockNode interface {
dag.Node

// Block returns the current block of the managed config node.
// Block returns the current block managed by the node.
Block() *ast.BlockStmt

// Evaluate updates the arguments for the managed component
// by re-evaluating its River block with the provided scope. The managed component
// will be built the first time Evaluate is called.
// Evaluate updates the arguments by re-evaluating the River block with the provided scope.
//
// Evaluate will return an error if the River block cannot be evaluated or if
// decoding to arguments fails.
Evaluate(scope *vm.Scope) error

// UpdateBlock updates the River block used to construct arguments.
UpdateBlock(b *ast.BlockStmt)
}
4 changes: 0 additions & 4 deletions pkg/flow/internal/controller/component_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package controller

import (
"github.com/grafana/agent/component"
"github.com/grafana/river/ast"
)

// ComponentNode is a generic representation of a Flow component.
Expand All @@ -27,9 +26,6 @@ type ComponentNode interface {
// ID returns the component ID of the managed component from its River block.
ID() ComponentID

// UpdateBlock updates the River block used to construct arguments for the managed component.
UpdateBlock(b *ast.BlockStmt)

// ModuleIDs returns the current list of modules managed by the component.
ModuleIDs() []string
}
Loading

0 comments on commit caf49e8

Please sign in to comment.