diff --git a/src/core/environment.go b/src/core/environment.go index 4fdaaa4011..8cfab01196 100644 --- a/src/core/environment.go +++ b/src/core/environment.go @@ -185,14 +185,12 @@ func getUnixName() string { } func (env *EnvironmentType) GetHostname() string { - ctx := context.Background() - defer ctx.Done() - hostInformation, err := host.InfoWithContext(ctx) + hostname, err := os.Hostname() if err != nil { log.Warnf("Unable to read hostname from dataplane, defaulting value. Error: %v", err) - return "" + hostname = "" } - return hostInformation.Hostname + return hostname } func (env *EnvironmentType) GetSystemUUID() string { diff --git a/test/integration/vendor/github.com/nginx/agent/v2/src/core/environment.go b/test/integration/vendor/github.com/nginx/agent/v2/src/core/environment.go index 4fdaaa4011..8cfab01196 100644 --- a/test/integration/vendor/github.com/nginx/agent/v2/src/core/environment.go +++ b/test/integration/vendor/github.com/nginx/agent/v2/src/core/environment.go @@ -185,14 +185,12 @@ func getUnixName() string { } func (env *EnvironmentType) GetHostname() string { - ctx := context.Background() - defer ctx.Done() - hostInformation, err := host.InfoWithContext(ctx) + hostname, err := os.Hostname() if err != nil { log.Warnf("Unable to read hostname from dataplane, defaulting value. Error: %v", err) - return "" + hostname = "" } - return hostInformation.Hostname + return hostname } func (env *EnvironmentType) GetSystemUUID() string { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/environment.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/environment.go index 4fdaaa4011..8cfab01196 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/environment.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/environment.go @@ -185,14 +185,12 @@ func getUnixName() string { } func (env *EnvironmentType) GetHostname() string { - ctx := context.Background() - defer ctx.Done() - hostInformation, err := host.InfoWithContext(ctx) + hostname, err := os.Hostname() if err != nil { log.Warnf("Unable to read hostname from dataplane, defaulting value. Error: %v", err) - return "" + hostname = "" } - return hostInformation.Hostname + return hostname } func (env *EnvironmentType) GetSystemUUID() string {