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

Removes a log message that corrupts support_archive zip package (release-1.4) #4374

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/csi/init/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
dtcsi "github.com/Dynatrace/dynatrace-operator/pkg/controllers/csi"
"github.com/Dynatrace/dynatrace-operator/pkg/controllers/csi/metadata"
"github.com/Dynatrace/dynatrace-operator/pkg/logd"
"github.com/Dynatrace/dynatrace-operator/pkg/util/installconfig"
"github.com/Dynatrace/dynatrace-operator/pkg/version"
"github.com/pkg/errors"
"github.com/spf13/afero"
Expand Down Expand Up @@ -51,6 +52,7 @@ func (builder CommandBuilder) Build() *cobra.Command {
func (builder CommandBuilder) buildRun() func(*cobra.Command, []string) error {
return func(cmd *cobra.Command, args []string) error {
unix.Umask(dtcsi.UnixUmask)
installconfig.ReadModules()
version.LogVersion()
logd.LogBaseLoggerSettings()

Expand Down
2 changes: 2 additions & 0 deletions cmd/csi/provisioner/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/Dynatrace/dynatrace-operator/pkg/controllers/csi/metadata"
csiprovisioner "github.com/Dynatrace/dynatrace-operator/pkg/controllers/csi/provisioner"
"github.com/Dynatrace/dynatrace-operator/pkg/logd"
"github.com/Dynatrace/dynatrace-operator/pkg/util/installconfig"
"github.com/Dynatrace/dynatrace-operator/pkg/version"
"github.com/pkg/errors"
"github.com/spf13/afero"
Expand Down Expand Up @@ -105,6 +106,7 @@ func addFlags(cmd *cobra.Command) {
func (builder CommandBuilder) buildRun() func(*cobra.Command, []string) error {
return func(cmd *cobra.Command, args []string) error {
unix.Umask(dtcsi.UnixUmask)
installconfig.ReadModules()
version.LogVersion()
logd.LogBaseLoggerSettings()

Expand Down
2 changes: 2 additions & 0 deletions cmd/csi/server/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
csidriver "github.com/Dynatrace/dynatrace-operator/pkg/controllers/csi/driver"
"github.com/Dynatrace/dynatrace-operator/pkg/controllers/csi/metadata"
"github.com/Dynatrace/dynatrace-operator/pkg/logd"
"github.com/Dynatrace/dynatrace-operator/pkg/util/installconfig"
"github.com/Dynatrace/dynatrace-operator/pkg/version"
"github.com/pkg/errors"
"github.com/spf13/afero"
Expand Down Expand Up @@ -108,6 +109,7 @@ func addFlags(cmd *cobra.Command) {
func (builder CommandBuilder) buildRun() func(*cobra.Command, []string) error {
return func(cmd *cobra.Command, args []string) error {
unix.Umask(dtcsi.UnixUmask)
installconfig.ReadModules()
version.LogVersion()
logd.LogBaseLoggerSettings()

Expand Down
2 changes: 2 additions & 0 deletions cmd/operator/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
cmdManager "github.com/Dynatrace/dynatrace-operator/cmd/manager"
"github.com/Dynatrace/dynatrace-operator/pkg/controllers/certificates"
"github.com/Dynatrace/dynatrace-operator/pkg/logd"
"github.com/Dynatrace/dynatrace-operator/pkg/util/installconfig"
"github.com/Dynatrace/dynatrace-operator/pkg/util/kubeobjects/pod"
"github.com/Dynatrace/dynatrace-operator/pkg/util/kubesystem"
"github.com/Dynatrace/dynatrace-operator/pkg/version"
Expand Down Expand Up @@ -124,6 +125,7 @@ func (builder CommandBuilder) setClientFromConfig(kubeCfg *rest.Config) (Command

func (builder CommandBuilder) buildRun() func(cmd *cobra.Command, args []string) error {
return func(cmd *cobra.Command, args []string) error {
installconfig.ReadModules()
version.LogVersion()
logd.LogBaseLoggerSettings()

Expand Down
2 changes: 2 additions & 0 deletions cmd/support_archive/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/Dynatrace/dynatrace-operator/cmd/remote_command"
"github.com/Dynatrace/dynatrace-operator/pkg/api/scheme"
"github.com/Dynatrace/dynatrace-operator/pkg/logd"
"github.com/Dynatrace/dynatrace-operator/pkg/util/installconfig"
"github.com/Dynatrace/dynatrace-operator/pkg/util/kubeobjects/env"
"github.com/Dynatrace/dynatrace-operator/pkg/util/kubeobjects/labels"
"github.com/Dynatrace/dynatrace-operator/pkg/version"
Expand Down Expand Up @@ -97,6 +98,7 @@ func (builder CommandBuilder) buildRun() func(*cobra.Command, []string) error {

logBuffer := bytes.Buffer{}
log := newSupportArchiveLogger(getLogOutput(archiveToStdoutFlagValue, &logBuffer))
installconfig.ReadModulesToLogger(log)
version.LogVersionToLogger(log)

archiveTargetFile, err := createZipArchiveTargetFile(archiveToStdoutFlagValue, defaultSupportArchiveTargetDir)
Expand Down
2 changes: 2 additions & 0 deletions cmd/webhook/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
dynakubevalidation "github.com/Dynatrace/dynatrace-operator/pkg/api/validation/dynakube"
edgeconnectvalidation "github.com/Dynatrace/dynatrace-operator/pkg/api/validation/edgeconnect"
"github.com/Dynatrace/dynatrace-operator/pkg/logd"
"github.com/Dynatrace/dynatrace-operator/pkg/util/installconfig"
"github.com/Dynatrace/dynatrace-operator/pkg/util/kubeobjects/pod"
"github.com/Dynatrace/dynatrace-operator/pkg/util/kubesystem"
"github.com/Dynatrace/dynatrace-operator/pkg/version"
Expand Down Expand Up @@ -120,6 +121,7 @@ func startCertificateWatcher(webhookManager manager.Manager, namespace string, p

func (builder CommandBuilder) buildRun() func(*cobra.Command, []string) error {
return func(cmd *cobra.Command, args []string) error {
installconfig.ReadModules()
version.LogVersion()
logd.LogBaseLoggerSettings()

Expand Down
5 changes: 2 additions & 3 deletions pkg/api/v1beta1/dynakube/convert_from.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import (
"github.com/Dynatrace/dynatrace-operator/pkg/api/v1beta3/dynakube"
"github.com/Dynatrace/dynatrace-operator/pkg/util/address"
"github.com/Dynatrace/dynatrace-operator/pkg/util/installconfig"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)

var isEnabledModules = installconfig.GetModules()

// ConvertFrom converts v1beta3 to v1beta1.
func (dst *DynaKube) ConvertFrom(srcRaw conversion.Hub) error {
src := srcRaw.(*dynakube.DynaKube)
Expand Down Expand Up @@ -60,7 +59,7 @@ func (dst *DynaKube) fromOneAgentSpec(src *dynakube.DynaKube) {
dst.Spec.OneAgent.ApplicationMonitoring = &ApplicationMonitoringSpec{}
dst.Spec.OneAgent.ApplicationMonitoring.AppInjectionSpec = *fromAppInjectSpec(src.Spec.OneAgent.ApplicationMonitoring.AppInjectionSpec)
dst.Spec.OneAgent.ApplicationMonitoring.Version = src.Spec.OneAgent.ApplicationMonitoring.Version
dst.Spec.OneAgent.ApplicationMonitoring.UseCSIDriver = &isEnabledModules.CSIDriver
dst.Spec.OneAgent.ApplicationMonitoring.UseCSIDriver = ptr.To(installconfig.GetModules().CSIDriver)
}
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/api/v1beta1/dynakube/convert_from_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/Dynatrace/dynatrace-operator/pkg/api/v1beta3/dynakube"
"github.com/Dynatrace/dynatrace-operator/pkg/api/v1beta3/dynakube/activegate"
"github.com/Dynatrace/dynatrace-operator/pkg/util/address"
"github.com/Dynatrace/dynatrace-operator/pkg/util/installconfig"
registryv1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -175,7 +176,7 @@ func compareCloudNativeSpec(t *testing.T, oldSpec CloudNativeFullStackSpec, newS

func compareApplicationMonitoringSpec(t *testing.T, oldSpec ApplicationMonitoringSpec, newSpec dynakube.ApplicationMonitoringSpec) {
compareAppInjectionSpec(t, oldSpec.AppInjectionSpec, newSpec.AppInjectionSpec)
assert.Equal(t, *oldSpec.UseCSIDriver, isEnabledModules.CSIDriver)
assert.Equal(t, *oldSpec.UseCSIDriver, installconfig.GetModules().CSIDriver)
assert.Equal(t, oldSpec.Version, newSpec.Version)
}

Expand Down
4 changes: 1 addition & 3 deletions pkg/api/v1beta2/dynakube/convert_from.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/conversion"
)

var isEnabledModules = installconfig.GetModules()

// ConvertFrom converts from the Hub version (v1beta3) to this version (v1beta3).
func (dst *DynaKube) ConvertFrom(srcRaw conversion.Hub) error {
src := srcRaw.(*v1beta3.DynaKube)
Expand Down Expand Up @@ -55,7 +53,7 @@ func (dst *DynaKube) fromOneAgentSpec(src *v1beta3.DynaKube) {
dst.Spec.OneAgent.ApplicationMonitoring = &ApplicationMonitoringSpec{}
dst.Spec.OneAgent.ApplicationMonitoring.AppInjectionSpec = *fromAppInjectSpec(src.Spec.OneAgent.ApplicationMonitoring.AppInjectionSpec)
dst.Spec.OneAgent.ApplicationMonitoring.Version = src.Spec.OneAgent.ApplicationMonitoring.Version
dst.Spec.OneAgent.ApplicationMonitoring.UseCSIDriver = isEnabledModules.CSIDriver
dst.Spec.OneAgent.ApplicationMonitoring.UseCSIDriver = installconfig.GetModules().CSIDriver
}
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/api/v1beta2/dynakube/convert_from_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/Dynatrace/dynatrace-operator/pkg/api/v1beta3/dynakube"
"github.com/Dynatrace/dynatrace-operator/pkg/api/v1beta3/dynakube/activegate"
"github.com/Dynatrace/dynatrace-operator/pkg/util/address"
"github.com/Dynatrace/dynatrace-operator/pkg/util/installconfig"
registryv1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -166,7 +167,7 @@ func compareCloudNativeSpec(t *testing.T, oldSpec CloudNativeFullStackSpec, newS

func compareApplicationMonitoringSpec(t *testing.T, oldSpec ApplicationMonitoringSpec, newSpec dynakube.ApplicationMonitoringSpec) {
compareAppInjectionSpec(t, oldSpec.AppInjectionSpec, newSpec.AppInjectionSpec)
assert.Equal(t, oldSpec.UseCSIDriver, isEnabledModules.CSIDriver)
assert.Equal(t, oldSpec.UseCSIDriver, installconfig.GetModules().CSIDriver)
assert.Equal(t, oldSpec.Version, newSpec.Version)
}

Expand Down
12 changes: 10 additions & 2 deletions pkg/util/installconfig/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ func GetModules() Modules {
return *override
}

ReadModules()

return modules
}

func ReadModules() {
ReadModulesToLogger(log)
}

func ReadModulesToLogger(log logd.Logger) {
once.Do(func() {
modulesJson := os.Getenv(ModulesJsonEnv)
if modulesJson == "" {
Expand All @@ -71,8 +81,6 @@ func GetModules() Modules {

log.Info("envvar content read and set", "envvar", ModulesJsonEnv, "value", modulesJson)
})

return modules
}

// SetModulesOverride is a testing function, so you can easily unittest function using the GetModules() func
Expand Down
Loading