diff --git a/.gitlab/deploy_containers/deploy_containers_a7.yml b/.gitlab/deploy_containers/deploy_containers_a7.yml index 5f1f8f9d137fe4..2d18d21dcf1bae 100644 --- a/.gitlab/deploy_containers/deploy_containers_a7.yml +++ b/.gitlab/deploy_containers/deploy_containers_a7.yml @@ -32,6 +32,17 @@ include: - if [[ "$FLAVOR" == "-linux" ]]; then export IMG_SOURCES="${IMG_LINUX_SOURCES}"; elif [[ "$FLAVOR" == "-servercore" ]]; then export IMG_SOURCES="${IMG_WINDOWS_SOURCES}"; else export IMG_SOURCES="${IMG_LINUX_SOURCES},${IMG_WINDOWS_SOURCES}"; fi - export IMG_DESTINATIONS="${AGENT_REPOSITORY}:${VERSION}${FLAVOR}${JMX}" +.deploy_containers-a7_win_only_image: + extends: .docker_publish_job_definition + stage: deploy_containers + dependencies: [] + before_script: + - OS=$(echo $OS_LTSC_MAPPING | cut -d ':' -f 1) + - LTSC_VERSION=$(echo $OS_LTSC_MAPPING | cut -d ':' -f 2) + - if [[ "$VERSION" == "" ]]; then VERSION="$(inv agent.version --major-version 7 --url-safe --pipeline-id $PARENT_PIPELINE_ID)" || exit $?; fi + - IMG_BASE_SRC="${SRC_AGENT}:v${PARENT_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}" + - export IMG_SOURCES="${IMG_BASE_SRC}-7${JMX}-win${OS}${FLAVOR}-amd64" + - export IMG_DESTINATIONS="${AGENT_REPOSITORY}:${VERSION}${FLAVOR}-ltsc${LTSC_VERSION}${JMX}" .deploy_containers-a7_external: extends: .deploy_containers-a7-base @@ -45,6 +56,20 @@ include: - "-servercore" - "-linux" +.deploy_containers-a7_win_only_external: + extends: .deploy_containers-a7_win_only_image + parallel: + matrix: + - JMX: + - "" + - "-jmx" + OS_LTSC_MAPPING: + - "ltsc2022:2022" + - "1809:2019" + FLAVOR: + - "" + - "-servercore" + .deploy_containers-a7-base-ot: extends: .docker_publish_job_definition stage: deploy_containers @@ -59,6 +84,11 @@ deploy_containers-a7: rules: !reference [.manual_on_deploy_auto_on_rc] +deploy_containers-a7-win-only: + extends: .deploy_containers-a7_win_only_external + rules: + !reference [.manual_on_deploy_auto_on_rc] + deploy_containers-a7-ot: extends: .deploy_containers-a7-base-ot rules: @@ -76,6 +106,13 @@ deploy_containers-a7-rc: variables: VERSION: 7-rc +deploy_containers-a7-win-only-rc: + extends: .deploy_containers-a7_win_only_external + rules: + !reference [.on_rc] + variables: + VERSION: 7-rc + deploy_containers-a7-ot-rc: extends: .deploy_containers-a7-base-ot rules: @@ -159,6 +196,25 @@ deploy_containers_latest-a7: - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${PARENT_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7-jmx" IMG_SOURCES: "%BASE%-win1809-servercore-amd64,%BASE%-winltsc2022-servercore-amd64" IMG_DESTINATIONS: ${AGENT_REPOSITORY}:7-servercore-jmx,${AGENT_REPOSITORY}:latest-servercore-jmx + # Windows only images + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${PARENT_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7" + IMG_SOURCES: "%BASE%-win1809-amd64" + IMG_DESTINATIONS: ${AGENT_REPOSITORY}:7,${AGENT_REPOSITORY}:latest-ltsc2019 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${PARENT_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7" + IMG_SOURCES: "%BASE%-winltsc2022-amd64" + IMG_DESTINATIONS: ${AGENT_REPOSITORY}:7,${AGENT_REPOSITORY}:latest-ltsc2022 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${PARENT_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7" + IMG_SOURCES: "%BASE%-win1809-servercore-amd64" + IMG_DESTINATIONS: ${AGENT_REPOSITORY}:7-servercore-ltsc2019,${AGENT_REPOSITORY}:latest-servercore-ltsc2019 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${PARENT_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7" + IMG_SOURCES: "BASE%-winltsc2022-servercore-amd64" + IMG_DESTINATIONS: ${AGENT_REPOSITORY}:7-servercore-ltsc2022,${AGENT_REPOSITORY}:latest-servercore-ltsc2022 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${PARENT_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7-jmx" + IMG_SOURCES: "%BASE%-winltsc2022-servercore-amd64" + IMG_DESTINATIONS: ${AGENT_REPOSITORY}:7-servercore-ltsc2022-jmx,${AGENT_REPOSITORY}:latest-servercore-ltsc2022-jmx + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${PARENT_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7-jmx" + IMG_SOURCES: "%BASE%-winltsc1809-servercore-amd64" + IMG_DESTINATIONS: ${AGENT_REPOSITORY}:7-servercore-ltsc2019-jmx,${AGENT_REPOSITORY}:latest-servercore-ltsc2019-jmx deploy_containers_latest-a7_internal: extends: .docker_publish_job_definition diff --git a/.gitlab/dev_container_deploy/docker_windows.yml b/.gitlab/dev_container_deploy/docker_windows.yml index 850df67aee5b53..734c81cacd36c6 100644 --- a/.gitlab/dev_container_deploy/docker_windows.yml +++ b/.gitlab/dev_container_deploy/docker_windows.yml @@ -20,6 +20,7 @@ dev_branch-a7-windows: IMG_REGISTRIES: dev parallel: matrix: + # Multi-arch - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7" IMG_SOURCES: "%BASE%-win1809-amd64,%BASE%-winltsc2022-amd64" IMG_DESTINATIONS: agent-dev:${CI_COMMIT_REF_SLUG}-py3-win @@ -32,6 +33,32 @@ dev_branch-a7-windows: - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7-jmx" IMG_SOURCES: "%BASE%-win1809-servercore-amd64,%BASE%-winltsc2022-servercore-amd64" IMG_DESTINATIONS: agent-dev:${CI_COMMIT_REF_SLUG}-py3-jmx-win-servercore + # ltsc2019 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7" + IMG_SOURCES: "%BASE%-win1809-amd64" + IMG_DESTINATIONS: agent-dev:${CI_COMMIT_REF_SLUG}-py3-win-ltsc2019 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7-jmx" + IMG_SOURCES: "%BASE%-win1809-amd64" + IMG_DESTINATIONS: agent-dev:${CI_COMMIT_REF_SLUG}-py3-jmx-win-ltsc2019 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7" + IMG_SOURCES: "%BASE%-win1809-servercore-amd64" + IMG_DESTINATIONS: agent-dev:${CI_COMMIT_REF_SLUG}-py3-win-servercore-ltsc2019 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7-jmx" + IMG_SOURCES: "%BASE%-win1809-servercore-amd64" + IMG_DESTINATIONS: agent-dev:${CI_COMMIT_REF_SLUG}-py3-jmx-win-servercore-ltsc2019 + # ltsc2022 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7" + IMG_SOURCES: "%BASE%-winltsc2022-amd64" + IMG_DESTINATIONS: agent-dev:${CI_COMMIT_REF_SLUG}-py3-win-ltsc2022 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7-jmx" + IMG_SOURCES: "%BASE%-winltsc2022-amd64" + IMG_DESTINATIONS: agent-dev:${CI_COMMIT_REF_SLUG}-py3-jmx-win-ltsc2022 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7" + IMG_SOURCES: "%BASE%-winltsc2022-servercore-amd64" + IMG_DESTINATIONS: agent-dev:${CI_COMMIT_REF_SLUG}-py3-win-servercore-ltsc2022 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7-jmx" + IMG_SOURCES: "%BASE%-winltsc2022-servercore-amd64" + IMG_DESTINATIONS: agent-dev:${CI_COMMIT_REF_SLUG}-py3-jmx-win-servercore-ltsc2022 dev_master-a7-windows: extends: .docker_publish_job_definition @@ -51,6 +78,7 @@ dev_master-a7-windows: IMG_REGISTRIES: dev parallel: matrix: + # Multi-arch - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7" IMG_SOURCES: "%BASE%-win1809-amd64,%BASE%-winltsc2022-amd64" IMG_DESTINATIONS: agent-dev:master-py3-win @@ -63,6 +91,32 @@ dev_master-a7-windows: - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7-jmx" IMG_SOURCES: "%BASE%-win1809-servercore-amd64,%BASE%-winltsc2022-servercore-amd64" IMG_DESTINATIONS: agent-dev:master-py3-jmx-win-servercore + # ltsc2019 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7" + IMG_SOURCES: "%BASE%-win1809-amd64" + IMG_DESTINATIONS: agent-dev:${CI_COMMIT_REF_SLUG}-py3-win-ltsc2019 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7-jmx" + IMG_SOURCES: "%BASE%-win1809-amd64" + IMG_DESTINATIONS: agent-dev:${CI_COMMIT_REF_SLUG}-py3-jmx-win-ltsc2019 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7" + IMG_SOURCES: "%BASE%-win1809-servercore-amd64" + IMG_DESTINATIONS: agent-dev:${CI_COMMIT_REF_SLUG}-py3-win-servercore-ltsc2019 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7-jmx" + IMG_SOURCES: "%BASE%-win1809-servercore-amd64" + IMG_DESTINATIONS: agent-dev:${CI_COMMIT_REF_SLUG}-py3-jmx-win-servercore-ltsc2019 + # ltsc2022 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7" + IMG_SOURCES: "%BASE%-winltsc2022-amd64" + IMG_DESTINATIONS: agent-dev:${CI_COMMIT_REF_SLUG}-py3-win-ltsc2022 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7-jmx" + IMG_SOURCES: "%BASE%-winltsc2022-amd64" + IMG_DESTINATIONS: agent-dev:${CI_COMMIT_REF_SLUG}-py3-jmx-win-ltsc2022 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7" + IMG_SOURCES: "%BASE%-winltsc2022-servercore-amd64" + IMG_DESTINATIONS: agent-dev:${CI_COMMIT_REF_SLUG}-py3-win-servercore-ltsc2022 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7-jmx" + IMG_SOURCES: "%BASE%-winltsc2022-servercore-amd64" + IMG_DESTINATIONS: agent-dev:${CI_COMMIT_REF_SLUG}-py3-jmx-win-servercore-ltsc2022 dev_nightly-a7-windows: extends: .docker_publish_job_definition @@ -82,6 +136,7 @@ dev_nightly-a7-windows: IMG_REGISTRIES: dev parallel: matrix: + # Multi-arch - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7" IMG_SOURCES: "%BASE%-win1809-amd64,%BASE%-winltsc2022-amd64" IMG_DESTINATIONS: agent-dev:nightly-${CI_COMMIT_SHORT_SHA}-py3-win @@ -94,3 +149,29 @@ dev_nightly-a7-windows: - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7-jmx" IMG_SOURCES: "%BASE%-win1809-servercore-amd64,%BASE%-winltsc2022-servercore-amd64" IMG_DESTINATIONS: agent-dev:nightly-${CI_COMMIT_SHORT_SHA}-py3-jmx-win-servercore + # ltsc2019 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7" + IMG_SOURCES: "%BASE%-win1809-amd64" + IMG_DESTINATIONS: agent-dev:${CI_COMMIT_REF_SLUG}-py3-win-ltsc2019 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7-jmx" + IMG_SOURCES: "%BASE%-win1809-amd64" + IMG_DESTINATIONS: agent-dev:${CI_COMMIT_REF_SLUG}-py3-jmx-win-ltsc2019 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7" + IMG_SOURCES: "%BASE%-win1809-servercore-amd64" + IMG_DESTINATIONS: agent-dev:${CI_COMMIT_REF_SLUG}-py3-win-servercore-ltsc2019 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7-jmx" + IMG_SOURCES: "%BASE%-win1809-servercore-amd64" + IMG_DESTINATIONS: agent-dev:${CI_COMMIT_REF_SLUG}-py3-jmx-win-servercore-ltsc2019 + # ltsc2022 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7" + IMG_SOURCES: "%BASE%-winltsc2022-amd64" + IMG_DESTINATIONS: agent-dev:${CI_COMMIT_REF_SLUG}-py3-win-ltsc2022 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7-jmx" + IMG_SOURCES: "%BASE%-winltsc2022-amd64" + IMG_DESTINATIONS: agent-dev:${CI_COMMIT_REF_SLUG}-py3-jmx-win-ltsc2022 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7" + IMG_SOURCES: "%BASE%-winltsc2022-servercore-amd64" + IMG_DESTINATIONS: agent-dev:${CI_COMMIT_REF_SLUG}-py3-win-servercore-ltsc2022 + - IMG_VARIABLES: "BASE=${SRC_AGENT}:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-7-jmx" + IMG_SOURCES: "%BASE%-winltsc2022-servercore-amd64" + IMG_DESTINATIONS: agent-dev:${CI_COMMIT_REF_SLUG}-py3-jmx-win-servercore-ltsc2022 diff --git a/.gitlab/packaging/rpm.yml b/.gitlab/packaging/rpm.yml index adddce75a76d99..f1c147ef52e792 100644 --- a/.gitlab/packaging/rpm.yml +++ b/.gitlab/packaging/rpm.yml @@ -76,13 +76,13 @@ agent_suse-x64-a7: extends: [.package_suse_rpm_common, .package_rpm_agent_7, .package_rpm_x86] needs: ["datadog-agent-7-x64"] variables: - DD_PRODUCT: agent + DD_PROJECT: agent agent_suse-arm64-a7: extends: [.package_suse_rpm_common, .package_rpm_agent_7, .package_rpm_arm64] needs: ["datadog-agent-7-arm64"] variables: - DD_PRODUCT: agent + DD_PROJECT: agent installer_rpm-amd64: extends: [.package_rpm_common, .package_rpm_agent_7, .package_rpm_x86] diff --git a/pkg/fleet/env/env.go b/pkg/fleet/env/env.go index 8bdd849d8f06e8..cd65a7d8e7e8be 100644 --- a/pkg/fleet/env/env.go +++ b/pkg/fleet/env/env.go @@ -7,13 +7,16 @@ package env import ( + "context" "fmt" "os" "slices" "strings" + "time" "github.com/DataDog/datadog-agent/pkg/config/model" "github.com/DataDog/datadog-agent/pkg/config/utils" + "github.com/DataDog/datadog-agent/pkg/util/hostname" ) const ( @@ -38,6 +41,7 @@ const ( envAgentUserNameCompat = "DDAGENTUSER_NAME" envTags = "DD_TAGS" envExtraTags = "DD_EXTRA_TAGS" + envHostname = "DD_HOSTNAME" ) var defaultEnv = Env{ @@ -98,7 +102,8 @@ type Env struct { CDNEnabled bool CDNLocalDirPath string - Tags []string + Tags []string + Hostname string } // FromEnv returns an Env struct with values from the environment. @@ -139,11 +144,18 @@ func FromEnv() *Env { strings.FieldsFunc(os.Getenv(envTags), splitFunc), strings.FieldsFunc(os.Getenv(envExtraTags), splitFunc)..., ), + Hostname: os.Getenv(envHostname), } } // FromConfig returns an Env struct with values from the configuration. func FromConfig(config model.Reader) *Env { + ctx, cancel := context.WithTimeout(context.Background(), time.Second) + defer cancel() + hostname, err := hostname.Get(ctx) + if err != nil { + hostname = "unknown" + } return &Env{ APIKey: utils.SanitizeAPIKey(config.GetString("api_key")), Site: config.GetString("site"), @@ -154,6 +166,7 @@ func FromConfig(config model.Reader) *Env { RegistryUsername: config.GetString("installer.registry.username"), RegistryPassword: config.GetString("installer.registry.password"), Tags: utils.GetConfiguredTags(config, false), + Hostname: hostname, } } @@ -199,6 +212,9 @@ func (e *Env) ToEnv() []string { if len(e.Tags) > 0 { env = append(env, envTags+"="+strings.Join(e.Tags, ",")) } + if len(e.Hostname) > 0 { + env = append(env, envHostname+"="+e.Hostname) + } env = append(env, overridesByNameToEnv(envRegistryURL, e.RegistryOverrideByImage)...) env = append(env, overridesByNameToEnv(envRegistryAuth, e.RegistryAuthOverrideByImage)...) env = append(env, overridesByNameToEnv(envRegistryUsername, e.RegistryUsernameByImage)...) diff --git a/pkg/fleet/env/env_test.go b/pkg/fleet/env/env_test.go index c1691313947ea1..790d6a748fc1e4 100644 --- a/pkg/fleet/env/env_test.go +++ b/pkg/fleet/env/env_test.go @@ -37,7 +37,8 @@ func TestFromEnv(t *testing.T) { InstallScript: InstallScriptEnv{ APMInstrumentationEnabled: APMInstrumentationNotSet, }, - Tags: []string{}, + Tags: []string{}, + Hostname: "", }, }, { @@ -68,6 +69,7 @@ func TestFromEnv(t *testing.T) { envAgentUserName: "customuser", envTags: "k1:v1,k2:v2", envExtraTags: "k3:v3,k4:v4", + envHostname: "hostname", }, expected: &Env{ APIKey: "123456", @@ -111,7 +113,8 @@ func TestFromEnv(t *testing.T) { InstallScript: InstallScriptEnv{ APMInstrumentationEnabled: APMInstrumentationEnabledAll, }, - Tags: []string{"k1:v1", "k2:v2", "k3:v3", "k4:v4"}, + Tags: []string{"k1:v1", "k2:v2", "k3:v3", "k4:v4"}, + Hostname: "hostname", }, }, { @@ -167,6 +170,7 @@ func TestFromEnv(t *testing.T) { DefaultPackagesInstallOverride: map[string]bool{}, DefaultPackagesVersionOverride: map[string]string{}, Tags: []string{}, + Hostname: "", }, }, } @@ -234,7 +238,8 @@ func TestToEnv(t *testing.T) { "dotnet": "latest", "ruby": "1.2", }, - Tags: []string{"k1:v1", "k2:v2"}, + Tags: []string{"k1:v1", "k2:v2"}, + Hostname: "hostname", }, expected: []string{ "DD_API_KEY=123456", @@ -259,6 +264,7 @@ func TestToEnv(t *testing.T) { "DD_INSTALLER_DEFAULT_PKG_VERSION_PACKAGE=1.2.3", "DD_INSTALLER_DEFAULT_PKG_VERSION_ANOTHER_PACKAGE=4.5.6", "DD_TAGS=k1:v1,k2:v2", + "DD_HOSTNAME=hostname", }, }, } diff --git a/pkg/fleet/internal/cdn/cdn_http.go b/pkg/fleet/internal/cdn/cdn_http.go index aaabe47412fe1e..98633efdf46d40 100644 --- a/pkg/fleet/internal/cdn/cdn_http.go +++ b/pkg/fleet/internal/cdn/cdn_http.go @@ -23,6 +23,7 @@ type cdnHTTP struct { client *remoteconfig.HTTPClient currentRootsVersion uint64 hostTagsGetter hostTagsGetter + env *env.Env } func newCDNHTTP(env *env.Env, configDBPath string) (CDN, error) { @@ -39,6 +40,7 @@ func newCDNHTTP(env *env.Env, configDBPath string) (CDN, error) { client: client, currentRootsVersion: 1, hostTagsGetter: newHostTagsGetter(env), + env: env, }, nil } @@ -134,6 +136,6 @@ func (c *cdnHTTP) get(ctx context.Context) ([][]byte, error) { return getOrderedScopedLayers( files, - getScopeExprVars(ctx, c.hostTagsGetter), + getScopeExprVars(c.env, c.hostTagsGetter), ) } diff --git a/pkg/fleet/internal/cdn/cdn_rc.go b/pkg/fleet/internal/cdn/cdn_rc.go index d1d2d87f4b43c7..afee2a514fe678 100644 --- a/pkg/fleet/internal/cdn/cdn_rc.go +++ b/pkg/fleet/internal/cdn/cdn_rc.go @@ -32,6 +32,7 @@ type cdnRC struct { configDBPath string firstRequest bool hostTagsGetter hostTagsGetter + env *env.Env } // newCDNRC creates a new CDN with RC: it fetches the configuration from the remote config service instead of cloudfront @@ -86,6 +87,7 @@ func newCDNRC(env *env.Env, configDBPath string) (CDN, error) { configDBPath: configDBPathTemp, firstRequest: true, hostTagsGetter: ht, + env: env, } service.Start() return cdn, nil @@ -192,7 +194,7 @@ func (c *cdnRC) get(ctx context.Context) ([][]byte, error) { } return getOrderedScopedLayers( files, - getScopeExprVars(ctx, c.hostTagsGetter), + getScopeExprVars(c.env, c.hostTagsGetter), ) } diff --git a/pkg/fleet/internal/cdn/scope_expression.go b/pkg/fleet/internal/cdn/scope_expression.go index 159ab417d2d5bf..a67e701942848e 100644 --- a/pkg/fleet/internal/cdn/scope_expression.go +++ b/pkg/fleet/internal/cdn/scope_expression.go @@ -6,12 +6,11 @@ package cdn import ( - "context" "encoding/json" "fmt" "regexp" - pkghostname "github.com/DataDog/datadog-agent/pkg/util/hostname" + "github.com/DataDog/datadog-agent/pkg/fleet/env" "github.com/DataDog/datadog-agent/pkg/version" "github.com/expr-lang/expr" ) @@ -112,14 +111,9 @@ func getOrderedScopedLayers(configs map[string][]byte, env map[string]interface{ return layers, nil } -func getScopeExprVars(ctx context.Context, hostTagsGetter hostTagsGetter) map[string]interface{} { - // TODO(baptiste): This should be passed from the daemon to the executable like tags - hostname, err := pkghostname.Get(ctx) - if err != nil { - hostname = "unknown" - } +func getScopeExprVars(env *env.Env, hostTagsGetter hostTagsGetter) map[string]interface{} { return map[string]interface{}{ - "hostname": hostname, + "hostname": env.Hostname, "installer_version": version.AgentVersion, // AgentVersion evaluates to the installer version here "tags": hostTagsGetter.get(), diff --git a/releasenotes/notes/add-ltsc2019-and-ltsc2022-images-b261c1821cc50116.yaml b/releasenotes/notes/add-ltsc2019-and-ltsc2022-images-b261c1821cc50116.yaml new file mode 100644 index 00000000000000..6fa6a8f0be750d --- /dev/null +++ b/releasenotes/notes/add-ltsc2019-and-ltsc2022-images-b261c1821cc50116.yaml @@ -0,0 +1,29 @@ +# Each section from every release note are combined when the +# CHANGELOG.rst is rendered. So the text needs to be worded so that +# it does not depend on any information only available in another +# section. This may mean repeating some details, but each section +# must be readable independently of the other. +# +# Each section note must be formatted as reStructuredText. +--- +features: + - | + Add new windows images for LTSC 2019 and LTSC 2022: + - `datadog-agent:7-servercore-ltsc2019-amd64` + - `datadog-agent:7-servercore-ltsc2022-amd64` + - `datadog-agent:7-servercore-ltsc2019-jmx-amd64` + - `datadog-agent:7-servercore-ltsc2022-jmx-amd64` + - `datadog-agent:latest-servercore-ltsc2019-jmx` + - `datadog-agent:latest-servercore-ltsc2022-jmx` + - `datadog-agent:latest-servercore-ltsc2019` + - `datadog-agent:latest-servercore-ltsc2022` + - `datadog-agent:7.X.Y-ltsc2019` + - `datadog-agent:7.X.Y-ltsc2022` + - `datadog-agent:7.X.Y-ltsc2019-jmx` + - `datadog-agent:7.X.Y-ltsc2022-jmx` + - `datadog-agent:7.X.Y-servercore-ltsc2019` + - `datadog-agent:7.X.Y-servercore-ltsc2022` + - `datadog-agent:7.X.Y-servercore-ltsc2019-jmx` + - `datadog-agent:7.X.Y-servercore-ltsc2022-jmx` + - `datadog-agent:latest-ltsc2019` + - `datadog-agent:latest-ltsc2022`