Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-v0.40] Prepare release v0.40.2 #6620

Merged
merged 11 commits into from
Mar 5, 2024
Merged
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
Loading