You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@yunikorn.apache.org by cc...@apache.org on 2023/06/21 11:45:18 UTC
[yunikorn-core] branch master updated: [YUNIKORN-1825] Convert core to use scoped logging (#576)
This is an automated email from the ASF dual-hosted git repository.
ccondit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yunikorn-core.git
The following commit(s) were added to refs/heads/master by this push:
new ddd16600 [YUNIKORN-1825] Convert core to use scoped logging (#576)
ddd16600 is described below
commit ddd16600a014e11568bd3fe8b3949db5e28c2076
Author: Craig Condit <cc...@apache.org>
AuthorDate: Wed Jun 21 06:45:04 2023 -0500
[YUNIKORN-1825] Convert core to use scoped logging (#576)
Convert all uses of log.Logger() to log.Log(name). This allows for
fine-grained control over logging for each subsystem.
Closes: #576
---
pkg/common/configs/config.go | 4 +-
pkg/common/configs/configvalidator.go | 18 ++---
pkg/common/resources/resources.go | 26 +++---
pkg/common/security/acl.go | 10 +--
pkg/common/security/usergroup.go | 16 ++--
pkg/common/server.go | 18 ++---
pkg/common/utils.go | 10 +--
pkg/entrypoint/entrypoint.go | 12 +--
pkg/entrypoint/service_context.go | 4 +-
pkg/events/event_publisher.go | 2 +-
pkg/events/event_system.go | 2 +-
pkg/log/logger.go | 49 ++++++++----
pkg/log/logger_test.go | 57 +++-----------
pkg/metrics/metrics_collector.go | 10 +--
pkg/metrics/metrics_test.go | 2 +-
pkg/metrics/queue.go | 2 +-
pkg/metrics/runtime.go | 2 +-
pkg/metrics/scheduler.go | 4 +-
pkg/plugins/plugins.go | 4 +-
pkg/rmproxy/rmproxy.go | 12 +--
pkg/scheduler/context.go | 58 +++++++-------
pkg/scheduler/health_checker.go | 12 +--
pkg/scheduler/mock_plugin_test.go | 8 +-
pkg/scheduler/objects/allocation.go | 4 +-
pkg/scheduler/objects/allocation_ask.go | 2 +-
pkg/scheduler/objects/application.go | 122 ++++++++++++++---------------
pkg/scheduler/objects/application_state.go | 2 +-
pkg/scheduler/objects/node.go | 26 +++---
pkg/scheduler/objects/node_collection.go | 2 +-
pkg/scheduler/objects/nodesorting.go | 4 +-
pkg/scheduler/objects/object_state.go | 2 +-
pkg/scheduler/objects/preemption.go | 24 +++---
pkg/scheduler/objects/queue.go | 88 ++++++++++-----------
pkg/scheduler/objects/reservation.go | 4 +-
pkg/scheduler/partition.go | 110 +++++++++++++-------------
pkg/scheduler/partition_manager.go | 18 ++---
pkg/scheduler/placement/filter.go | 18 ++---
pkg/scheduler/placement/fixed_rule.go | 6 +-
pkg/scheduler/placement/placement.go | 28 +++----
pkg/scheduler/placement/provided_rule.go | 6 +-
pkg/scheduler/placement/rule.go | 4 +-
pkg/scheduler/placement/tag_rule.go | 6 +-
pkg/scheduler/placement/user_rule.go | 6 +-
pkg/scheduler/scheduler.go | 12 +--
pkg/scheduler/tests/utilities_test.go | 2 +-
pkg/scheduler/ugm/manager.go | 76 +++++++++---------
pkg/scheduler/ugm/queue_tracker.go | 20 ++---
pkg/trace/scheduler_tracer.go | 2 +-
pkg/trace/utils.go | 4 +-
pkg/webservice/handlers.go | 20 ++---
pkg/webservice/state_dump.go | 2 +-
pkg/webservice/webservice.go | 6 +-
52 files changed, 474 insertions(+), 494 deletions(-)
diff --git a/pkg/common/configs/config.go b/pkg/common/configs/config.go
index 14b324c6..581e9cbe 100644
--- a/pkg/common/configs/config.go
+++ b/pkg/common/configs/config.go
@@ -166,14 +166,14 @@ func ParseAndValidateConfig(content []byte) (*SchedulerConfig, error) {
conf := &SchedulerConfig{}
err := yaml.UnmarshalStrict(content, conf)
if err != nil {
- log.Logger().Error("failed to parse queue configuration",
+ log.Log(log.Config).Error("failed to parse queue configuration",
zap.Error(err))
return nil, err
}
// validate the config
err = Validate(conf)
if err != nil {
- log.Logger().Error("queue configuration validation failed",
+ log.Log(log.Config).Error("queue configuration validation failed",
zap.Error(err))
return nil, err
}
diff --git a/pkg/common/configs/configvalidator.go b/pkg/common/configs/configvalidator.go
index f473fba6..1652b0b3 100644
--- a/pkg/common/configs/configvalidator.go
+++ b/pkg/common/configs/configvalidator.go
@@ -286,7 +286,7 @@ func checkPlacementRules(partition *PartitionConfig) error {
return nil
}
- log.Logger().Debug("checking placement rule config",
+ log.Log(log.Config).Debug("checking placement rule config",
zap.String("partitionName", partition.Name))
// top level rule checks, parents are called recursively
for _, rule := range partition.PlacementRules {
@@ -363,7 +363,7 @@ func checkPlacementRule(rule PlacementRule) error {
// check the parent rule
if rule.Parent != nil {
if err := checkPlacementRule(*rule.Parent); err != nil {
- log.Logger().Debug("parent placement rule failed",
+ log.Log(log.Config).Debug("parent placement rule failed",
zap.String("rule", rule.Name),
zap.String("parentRule", rule.Parent.Name))
return err
@@ -371,7 +371,7 @@ func checkPlacementRule(rule PlacementRule) error {
}
// check filter if given
if err := checkPlacementFilter(rule.Filter); err != nil {
- log.Logger().Debug("placement rule filter failed",
+ log.Log(log.Config).Debug("placement rule filter failed",
zap.String("rule", rule.Name),
zap.Any("filter", rule.Filter))
return err
@@ -473,7 +473,7 @@ func checkLimit(limit Limit, existedUserName map[string]bool, existedGroupName m
if len(limit.MaxResources) != 0 {
limitResource, err = resources.NewResourceFromConf(limit.MaxResources)
if err != nil {
- log.Logger().Debug("resource parsing failed",
+ log.Log(log.Config).Debug("resource parsing failed",
zap.Error(err))
return err
}
@@ -497,7 +497,7 @@ func checkLimit(limit Limit, existedUserName map[string]bool, existedGroupName m
if queue.Name != RootQueue {
queueMaxResource, err := resources.NewResourceFromConf(queue.Resources.Max)
if err != nil {
- log.Logger().Debug("resource parsing failed",
+ log.Log(log.Config).Debug("resource parsing failed",
zap.Error(err))
return fmt.Errorf("parse queue %s max resource failed: %s", queue.Name, err.Error())
}
@@ -516,7 +516,7 @@ func checkLimits(limits []Limit, obj string, queue *QueueConfig) error {
return nil
}
// walk over the list of limits
- log.Logger().Debug("checking limits configs",
+ log.Log(log.Config).Debug("checking limits configs",
zap.String("objName", obj),
zap.Int("limitsLength", len(limits)))
@@ -615,7 +615,7 @@ func checkQueuesStructure(partition *PartitionConfig) error {
return fmt.Errorf("queue config is not set")
}
- log.Logger().Debug("checking partition queue config",
+ log.Log(log.Config).Debug("checking partition queue config",
zap.String("partitionName", partition.Name))
// handle no root queue cases
@@ -635,7 +635,7 @@ func checkQueuesStructure(partition *PartitionConfig) error {
// insert the root queue if not there
if insertRoot {
- log.Logger().Debug("inserting root queue",
+ log.Log(log.Config).Debug("inserting root queue",
zap.Int("numOfQueues", len(partition.Queues)))
var rootQueue QueueConfig
rootQueue.Name = RootQueue
@@ -658,7 +658,7 @@ func checkQueuesStructure(partition *PartitionConfig) error {
// Check the state dump file path, if configured, is a valid path that can be written to.
func checkDeprecatedStateDumpFilePath(partition *PartitionConfig) error {
if partition.StateDumpFilePath != "" {
- log.Logger().Warn("Ignoring deprecated partition setting 'statedumpfilepath'. This parameter will be removed in a future release.")
+ log.Log(log.Deprecation).Warn("Ignoring deprecated partition setting 'statedumpfilepath'. This parameter will be removed in a future release.")
}
return nil
}
diff --git a/pkg/common/resources/resources.go b/pkg/common/resources/resources.go
index a3d8afc5..f0da8d76 100644
--- a/pkg/common/resources/resources.go
+++ b/pkg/common/resources/resources.go
@@ -295,13 +295,13 @@ func addVal(valA, valB Quantity) Quantity {
if (result < valA) != (valB < 0) {
if valA < 0 {
// return the minimum possible
- log.Logger().Warn("Resource calculation wrapped: returned minimum value possible",
+ log.Log(log.Resources).Warn("Resource calculation wrapped: returned minimum value possible",
zap.Int64("valueA", int64(valA)),
zap.Int64("valueB", int64(valB)))
return math.MinInt64
}
// return the maximum possible
- log.Logger().Warn("Resource calculation wrapped: returned maximum value possible",
+ log.Log(log.Resources).Warn("Resource calculation wrapped: returned maximum value possible",
zap.Int64("valueA", int64(valA)),
zap.Int64("valueB", int64(valB)))
return math.MaxInt64
@@ -326,13 +326,13 @@ func mulVal(valA, valB Quantity) Quantity {
if (result/valB != valA) || (valA == math.MinInt64 && valB == -1) {
if (valA < 0) != (valB < 0) {
// return the minimum possible
- log.Logger().Warn("Resource calculation wrapped: returned minimum value possible",
+ log.Log(log.Resources).Warn("Resource calculation wrapped: returned minimum value possible",
zap.Int64("valueA", int64(valA)),
zap.Int64("valueB", int64(valB)))
return math.MinInt64
}
// return the maximum possible
- log.Logger().Warn("Resource calculation wrapped: returned maximum value possible",
+ log.Log(log.Resources).Warn("Resource calculation wrapped: returned maximum value possible",
zap.Int64("valueA", int64(valA)),
zap.Int64("valueB", int64(valB)))
return math.MaxInt64
@@ -349,14 +349,14 @@ func mulValRatio(value Quantity, ratio float64) Quantity {
result := float64(value) * ratio
// protect against positive integer overflow
if result > math.MaxInt64 {
- log.Logger().Warn("Multiplication result positive overflow",
+ log.Log(log.Resources).Warn("Multiplication result positive overflow",
zap.Float64("value", float64(value)),
zap.Float64("ratio", ratio))
return math.MaxInt64
}
// protect against negative integer overflow
if result < math.MinInt64 {
- log.Logger().Warn("Multiplication result negative overflow",
+ log.Log(log.Resources).Warn("Multiplication result negative overflow",
zap.Float64("value", float64(value)),
zap.Float64("ratio", ratio))
return math.MinInt64
@@ -541,7 +541,7 @@ func getShares(res, total *Resource) []float64 {
if total == nil || total.Resources[k] == 0 {
// negative share is logged
if v < 0 {
- log.Logger().Debug("usage is negative no total, share is also negative",
+ log.Log(log.Resources).Debug("usage is negative no total, share is also negative",
zap.String("resource key", k),
zap.Int64("resource quantity", int64(v)))
}
@@ -552,7 +552,7 @@ func getShares(res, total *Resource) []float64 {
shares[idx] = float64(v) / float64(total.Resources[k])
// negative share is logged
if shares[idx] < 0 {
- log.Logger().Debug("share set is negative",
+ log.Log(log.Resources).Debug("share set is negative",
zap.String("resource key", k),
zap.Int64("resource quantity", int64(v)),
zap.Int64("total quantity", int64(total.Resources[k])))
@@ -939,7 +939,7 @@ func IsZero(zero *Resource) bool {
func CalculateAbsUsedCapacity(capacity, used *Resource) *Resource {
absResource := NewResource()
if capacity == nil || used == nil {
- log.Logger().Debug("Cannot calculate absolute capacity because of missing capacity or usage")
+ log.Log(log.Resources).Debug("Cannot calculate absolute capacity because of missing capacity or usage")
return absResource
}
missingResources := &strings.Builder{}
@@ -947,7 +947,7 @@ func CalculateAbsUsedCapacity(capacity, used *Resource) *Resource {
var absResValue int64
if usedResource, ok := used.Resources[resourceName]; ok {
if availableResource < usedResource {
- log.Logger().Warn("Higher usage than max capacity",
+ log.Log(log.Resources).Warn("Higher usage than max capacity",
zap.String("resource", resourceName),
zap.Int64("capacity", int64(availableResource)),
zap.Int64("usage", int64(usedResource)))
@@ -956,7 +956,7 @@ func CalculateAbsUsedCapacity(capacity, used *Resource) *Resource {
absResValue = int64(div * 100)
// protect against positive integer overflow
if absResValue < 0 && div > 0 {
- log.Logger().Warn("Absolute resource value result positive overflow",
+ log.Log(log.Resources).Warn("Absolute resource value result positive overflow",
zap.String("resource", resourceName),
zap.Int64("capacity", int64(availableResource)),
zap.Int64("usage", int64(usedResource)))
@@ -964,7 +964,7 @@ func CalculateAbsUsedCapacity(capacity, used *Resource) *Resource {
}
// protect against negative integer overflow
if absResValue > 0 && div < 0 {
- log.Logger().Warn("Absolute resource value result negative overflow",
+ log.Log(log.Resources).Warn("Absolute resource value result negative overflow",
zap.String("resource", resourceName),
zap.Int64("capacity", int64(availableResource)),
zap.Int64("usage", int64(usedResource)))
@@ -980,7 +980,7 @@ func CalculateAbsUsedCapacity(capacity, used *Resource) *Resource {
absResource.Resources[resourceName] = Quantity(absResValue)
}
if missingResources.Len() != 0 {
- log.Logger().Debug("Absolute usage result is missing resource information",
+ log.Log(log.Resources).Debug("Absolute usage result is missing resource information",
zap.Stringer("missing resource(s)", missingResources))
}
return absResource
diff --git a/pkg/common/security/acl.go b/pkg/common/security/acl.go
index 711b443d..3d83a5ad 100644
--- a/pkg/common/security/acl.go
+++ b/pkg/common/security/acl.go
@@ -60,7 +60,7 @@ func (a *ACL) setUsers(userList []string) {
}
// special case if the user list is just the wildcard
if len(userList) == 1 && userList[0] == WildCard {
- log.Logger().Info("user list is wildcard, allowing all access")
+ log.Log(log.Security).Info("user list is wildcard, allowing all access")
a.allAllowed = true
return
}
@@ -74,7 +74,7 @@ func (a *ACL) setUsers(userList []string) {
if userNameRegExp.MatchString(user) {
a.users[user] = true
} else {
- log.Logger().Info("ignoring user in ACL definition",
+ log.Log(log.Security).Info("ignoring user in ACL definition",
zap.String("user", user))
}
}
@@ -89,11 +89,11 @@ func (a *ACL) setGroups(groupList []string) {
}
// special case if the wildcard was already set
if a.allAllowed {
- log.Logger().Info("ignoring group list in ACL: wildcard set")
+ log.Log(log.Security).Info("ignoring group list in ACL: wildcard set")
return
}
if len(groupList) == 1 && groupList[0] == WildCard {
- log.Logger().Info("group list is wildcard, allowing all access")
+ log.Log(log.Security).Info("group list is wildcard, allowing all access")
a.users = make(map[string]bool)
a.allAllowed = true
return
@@ -108,7 +108,7 @@ func (a *ACL) setGroups(groupList []string) {
if groupRegExp.MatchString(group) {
a.groups[group] = true
} else {
- log.Logger().Info("ignoring group in ACL",
+ log.Log(log.Security).Info("ignoring group in ACL",
zap.String("group", group))
}
}
diff --git a/pkg/common/security/usergroup.go b/pkg/common/security/usergroup.go
index 675229d1..e381204d 100644
--- a/pkg/common/security/usergroup.go
+++ b/pkg/common/security/usergroup.go
@@ -70,17 +70,17 @@ func GetUserGroupCache(resolver string) *UserGroupCache {
once.Do(func() {
switch resolver {
case "test":
- log.Logger().Info("creating test user group resolver")
+ log.Log(log.Security).Info("creating test user group resolver")
instance = GetUserGroupCacheTest()
case "os":
- log.Logger().Info("creating OS user group resolver")
+ log.Log(log.Security).Info("creating OS user group resolver")
instance = GetUserGroupCacheOS()
default:
- log.Logger().Info("creating UserGroupCache without resolver")
+ log.Log(log.Security).Info("creating UserGroupCache without resolver")
instance = GetUserGroupNoResolve()
}
instance.ugs = make(map[string]*UserGroup)
- log.Logger().Info("starting UserGroupCache cleaner",
+ log.Log(log.Security).Info("starting UserGroupCache cleaner",
zap.Stringer("cleanerInterval", instance.interval))
go instance.run()
})
@@ -93,7 +93,7 @@ func (c *UserGroupCache) run() {
time.Sleep(instance.interval)
runStart := time.Now()
c.cleanUpCache()
- log.Logger().Debug("time consumed cleaning the UserGroupCache",
+ log.Log(log.Security).Debug("time consumed cleaning the UserGroupCache",
zap.Stringer("duration", time.Since(runStart)))
}
}
@@ -116,7 +116,7 @@ func (c *UserGroupCache) cleanUpCache() {
// reset the cached content, test use only
func (c *UserGroupCache) resetCache() {
- log.Logger().Debug("UserGroupCache reset")
+ log.Log(log.Security).Debug("UserGroupCache reset")
instance.lock.Lock()
defer instance.lock.Unlock()
c.ugs = make(map[string]*UserGroup)
@@ -171,7 +171,7 @@ func (c *UserGroupCache) GetUserGroup(userName string) (UserGroup, error) {
// find the user first, then resolve the groups
osUser, err := c.lookup(userName)
if err != nil {
- log.Logger().Error("Error resolving user: does not exist",
+ log.Log(log.Security).Error("Error resolving user: does not exist",
zap.String("userName", userName),
zap.Error(err))
ug.failed = true
@@ -182,7 +182,7 @@ func (c *UserGroupCache) GetUserGroup(userName string) (UserGroup, error) {
err = ug.resolveGroups(osUser, c)
// log a failure and continue
if err != nil {
- log.Logger().Error("Error resolving groups for user",
+ log.Log(log.Security).Error("Error resolving groups for user",
zap.String("userName", userName),
zap.Error(err))
ug.failed = true
diff --git a/pkg/common/server.go b/pkg/common/server.go
index 74bbf342..25ef9fc5 100644
--- a/pkg/common/server.go
+++ b/pkg/common/server.go
@@ -85,15 +85,15 @@ func ParseEndpoint(ep string) (string, string, error) {
// Logging unary interceptor function to log every RPC call
func logGRPC(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
- log.Logger().Debug("GPRC call",
+ log.Log(log.RPC).Debug("GPRC call",
zap.String("method", info.FullMethod))
- log.Logger().Debug("GPRC request",
+ log.Log(log.RPC).Debug("GPRC request",
zap.String("request", fmt.Sprintf("%+v", req)))
resp, err := handler(ctx, req)
if err != nil {
- log.Logger().Debug("GPRC error", zap.Error(err))
+ log.Log(log.RPC).Debug("GPRC error", zap.Error(err))
} else {
- log.Logger().Debug("GPRC response",
+ log.Log(log.RPC).Debug("GPRC response",
zap.String("response", fmt.Sprintf("%+v", resp)))
}
return resp, err
@@ -107,13 +107,13 @@ func withServerUnaryInterceptor() grpc.ServerOption {
func (s *nonBlockingGRPCServer) serve(endpoint string, ss si.SchedulerServer) {
proto, addr, err := ParseEndpoint(endpoint)
if err != nil {
- log.Logger().Fatal("fatal error", zap.Error(err))
+ log.Log(log.RPC).Fatal("fatal error", zap.Error(err))
}
if proto == "unix" {
addr = "/" + addr
if err = os.Remove(addr); err != nil && !os.IsNotExist(err) {
- log.Logger().Fatal("failed to remove unix domain socket",
+ log.Log(log.RPC).Fatal("failed to remove unix domain socket",
zap.String("uds", addr),
zap.Error(err))
}
@@ -122,7 +122,7 @@ func (s *nonBlockingGRPCServer) serve(endpoint string, ss si.SchedulerServer) {
var listener net.Listener
listener, err = net.Listen(proto, addr)
if err != nil {
- log.Logger().Fatal("failed to listen to address",
+ log.Log(log.RPC).Fatal("failed to listen to address",
zap.Error(err))
}
@@ -133,10 +133,10 @@ func (s *nonBlockingGRPCServer) serve(endpoint string, ss si.SchedulerServer) {
si.RegisterSchedulerServer(server, ss)
}
- log.Logger().Info("listening for connections",
+ log.Log(log.RPC).Info("listening for connections",
zap.Stringer("address", listener.Addr()))
if err = server.Serve(listener); err != nil {
- log.Logger().Fatal("failed to serve", zap.Error(err))
+ log.Log(log.RPC).Fatal("failed to serve", zap.Error(err))
}
}
diff --git a/pkg/common/utils.go b/pkg/common/utils.go
index 45be1fc9..690dc83f 100644
--- a/pkg/common/utils.go
+++ b/pkg/common/utils.go
@@ -86,7 +86,7 @@ func GetBoolEnvVar(key string, defaultVal bool) bool {
if value, ok := os.LookupEnv(key); ok {
boolValue, err := strconv.ParseBool(value)
if err != nil {
- log.Logger().Debug("Failed to parse environment variable, using default value",
+ log.Log(log.Utils).Debug("Failed to parse environment variable, using default value",
zap.String("name", key),
zap.String("value", value),
zap.Bool("default", defaultVal))
@@ -109,7 +109,7 @@ func ConvertSITimeout(millis int64) time.Duration {
// just handle max wrapping, no need to handle min wrapping
result := millis * int64(time.Millisecond)
if result/millis != int64(time.Millisecond) {
- log.Logger().Warn("Timeout conversion wrapped: returned no timeout",
+ log.Log(log.Utils).Warn("Timeout conversion wrapped: returned no timeout",
zap.Int64("configured timeout in ms", millis))
return time.Duration(0)
}
@@ -142,14 +142,14 @@ func adjustTimeout(timeout time.Duration, siApp *si.AddApplicationRequest) time.
adjusted := time.Until(expectedTimeout)
if adjusted <= 0 {
- log.Logger().Info("Placeholder timeout reached - expected timeout is in the past",
+ log.Log(log.Utils).Info("Placeholder timeout reached - expected timeout is in the past",
zap.Duration("timeout duration", timeout),
zap.Time("creation time", created),
zap.Time("expected timeout", expectedTimeout))
return time.Millisecond // smallest allowed timeout value
}
- log.Logger().Info("Adjusting placeholder timeout",
+ log.Log(log.Utils).Info("Adjusting placeholder timeout",
zap.Duration("timeout duration", timeout),
zap.Time("creation time", created),
zap.Time("expected timeout", expectedTimeout))
@@ -164,7 +164,7 @@ func ConvertSITimestamp(ts string) time.Time {
tm, err := strconv.ParseInt(ts, 10, 64)
if err != nil {
- log.Logger().Warn("Unable to parse timestamp string", zap.String("timestamp", ts),
+ log.Log(log.Utils).Warn("Unable to parse timestamp string", zap.String("timestamp", ts),
zap.Error(err))
return time.Time{}
}
diff --git a/pkg/entrypoint/entrypoint.go b/pkg/entrypoint/entrypoint.go
index 2a42a989..115530f4 100644
--- a/pkg/entrypoint/entrypoint.go
+++ b/pkg/entrypoint/entrypoint.go
@@ -40,7 +40,7 @@ type startupOptions struct {
}
func StartAllServices() *ServiceContext {
- log.Logger().Info("ServiceContext start all services")
+ log.Log(log.Entrypoint).Info("ServiceContext start all services")
return startAllServicesWithParameters(
startupOptions{
manualScheduleFlag: false,
@@ -57,7 +57,7 @@ func StartAllServicesWithLogger(logger *zap.Logger, zapConfigs *zap.Config) *Ser
// Visible by tests
func StartAllServicesWithManualScheduler() *ServiceContext {
- log.Logger().Info("ServiceContext start all services (manual scheduler)")
+ log.Log(log.Entrypoint).Info("ServiceContext start all services (manual scheduler)")
return startAllServicesWithParameters(
startupOptions{
manualScheduleFlag: true,
@@ -69,7 +69,7 @@ func StartAllServicesWithManualScheduler() *ServiceContext {
func startAllServicesWithParameters(opts startupOptions) *ServiceContext {
if opts.eventSystemEnabled {
- log.Logger().Info("creating and starting event system")
+ log.Log(log.Entrypoint).Info("creating and starting event system")
events.CreateAndSetEventSystem()
events.GetEventSystem().StartService()
}
@@ -83,7 +83,7 @@ func startAllServicesWithParameters(opts startupOptions) *ServiceContext {
}
// start services
- log.Logger().Info("ServiceContext start scheduling services")
+ log.Log(log.Entrypoint).Info("ServiceContext start scheduling services")
sched.StartService(eventHandler, opts.manualScheduleFlag)
proxy.StartService(eventHandler)
@@ -94,14 +94,14 @@ func startAllServicesWithParameters(opts startupOptions) *ServiceContext {
var imHistory *history.InternalMetricsHistory
if opts.metricsHistorySize != 0 {
- log.Logger().Info("creating InternalMetricsHistory")
+ log.Log(log.Entrypoint).Info("creating InternalMetricsHistory")
imHistory = history.NewInternalMetricsHistory(opts.metricsHistorySize)
metricsCollector := metrics.NewInternalMetricsCollector(imHistory)
metricsCollector.StartService()
}
if opts.startWebAppFlag {
- log.Logger().Info("ServiceContext start web application service")
+ log.Log(log.Entrypoint).Info("ServiceContext start web application service")
webapp := webservice.NewWebApp(sched.GetClusterContext(), imHistory)
webapp.StartWebApp()
context.WebApp = webapp
diff --git a/pkg/entrypoint/service_context.go b/pkg/entrypoint/service_context.go
index 5cedf9bb..e14f55d2 100644
--- a/pkg/entrypoint/service_context.go
+++ b/pkg/entrypoint/service_context.go
@@ -34,11 +34,11 @@ type ServiceContext struct {
}
func (s *ServiceContext) StopAll() {
- log.Logger().Info("ServiceContext stop all services")
+ log.Log(log.Entrypoint).Info("ServiceContext stop all services")
// TODO implement stop for services
if s.WebApp != nil {
if err := s.WebApp.StopWebApp(); err != nil {
- log.Logger().Error("failed to stop web-app",
+ log.Log(log.Entrypoint).Error("failed to stop web-app",
zap.Error(err))
}
}
diff --git a/pkg/events/event_publisher.go b/pkg/events/event_publisher.go
index 6225a1ee..216edb7e 100644
--- a/pkg/events/event_publisher.go
+++ b/pkg/events/event_publisher.go
@@ -55,7 +55,7 @@ func (sp *EventPublisher) StartService() {
messages := sp.store.CollectEvents()
if len(messages) > 0 {
if eventPlugin := plugins.GetResourceManagerCallbackPlugin(); eventPlugin != nil {
- log.Logger().Debug("Sending eventChannel", zap.Int("number of messages", len(messages)))
+ log.Log(log.Events).Debug("Sending eventChannel", zap.Int("number of messages", len(messages)))
eventPlugin.SendEvent(messages)
}
}
diff --git a/pkg/events/event_system.go b/pkg/events/event_system.go
index 304e0dd9..2dc6a941 100644
--- a/pkg/events/event_system.go
+++ b/pkg/events/event_system.go
@@ -112,7 +112,7 @@ func (ec *EventSystemImpl) AddEvent(event *si.EventRecord) {
case ec.channel <- event:
metrics.GetEventMetrics().IncEventsChanneled()
default:
- log.Logger().Debug("could not add Event to channel")
+ log.Log(log.Events).Debug("could not add Event to channel")
metrics.GetEventMetrics().IncEventsNotChanneled()
}
}
diff --git a/pkg/log/logger.go b/pkg/log/logger.go
index c08a534a..8a14880c 100644
--- a/pkg/log/logger.go
+++ b/pkg/log/logger.go
@@ -52,18 +52,42 @@ const (
levelSuffix = ".level"
)
-// Predefined loggers: when adding new loggers, ids must be sequential, and all must be added to the loggers slice in the same order
+// Defined loggers: when adding new loggers, ids must be sequential, and all must be added to the loggers slice in the same order
var (
- Core = &LoggerHandle{id: 1, name: "core"}
- Test = &LoggerHandle{id: 2, name: "test"}
- AppUsage = &LoggerHandle{id: 3, name: "core.application.usage"}
+ Core = &LoggerHandle{id: 1, name: "core"}
+ Test = &LoggerHandle{id: 2, name: "test"}
+ Deprecation = &LoggerHandle{id: 3, name: "deprecation"}
+ Config = &LoggerHandle{id: 4, name: "core.config"}
+ Entrypoint = &LoggerHandle{id: 5, name: "core.entrypoint"}
+ Events = &LoggerHandle{id: 6, name: "core.events"}
+ OpenTracing = &LoggerHandle{id: 7, name: "core.opentracing"}
+ Resources = &LoggerHandle{id: 8, name: "core.resources"}
+ REST = &LoggerHandle{id: 9, name: "core.rest"}
+ RMProxy = &LoggerHandle{id: 10, name: "core.rmproxy"}
+ RPC = &LoggerHandle{id: 11, name: "core.rpc"}
+ Metrics = &LoggerHandle{id: 12, name: "core.metrics"}
+ Scheduler = &LoggerHandle{id: 13, name: "core.scheduler"}
+ SchedAllocation = &LoggerHandle{id: 14, name: "core.scheduler.allocation"}
+ SchedApplication = &LoggerHandle{id: 15, name: "core.scheduler.application"}
+ SchedAppUsage = &LoggerHandle{id: 16, name: "core.scheduler.application.usage"}
+ SchedContext = &LoggerHandle{id: 17, name: "core.scheduler.context"}
+ SchedFSM = &LoggerHandle{id: 18, name: "core.scheduler.fsm"}
+ SchedHealth = &LoggerHandle{id: 19, name: "core.scheduler.health"}
+ SchedNode = &LoggerHandle{id: 20, name: "core.scheduler.node"}
+ SchedPartition = &LoggerHandle{id: 21, name: "core.scheduler.partition"}
+ SchedPreemption = &LoggerHandle{id: 22, name: "core.scheduler.preemption"}
+ SchedQueue = &LoggerHandle{id: 23, name: "core.scheduler.queue"}
+ SchedReservation = &LoggerHandle{id: 24, name: "core.scheduler.reservation"}
+ SchedUGM = &LoggerHandle{id: 25, name: "core.scheduler.ugm"}
+ Security = &LoggerHandle{id: 26, name: "core.security"}
+ Utils = &LoggerHandle{id: 27, name: "core.utils"}
)
// this tracks all the known logger handles, used to preallocate the real logger instances when configuration changes
var loggers = []*LoggerHandle{
- Core,
- Test,
- AppUsage,
+ Core, Test, Deprecation, Config, Entrypoint, Events, OpenTracing, Resources, REST, RMProxy, RPC, Metrics,
+ Scheduler, SchedAllocation, SchedApplication, SchedAppUsage, SchedContext, SchedFSM, SchedHealth, SchedNode,
+ SchedPartition, SchedPreemption, SchedQueue, SchedReservation, SchedUGM, Security, Utils,
}
// structure to hold all current logger configuration state
@@ -77,19 +101,14 @@ var currentLoggerConfig = atomic.Pointer[loggerConfig]{}
// tracks the default logger handle, which is used for legacy log.Logger() calls
var defaultLogger = atomic.Pointer[LoggerHandle]{}
-// Logger retrieves the global logger. This is for compatibility with legacy code and
-// should not be used for new log messages; use Log(loggerHandle) instead
+// Logger retrieves the global logger.
+//
+// Deprecated: Use Log(loggerHandle) instead.
func Logger() *zap.Logger {
once.Do(initLogger)
return Log(defaultLogger.Load())
}
-// RootLogger retrieves the root logger, visible for testing
-func RootLogger() *zap.Logger {
- once.Do(initLogger)
- return logger
-}
-
// Log retrieves a named logger
func Log(handle *LoggerHandle) *zap.Logger {
once.Do(initLogger)
diff --git a/pkg/log/logger_test.go b/pkg/log/logger_test.go
index 6fdbe29b..a0db0405 100644
--- a/pkg/log/logger_test.go
+++ b/pkg/log/logger_test.go
@@ -36,10 +36,10 @@ var logFile string
var iterations = 100000
func TestLoggerIds(t *testing.T) {
- _ = Logger()
+ _ = Log(Test)
// validate logger count
- assert.Equal(t, 3, len(loggers), "wrong logger count")
+ assert.Equal(t, 27, len(loggers), "wrong logger count")
// validate that all loggers are populated and have sequential ids
for i := 0; i < len(loggers); i++ {
@@ -93,7 +93,7 @@ func TestCreateConfig(t *testing.T) {
// indirect call to init logger
assert.Assert(t, logger == nil, "global logger should not have been set %v", logger)
- localLogger = Logger()
+ localLogger = Log(Test)
assert.Assert(t, localLogger != nil, "returned logger should have been not nil")
}
@@ -110,49 +110,10 @@ func TestInitializeLogger(t *testing.T) {
assert.NilError(t, err2, "failed to create local logger")
InitializeLogger(localLogger, &zapConfig)
- assert.Equal(t, RootLogger(), localLogger)
+ assert.Equal(t, logger, localLogger)
// second initialization should not do anything
InitializeLogger(localLogger2, &zapConfig)
- assert.Equal(t, RootLogger(), localLogger)
-}
-func BenchmarkLegacyLoggerDebug(b *testing.B) {
- benchmarkLegacyLoggerDebug(b.N)
-}
-
-func TestLegacyLoggerDebug(t *testing.T) {
- nsOp := benchmarkLegacyLoggerDebug(iterations)
- RootLogger().Info("log.Logger() performance", zap.Int64("debug (ns/op)", nsOp))
-}
-
-func benchmarkLegacyLoggerDebug(iterations int) int64 {
- _ = Logger()
- initTestLogger()
- defer resetTestLogger()
- start := time.Now()
- for i := 0; i < iterations; i++ {
- RootLogger().Debug("test", zap.String("foo", "bar"))
- }
- return (time.Since(start).Nanoseconds()) / int64(iterations)
-}
-
-func BenchmarkLegacyLoggerInfo(b *testing.B) {
- benchmarkLegacyLoggerInfo(b.N)
-}
-
-func TestLegacyLoggerInfo(t *testing.T) {
- nsOp := benchmarkLegacyLoggerInfo(iterations)
- RootLogger().Info("log.Logger() performance", zap.Int64("info (ns/op)", nsOp))
-}
-
-func benchmarkLegacyLoggerInfo(iterations int) int64 {
- _ = Logger()
- initTestLogger()
- defer resetTestLogger()
- start := time.Now()
- for i := 0; i < iterations; i++ {
- RootLogger().Info("test", zap.String("foo", "bar"))
- }
- return (time.Since(start).Nanoseconds()) / int64(iterations)
+ assert.Equal(t, logger, localLogger)
}
func BenchmarkScopedLoggerDebug(b *testing.B) {
@@ -165,7 +126,7 @@ func TestScopedLoggerDebug(t *testing.T) {
}
func benchmarkScopedLoggerDebug(iterations int) int64 {
- _ = Logger()
+ _ = Log(Test)
initTestLogger()
defer resetTestLogger()
UpdateLoggingConfig(map[string]string{
@@ -188,7 +149,7 @@ func TestScopedLoggerInfo(t *testing.T) {
}
func benchmarkScopedLoggerInfo(iterations int) int64 {
- _ = Logger()
+ _ = Log(Test)
initTestLogger()
defer resetTestLogger()
UpdateLoggingConfig(map[string]string{
@@ -211,7 +172,7 @@ func TestScopedLoggerDebugEnabled(t *testing.T) {
}
func benchmarkScopedLoggerDebugEnabled(iterations int) int64 {
- _ = Logger()
+ _ = Log(Test)
initTestLogger()
defer resetTestLogger()
UpdateLoggingConfig(map[string]string{
@@ -234,7 +195,7 @@ func TestScopedLoggerInfoFiltered(t *testing.T) {
}
func benchmarkScopedLoggerInfoFiltered(iterations int) int64 {
- _ = Logger()
+ _ = Log(Test)
initTestLogger()
defer resetTestLogger()
UpdateLoggingConfig(map[string]string{
diff --git a/pkg/metrics/metrics_collector.go b/pkg/metrics/metrics_collector.go
index 889615c2..ee9651ed 100644
--- a/pkg/metrics/metrics_collector.go
+++ b/pkg/metrics/metrics_collector.go
@@ -65,24 +65,24 @@ func (u *internalMetricsCollector) StartService() {
}
func (u *internalMetricsCollector) store() {
- log.Logger().Debug("Adding current status to historical partition data")
+ log.Log(log.Metrics).Debug("Adding current status to historical partition data")
totalAppsRunning, err := m.scheduler.getTotalApplicationsRunning()
if err != nil {
- log.Logger().Warn("Could not encode totalApplications metric.", zap.Error(err))
+ log.Log(log.Metrics).Warn("Could not encode totalApplications metric.", zap.Error(err))
totalAppsRunning = -1
}
allocatedContainers, err := m.scheduler.getAllocatedContainers()
if err != nil {
- log.Logger().Warn("Could not encode allocatedContainers metric.", zap.Error(err))
+ log.Log(log.Metrics).Warn("Could not encode allocatedContainers metric.", zap.Error(err))
}
releasedContainers, err := m.scheduler.getReleasedContainers()
if err != nil {
- log.Logger().Warn("Could not encode releasedContainers metric.", zap.Error(err))
+ log.Log(log.Metrics).Warn("Could not encode releasedContainers metric.", zap.Error(err))
}
totalContainersRunning := allocatedContainers - releasedContainers
if totalContainersRunning < 0 {
- log.Logger().Warn("Could not calculate the totalContainersRunning.",
+ log.Log(log.Metrics).Warn("Could not calculate the totalContainersRunning.",
zap.Int("allocatedContainers", allocatedContainers),
zap.Int("releasedContainers", releasedContainers))
}
diff --git a/pkg/metrics/metrics_test.go b/pkg/metrics/metrics_test.go
index 8bedccb0..07f979b1 100644
--- a/pkg/metrics/metrics_test.go
+++ b/pkg/metrics/metrics_test.go
@@ -50,7 +50,7 @@ func generateRandomString(len int) string {
randomBytes := make([]byte, len)
n, err := rand.Read(randomBytes)
if err != nil {
- log.Logger().Warn("Random running low on entropy",
+ log.Log(log.Metrics).Warn("Random running low on entropy",
zap.Int("bytesRequested", len),
zap.Int("bytesRead", n))
}
diff --git a/pkg/metrics/queue.go b/pkg/metrics/queue.go
index 89ff55a5..3d55eb0b 100644
--- a/pkg/metrics/queue.go
+++ b/pkg/metrics/queue.go
@@ -64,7 +64,7 @@ func InitQueueMetrics(name string) CoreQueueMetrics {
// metrics name must be complied with regex: [a-zA-Z_:][a-zA-Z0-9_:]*,
// queue name regex: ^[a-zA-Z0-9_-]{1,64}$
if err := prometheus.Register(metric); err != nil {
- log.Logger().Warn("failed to register metrics collector", zap.Error(err))
+ log.Log(log.Metrics).Warn("failed to register metrics collector", zap.Error(err))
}
}
diff --git a/pkg/metrics/runtime.go b/pkg/metrics/runtime.go
index 4139a7ce..19448142 100644
--- a/pkg/metrics/runtime.go
+++ b/pkg/metrics/runtime.go
@@ -239,7 +239,7 @@ func initRuntimeMetrics() *RuntimeMetrics {
for _, metric := range metricsList {
if err := prometheus.Register(metric); err != nil {
- log.Logger().Warn("failed to register metrics collector", zap.Error(err))
+ log.Log(log.Metrics).Warn("failed to register metrics collector", zap.Error(err))
}
}
diff --git a/pkg/metrics/scheduler.go b/pkg/metrics/scheduler.go
index d0c2d7e3..cc244e72 100644
--- a/pkg/metrics/scheduler.go
+++ b/pkg/metrics/scheduler.go
@@ -148,7 +148,7 @@ func InitSchedulerMetrics() *SchedulerMetrics {
}
for _, metric := range metricsList {
if err := prometheus.Register(metric); err != nil {
- log.Logger().Warn("failed to register metrics collector", zap.Error(err))
+ log.Log(log.Metrics).Warn("failed to register metrics collector", zap.Error(err))
}
}
return s
@@ -380,7 +380,7 @@ func (m *SchedulerMetrics) SetNodeResourceUsage(resourceName string, rangeIdx in
Help: "Total resource usage of node, by resource name.",
}, []string{"range"})
if err := prometheus.Register(resourceMetrics); err != nil {
- log.Logger().Warn("failed to register metrics collector", zap.Error(err))
+ log.Log(log.Metrics).Warn("failed to register metrics collector", zap.Error(err))
return
}
m.nodeResourceUsage[resourceName] = resourceMetrics
diff --git a/pkg/plugins/plugins.go b/pkg/plugins/plugins.go
index fb26e3ec..88f2601f 100644
--- a/pkg/plugins/plugins.go
+++ b/pkg/plugins/plugins.go
@@ -43,11 +43,11 @@ func RegisterSchedulerPlugin(plugin interface{}) {
plugins.Lock()
defer plugins.Unlock()
if rmc, ok := plugin.(api.ResourceManagerCallback); ok {
- log.Logger().Info("register scheduler plugin: ResourceManagerCallback")
+ log.Log(log.RMProxy).Info("register scheduler plugin: ResourceManagerCallback")
plugins.ResourceManagerCallbackPlugin = rmc
}
if sdp, ok := plugin.(api.StateDumpPlugin); ok {
- log.Logger().Info("register scheduler plugin: StateDumpPlugin")
+ log.Log(log.RMProxy).Info("register scheduler plugin: StateDumpPlugin")
plugins.StateDumpPlugin = sdp
}
}
diff --git a/pkg/rmproxy/rmproxy.go b/pkg/rmproxy/rmproxy.go
index 4f245469..4ace8548 100644
--- a/pkg/rmproxy/rmproxy.go
+++ b/pkg/rmproxy/rmproxy.go
@@ -56,12 +56,12 @@ func (rmp *RMProxy) GetRMEventHandler() handler.EventHandler {
func enqueueAndCheckFull(queue chan interface{}, ev interface{}) {
select {
case queue <- ev:
- log.Logger().Debug("enqueue event",
+ log.Log(log.RMProxy).Debug("enqueue event",
zap.Stringer("eventType", reflect.TypeOf(ev)),
zap.Any("event", ev),
zap.Int("currentQueueSize", len(queue)))
default:
- log.Logger().DPanic("failed to enqueue event",
+ log.Log(log.RMProxy).DPanic("failed to enqueue event",
zap.Stringer("event", reflect.TypeOf(ev)))
}
}
@@ -85,7 +85,7 @@ func (rmp *RMProxy) StartService(handlers handler.EventHandlers) {
}
func (rmp *RMProxy) handleUpdateResponseError(rmID string, err error) {
- log.Logger().Error("failed to handle response",
+ log.Log(log.RMProxy).Error("failed to handle response",
zap.String("rmID", rmID),
zap.Error(err))
}
@@ -124,7 +124,7 @@ func (rmp *RMProxy) processApplicationUpdateEvent(event *rmevent.RMApplicationUp
rmp.handleUpdateResponseError(event.RmID, err)
}
} else {
- log.Logger().DPanic("RM is not registered",
+ log.Log(log.RMProxy).DPanic("RM is not registered",
zap.String("rmID", event.RmID))
}
@@ -162,7 +162,7 @@ func (rmp *RMProxy) triggerUpdateAllocation(rmID string, response *si.Allocation
rmp.handleUpdateResponseError(rmID, err)
}
} else {
- log.Logger().DPanic("RM is not registered",
+ log.Log(log.RMProxy).DPanic("RM is not registered",
zap.String("rmID", rmID))
}
}
@@ -208,7 +208,7 @@ func (rmp *RMProxy) processRMNodeUpdateEvent(event *rmevent.RMNodeUpdateEvent) {
rmp.handleUpdateResponseError(event.RmID, err)
}
} else {
- log.Logger().DPanic("RM is not registered",
+ log.Log(log.RMProxy).DPanic("RM is not registered",
zap.String("rmID", event.RmID))
}
}
diff --git a/pkg/scheduler/context.go b/pkg/scheduler/context.go
index 7a7b06ba..37d93726 100644
--- a/pkg/scheduler/context.go
+++ b/pkg/scheduler/context.go
@@ -170,7 +170,7 @@ func (cc *ClusterContext) processRMRegistrationEvent(event *rmevent.RMRegistrati
// load the config this returns a validated configuration
if len(config) == 0 {
- log.Logger().Info("No scheduler configuration supplied, using defaults", zap.String("rmID", rmID))
+ log.Log(log.SchedContext).Info("No scheduler configuration supplied, using defaults", zap.String("rmID", rmID))
config = configs.DefaultSchedulerConfig
}
conf, err := configs.LoadSchedulerConfigFromByteArray([]byte(config))
@@ -216,7 +216,7 @@ func (cc *ClusterContext) processRMConfigUpdateEvent(event *rmevent.RMConfigUpda
// load the config this returns a validated configuration
config := event.Config
if len(config) == 0 {
- log.Logger().Info("No scheduler configuration supplied, using defaults", zap.String("rmID", rmID))
+ log.Log(log.SchedContext).Info("No scheduler configuration supplied, using defaults", zap.String("rmID", rmID))
config = configs.DefaultSchedulerConfig
}
conf, err := configs.LoadSchedulerConfigFromByteArray([]byte(config))
@@ -324,7 +324,7 @@ func (cc *ClusterContext) UpdateSchedulerConfig(conf *configs.SchedulerConfig) e
// hack around the missing rmID
for _, pi := range cc.partitions {
rmID := pi.RmID
- log.Logger().Debug("Assuming one RM on config update call from webservice",
+ log.Log(log.SchedContext).Debug("Assuming one RM on config update call from webservice",
zap.String("rmID", rmID))
if err := cc.updateSchedulerConfig(conf, rmID); err != nil {
return err
@@ -379,14 +379,14 @@ func (cc *ClusterContext) updateSchedulerConfig(conf *configs.SchedulerConfig, r
return err
}
// checks passed perform the real update
- log.Logger().Info("updating partitions", zap.String("partitionName", partitionName))
+ log.Log(log.SchedContext).Info("updating partitions", zap.String("partitionName", partitionName))
err = part.updatePartitionDetails(p)
if err != nil {
return err
}
} else {
// not found: new partition, no checks needed
- log.Logger().Info("added partitions", zap.String("partitionName", partitionName))
+ log.Log(log.SchedContext).Info("added partitions", zap.String("partitionName", partitionName))
part, err = newPartitionContext(p, rmID, cc)
if err != nil {
@@ -403,7 +403,7 @@ func (cc *ClusterContext) updateSchedulerConfig(conf *configs.SchedulerConfig, r
for _, part := range cc.partitions {
if !visited[part.Name] {
part.partitionManager.Stop()
- log.Logger().Info("marked partition for removal",
+ log.Log(log.SchedContext).Info("marked partition for removal",
zap.String("partitionName", part.Name))
}
}
@@ -509,7 +509,7 @@ func (cc *ClusterContext) handleRMUpdateApplicationEvent(event *rmevent.RMUpdate
ApplicationID: app.ApplicationID,
Reason: msg,
})
- log.Logger().Error("Failed to add application to non existing partition",
+ log.Log(log.SchedContext).Error("Failed to add application to non existing partition",
zap.String("applicationID", app.ApplicationID),
zap.String("partitionName", app.PartitionName))
continue
@@ -523,7 +523,7 @@ func (cc *ClusterContext) handleRMUpdateApplicationEvent(event *rmevent.RMUpdate
Reason: err.Error(),
})
partition.AddRejectedApplication(objects.NewApplication(app, ugi, cc.rmEventHandler, request.RmID), err.Error())
- log.Logger().Error("Failed to add application to partition (user rejected)",
+ log.Log(log.SchedContext).Error("Failed to add application to partition (user rejected)",
zap.String("applicationID", app.ApplicationID),
zap.String("partitionName", app.PartitionName),
zap.Error(err))
@@ -537,7 +537,7 @@ func (cc *ClusterContext) handleRMUpdateApplicationEvent(event *rmevent.RMUpdate
Reason: err.Error(),
})
partition.AddRejectedApplication(schedApp, err.Error())
- log.Logger().Error("Failed to add application to partition (placement rejected)",
+ log.Log(log.SchedContext).Error("Failed to add application to partition (placement rejected)",
zap.String("applicationID", app.ApplicationID),
zap.String("partitionName", app.PartitionName),
zap.Error(err))
@@ -546,7 +546,7 @@ func (cc *ClusterContext) handleRMUpdateApplicationEvent(event *rmevent.RMUpdate
acceptedApps = append(acceptedApps, &si.AcceptedApplication{
ApplicationID: schedApp.ApplicationID,
})
- log.Logger().Info("Added application to partition",
+ log.Log(log.SchedContext).Info("Added application to partition",
zap.String("applicationID", app.ApplicationID),
zap.String("partitionName", app.PartitionName),
zap.String("requested queue", app.QueueName),
@@ -577,7 +577,7 @@ func (cc *ClusterContext) handleRMUpdateApplicationEvent(event *rmevent.RMUpdate
cc.notifyRMAllocationReleased(partition.RmID, allocations, si.TerminationType_STOPPED_BY_RM,
fmt.Sprintf("Application %s Removed", app.ApplicationID))
}
- log.Logger().Info("Application removed from partition",
+ log.Log(log.SchedContext).Info("Application removed from partition",
zap.String("applicationID", app.ApplicationID),
zap.String("partitionName", app.PartitionName),
zap.Int("allocations released", len(allocations)))
@@ -613,7 +613,7 @@ func (cc *ClusterContext) addNode(nodeInfo *si.NodeInfo) error {
err := fmt.Errorf("failed to find partition %s for new node %s", sn.Partition, sn.NodeID)
//nolint: TODO assess impact of partition metrics (this never hit the partition)
metrics.GetSchedulerMetrics().IncFailedNodes()
- log.Logger().Error("Failed to add node to non existing partition",
+ log.Log(log.SchedContext).Error("Failed to add node to non existing partition",
zap.String("nodeID", sn.NodeID),
zap.String("partitionName", sn.Partition))
return err
@@ -623,13 +623,13 @@ func (cc *ClusterContext) addNode(nodeInfo *si.NodeInfo) error {
err := partition.AddNode(sn, existingAllocations)
if err != nil {
wrapped := fmt.Errorf("failure while adding new node, node rejected with error: %w", err)
- log.Logger().Error("Failed to add node to partition (rejected)",
+ log.Log(log.SchedContext).Error("Failed to add node to partition (rejected)",
zap.String("nodeID", sn.NodeID),
zap.String("partitionName", sn.Partition),
zap.Error(err))
return wrapped
}
- log.Logger().Info("successfully added node",
+ log.Log(log.SchedContext).Info("successfully added node",
zap.String("nodeID", sn.NodeID),
zap.String("partition", sn.Partition))
return nil
@@ -642,14 +642,14 @@ func (cc *ClusterContext) updateNode(nodeInfo *si.NodeInfo) {
if p, ok := nodeInfo.Attributes[siCommon.NodePartition]; ok {
partition = cc.GetPartition(p)
} else {
- log.Logger().Error("node partition not specified",
+ log.Log(log.SchedContext).Error("node partition not specified",
zap.String("nodeID", nodeInfo.NodeID),
zap.Stringer("nodeAction", nodeInfo.Action))
return
}
if partition == nil {
- log.Logger().Error("Failed to update node on non existing partition",
+ log.Log(log.SchedContext).Error("Failed to update node on non existing partition",
zap.String("nodeID", nodeInfo.NodeID),
zap.String("partitionName", nodeInfo.Attributes[siCommon.NodePartition]),
zap.Stringer("nodeAction", nodeInfo.Action))
@@ -658,7 +658,7 @@ func (cc *ClusterContext) updateNode(nodeInfo *si.NodeInfo) {
node := partition.GetNode(nodeInfo.NodeID)
if node == nil {
- log.Logger().Error("Failed to update non existing node",
+ log.Log(log.SchedContext).Error("Failed to update non existing node",
zap.String("nodeID", nodeInfo.NodeID),
zap.String("partitionName", nodeInfo.Attributes[siCommon.NodePartition]),
zap.Stringer("nodeAction", nodeInfo.Action))
@@ -670,16 +670,16 @@ func (cc *ClusterContext) updateNode(nodeInfo *si.NodeInfo) {
var newReadyStatus bool
var err error
if newReadyStatus, err = strconv.ParseBool(nodeInfo.Attributes[siCommon.NodeReadyAttribute]); err != nil {
- log.Logger().Error("Could not parse ready attribute, assuming true", zap.Any("attributes", nodeInfo.Attributes))
+ log.Log(log.SchedContext).Error("Could not parse ready attribute, assuming true", zap.Any("attributes", nodeInfo.Attributes))
newReadyStatus = true
}
if node.IsReady() && !newReadyStatus {
- log.Logger().Info("Node has become unhealthy", zap.String("Node ID", node.NodeID))
+ log.Log(log.SchedContext).Info("Node has become unhealthy", zap.String("Node ID", node.NodeID))
metrics.GetSchedulerMetrics().IncUnhealthyNodes()
}
if !node.IsReady() && newReadyStatus {
- log.Logger().Info("Node has become healthy", zap.String("Node ID", node.NodeID))
+ log.Log(log.SchedContext).Info("Node has become healthy", zap.String("Node ID", node.NodeID))
metrics.GetSchedulerMetrics().DecUnhealthyNodes()
}
node.SetReady(newReadyStatus)
@@ -722,7 +722,7 @@ func (cc *ClusterContext) updateNode(nodeInfo *si.NodeInfo) {
cc.notifyRMNewAllocation(partition.RmID, confirm)
}
default:
- log.Logger().Debug("unknown action for node update",
+ log.Log(log.SchedContext).Debug("unknown action for node update",
zap.String("nodeID", nodeInfo.NodeID),
zap.String("partitionName", nodeInfo.Attributes[siCommon.NodePartition]),
zap.Stringer("nodeAction", nodeInfo.Action))
@@ -758,7 +758,7 @@ func (cc *ClusterContext) processAsks(request *si.AllocationRequest) {
partition := cc.GetPartition(siAsk.PartitionName)
if partition == nil {
msg := fmt.Sprintf("Failed to find partition %s, for application %s and allocation %s", siAsk.PartitionName, siAsk.ApplicationID, siAsk.AllocationKey)
- log.Logger().Error("Invalid ask add requested by shim, partition not found",
+ log.Log(log.SchedContext).Error("Invalid ask add requested by shim, partition not found",
zap.String("partition", siAsk.PartitionName),
zap.String("applicationID", siAsk.ApplicationID),
zap.String("askKey", siAsk.AllocationKey))
@@ -778,7 +778,7 @@ func (cc *ClusterContext) processAsks(request *si.AllocationRequest) {
ApplicationID: siAsk.ApplicationID,
Reason: err.Error(),
})
- log.Logger().Error("Invalid ask add requested by shim",
+ log.Log(log.SchedContext).Error("Invalid ask add requested by shim",
zap.String("partition", siAsk.PartitionName),
zap.String("applicationID", siAsk.ApplicationID),
zap.String("askKey", siAsk.AllocationKey),
@@ -799,7 +799,7 @@ func (cc *ClusterContext) processAskReleases(releases []*si.AllocationAskRelease
for _, toRelease := range releases {
partition := cc.GetPartition(toRelease.PartitionName)
if partition == nil {
- log.Logger().Error("Invalid ask release requested by shim, partition not found",
+ log.Log(log.SchedContext).Error("Invalid ask release requested by shim, partition not found",
zap.String("partition", toRelease.PartitionName),
zap.String("applicationID", toRelease.ApplicationID),
zap.String("askKey", toRelease.AllocationKey))
@@ -850,9 +850,9 @@ func (cc *ClusterContext) notifyRMNewAllocation(rmID string, alloc *objects.Allo
// Wait from channel
result := <-c
if result.Succeeded {
- log.Logger().Debug("Successfully synced shim on new allocation. response: " + result.Reason)
+ log.Log(log.SchedContext).Debug("Successfully synced shim on new allocation. response: " + result.Reason)
} else {
- log.Logger().Info("failed to sync shim on new allocation",
+ log.Log(log.SchedContext).Info("failed to sync shim on new allocation",
zap.String("Allocation key: ", alloc.GetAllocationKey()))
}
}
@@ -881,9 +881,9 @@ func (cc *ClusterContext) notifyRMAllocationReleased(rmID string, released []*ob
// Wait from channel
result := <-c
if result.Succeeded {
- log.Logger().Debug("Successfully synced shim on released allocations. response: " + result.Reason)
+ log.Log(log.SchedContext).Debug("Successfully synced shim on released allocations. response: " + result.Reason)
} else {
- log.Logger().Info("failed to sync shim on released allocations")
+ log.Log(log.SchedContext).Info("failed to sync shim on released allocations")
}
}
@@ -896,7 +896,7 @@ func (cc *ClusterContext) GetNode(nodeID, partitionName string) *objects.Node {
partition := cc.partitions[partitionName]
if partition == nil {
- log.Logger().Info("partition not found for scheduling node",
+ log.Log(log.SchedContext).Info("partition not found for scheduling node",
zap.String("nodeID", nodeID),
zap.String("partitionName", partitionName))
return nil
diff --git a/pkg/scheduler/health_checker.go b/pkg/scheduler/health_checker.go
index 7e2c2c9e..6c3d3a1a 100644
--- a/pkg/scheduler/health_checker.go
+++ b/pkg/scheduler/health_checker.go
@@ -76,7 +76,7 @@ func (c *HealthChecker) readPeriod() time.Duration {
result, err := time.ParseDuration(value)
if err != nil {
- log.Logger().Warn("Failed to parse configuration value",
+ log.Log(log.SchedHealth).Warn("Failed to parse configuration value",
zap.String("key", configs.HealthCheckInterval),
zap.String("value", value),
zap.Error(err))
@@ -112,7 +112,7 @@ func (c *HealthChecker) startInternal(runImmediately bool) {
c.period = period
c.enabled = true
- log.Logger().Info("Starting periodic health checker", zap.Duration("interval", period))
+ log.Log(log.SchedHealth).Info("Starting periodic health checker", zap.Duration("interval", period))
go func() {
ticker := time.NewTicker(period)
@@ -131,7 +131,7 @@ func (c *HealthChecker) startInternal(runImmediately bool) {
c.stopChan = nil
c.period = 0
c.enabled = false
- log.Logger().Info("Periodic health checker disabled")
+ log.Log(log.SchedHealth).Info("Periodic health checker disabled")
}
}
@@ -142,7 +142,7 @@ func (c *HealthChecker) Stop() {
configs.RemoveConfigMapCallback(c.confWatcherId)
if c.stopChan != nil {
- log.Logger().Info("Stopping periodic health checker")
+ log.Log(log.SchedHealth).Info("Stopping periodic health checker")
*c.stopChan <- struct{}{}
close(*c.stopChan)
c.stopChan = nil
@@ -173,10 +173,10 @@ func (c *HealthChecker) runOnce() {
result := GetSchedulerHealthStatus(schedulerMetrics, c.context)
updateSchedulerLastHealthStatus(&result, c.context)
if !result.Healthy {
- log.Logger().Warn("Scheduler is not healthy",
+ log.Log(log.SchedHealth).Warn("Scheduler is not healthy",
zap.Any("health check values", result.HealthChecks))
} else {
- log.Logger().Debug("Scheduler is healthy",
+ log.Log(log.SchedHealth).Debug("Scheduler is healthy",
zap.Any("health check values", result.HealthChecks))
}
}
diff --git a/pkg/scheduler/mock_plugin_test.go b/pkg/scheduler/mock_plugin_test.go
index 9866c27c..c5f0f87e 100644
--- a/pkg/scheduler/mock_plugin_test.go
+++ b/pkg/scheduler/mock_plugin_test.go
@@ -36,24 +36,24 @@ type fakePredicatePlugin struct {
func (f *fakePredicatePlugin) Predicates(args *si.PredicatesArgs) error {
if f.mustFail {
- log.Logger().Info("fake predicate plugin fail: must fail set")
+ log.Log(log.Test).Info("fake predicate plugin fail: must fail set")
return fmt.Errorf("fake predicate plugin failed")
}
if fail, ok := f.nodes[args.NodeID]; ok {
if args.Allocate && fail >= 0 {
- log.Logger().Info("fake predicate plugin node allocate fail",
+ log.Log(log.Test).Info("fake predicate plugin node allocate fail",
zap.String("node", args.NodeID),
zap.Int("fail mode", fail))
return fmt.Errorf("fake predicate plugin failed")
}
if !args.Allocate && fail <= 0 {
- log.Logger().Info("fake predicate plugin node reserve fail",
+ log.Log(log.Test).Info("fake predicate plugin node reserve fail",
zap.String("node", args.NodeID),
zap.Int("fail mode", fail))
return fmt.Errorf("fake predicate plugin failed")
}
}
- log.Logger().Info("fake predicate plugin pass",
+ log.Log(log.Test).Info("fake predicate plugin pass",
zap.String("node", args.NodeID))
return nil
}
diff --git a/pkg/scheduler/objects/allocation.go b/pkg/scheduler/objects/allocation.go
index 0f17f995..3e85b650 100644
--- a/pkg/scheduler/objects/allocation.go
+++ b/pkg/scheduler/objects/allocation.go
@@ -120,14 +120,14 @@ func NewAllocationFromSI(alloc *si.Allocation, instType string) *Allocation {
// this is a safety check placeholder and task group name must be set as a combo
// order is important as task group can be set without placeholder but not the other way around
if alloc.Placeholder && alloc.TaskGroupName == "" {
- log.Logger().Debug("Allocation cannot be a placeholder without a TaskGroupName",
+ log.Log(log.SchedAllocation).Debug("Allocation cannot be a placeholder without a TaskGroupName",
zap.Stringer("SI alloc", alloc))
return nil
}
creationTime, err := strconv.ParseInt(alloc.AllocationTags[siCommon.CreationTime], 10, 64)
if err != nil {
- log.Logger().Warn("CreationTime is not set on the Allocation object or invalid",
+ log.Log(log.SchedAllocation).Warn("CreationTime is not set on the Allocation object or invalid",
zap.String("creationTime", alloc.AllocationTags[siCommon.CreationTime]))
creationTime = -1
}
diff --git a/pkg/scheduler/objects/allocation_ask.go b/pkg/scheduler/objects/allocation_ask.go
index 8c689049..d116b687 100644
--- a/pkg/scheduler/objects/allocation_ask.go
+++ b/pkg/scheduler/objects/allocation_ask.go
@@ -97,7 +97,7 @@ func NewAllocationAskFromSI(ask *si.AllocationAsk) *AllocationAsk {
// this is a safety check placeholder and task group name must be set as a combo
// order is important as task group can be set without placeholder but not the other way around
if saa.placeholder && saa.taskGroupName == "" {
- log.Logger().Debug("ask cannot be a placeholder without a TaskGroupName",
+ log.Log(log.SchedAllocation).Debug("ask cannot be a placeholder without a TaskGroupName",
zap.Stringer("SI ask", ask))
return nil
}
diff --git a/pkg/scheduler/objects/application.go b/pkg/scheduler/objects/application.go
index 6c583533..961f46cb 100644
--- a/pkg/scheduler/objects/application.go
+++ b/pkg/scheduler/objects/application.go
@@ -125,7 +125,7 @@ type ApplicationSummary struct {
}
func (as *ApplicationSummary) DoLogging() {
- log.Log(log.AppUsage).Info("YK_APP_SUMMARY:",
+ log.Log(log.SchedAppUsage).Info("YK_APP_SUMMARY:",
zap.String("appID", as.ApplicationID),
zap.Int64("submissionTime", as.SubmissionTime.UnixMilli()),
zap.Int64("startTime", as.StartTime.UnixMilli()),
@@ -183,7 +183,7 @@ func NewApplication(siApp *si.AddApplicationRequest, ugi security.UserGroup, eve
placeholderTimeout := common.ConvertSITimeoutWithAdjustment(siApp, defaultPlaceholderTimeout)
gangSchedStyle := siApp.GetGangSchedulingStyle()
if gangSchedStyle != Soft && gangSchedStyle != Hard {
- log.Logger().Info("Unknown gang scheduling style, using soft style as default",
+ log.Log(log.SchedApplication).Info("Unknown gang scheduling style, using soft style as default",
zap.String("gang scheduling style", gangSchedStyle))
gangSchedStyle = Soft
}
@@ -230,7 +230,7 @@ func (sa *Application) GetStateLog() []*StateLogEntry {
// Set the reservation delay.
// Set when the cluster context is created to disable reservation.
func SetReservationDelay(delay time.Duration) {
- log.Logger().Debug("Set reservation delay",
+ log.Log(log.SchedApplication).Debug("Set reservation delay",
zap.Duration("delay", delay))
reservationDelay = delay
}
@@ -339,7 +339,7 @@ func (sa *Application) OnStateChange(event *fsm.Event, eventInfo string) {
// This prevents an app from not progressing to Running when it only has 1 allocation.
// Called when entering the Starting state by the state machine.
func (sa *Application) setStateTimer(timeout time.Duration, currentState string, event applicationEvent) {
- log.Logger().Debug("Application state timer initiated",
+ log.Log(log.SchedApplication).Debug("Application state timer initiated",
zap.String("appID", sa.ApplicationID),
zap.String("state", sa.stateMachine.Current()),
zap.Duration("timeout", timeout))
@@ -355,7 +355,7 @@ func (sa *Application) timeoutStateTimer(expectedState string, event application
// make sure we are still in the right state
// we could have been failed or something might have happened while waiting for a lock
if expectedState == sa.stateMachine.Current() {
- log.Logger().Debug("Application state: auto progress",
+ log.Log(log.SchedApplication).Debug("Application state: auto progress",
zap.String("applicationID", sa.ApplicationID),
zap.String("state", sa.stateMachine.Current()))
// if the app is completing, but there are placeholders left, first do the cleanup
@@ -388,7 +388,7 @@ func (sa *Application) clearStateTimer() {
}
sa.stateTimer.Stop()
sa.stateTimer = nil
- log.Logger().Debug("Application state timer cleared",
+ log.Log(log.SchedApplication).Debug("Application state timer cleared",
zap.String("appID", sa.ApplicationID),
zap.String("state", sa.stateMachine.Current()))
}
@@ -397,7 +397,7 @@ func (sa *Application) initPlaceholderTimer() {
if sa.placeholderTimer != nil || !sa.IsAccepted() || sa.execTimeout <= 0 {
return
}
- log.Logger().Debug("Application placeholder timer initiated",
+ log.Log(log.SchedApplication).Debug("Application placeholder timer initiated",
zap.String("AppID", sa.ApplicationID),
zap.Duration("Timeout", sa.execTimeout))
sa.placeholderTimer = time.AfterFunc(sa.execTimeout, sa.timeoutPlaceholderProcessing)
@@ -409,7 +409,7 @@ func (sa *Application) clearPlaceholderTimer() {
}
sa.placeholderTimer.Stop()
sa.placeholderTimer = nil
- log.Logger().Debug("Application placeholder timer cleared",
+ log.Log(log.SchedApplication).Debug("Application placeholder timer cleared",
zap.String("AppID", sa.ApplicationID),
zap.Duration("Timeout", sa.execTimeout))
}
@@ -440,14 +440,14 @@ func (sa *Application) timeoutPlaceholderProcessing() {
sa.placeholderData[alloc.GetTaskGroup()].TimedOut++
}
}
- log.Logger().Info("Placeholder timeout, releasing placeholders",
+ log.Log(log.SchedApplication).Info("Placeholder timeout, releasing placeholders",
zap.String("AppID", sa.ApplicationID),
zap.Int("placeholders being replaced", replacing),
zap.Int("releasing placeholders", len(toRelease)))
sa.notifyRMAllocationReleased(sa.rmID, toRelease, si.TerminationType_TIMEOUT, "releasing allocated placeholders on placeholder timeout")
// Case 2: in every other case fail the application, and notify the context about the expired placeholder asks
default:
- log.Logger().Info("Placeholder timeout, releasing asks and placeholders",
+ log.Log(log.SchedApplication).Info("Placeholder timeout, releasing asks and placeholders",
zap.String("AppID", sa.ApplicationID),
zap.Int("releasing placeholders", len(sa.allocations)),
zap.Int("releasing asks", len(sa.requests)),
@@ -458,7 +458,7 @@ func (sa *Application) timeoutPlaceholderProcessing() {
event = FailApplication
}
if err := sa.HandleApplicationEventWithInfo(event, "ResourceReservationTimeout"); err != nil {
- log.Logger().Debug("Application state change failed when placeholder timed out",
+ log.Log(log.SchedApplication).Debug("Application state change failed when placeholder timed out",
zap.String("AppID", sa.ApplicationID),
zap.String("currentState", sa.CurrentState()),
zap.Error(err))
@@ -553,7 +553,7 @@ func (sa *Application) removeAsksInternal(allocKey string) int {
for key, reserve := range sa.reservations {
releases, err := sa.unReserveInternal(reserve.node, reserve.ask)
if err != nil {
- log.Logger().Warn("Removal of reservation failed while removing all allocation asks",
+ log.Log(log.SchedApplication).Warn("Removal of reservation failed while removing all allocation asks",
zap.String("appID", sa.ApplicationID),
zap.String("reservationKey", key),
zap.Error(err))
@@ -576,7 +576,7 @@ func (sa *Application) removeAsksInternal(allocKey string) int {
reserve := sa.reservations[key]
releases, err := sa.unReserveInternal(reserve.node, reserve.ask)
if err != nil {
- log.Logger().Warn("Removal of reservation failed while removing allocation ask",
+ log.Log(log.SchedApplication).Warn("Removal of reservation failed while removing allocation ask",
zap.String("appID", sa.ApplicationID),
zap.String("reservationKey", key),
zap.Error(err))
@@ -606,13 +606,13 @@ func (sa *Application) removeAsksInternal(allocKey string) int {
hasPlaceHolderAllocations := len(sa.getPlaceholderAllocations()) > 0
if resources.IsZero(sa.pending) && resources.IsZero(sa.allocatedResource) && !sa.IsFailing() && !sa.IsCompleting() && !hasPlaceHolderAllocations {
if err := sa.HandleApplicationEvent(CompleteApplication); err != nil {
- log.Logger().Warn("Application state not changed to Completing while updating ask(s)",
+ log.Log(log.SchedApplication).Warn("Application state not changed to Completing while updating ask(s)",
zap.String("currentState", sa.CurrentState()),
zap.Error(err))
}
}
- log.Logger().Info("ask removed successfully from application",
+ log.Log(log.SchedApplication).Info("ask removed successfully from application",
zap.String("appID", sa.ApplicationID),
zap.String("ask", allocKey),
zap.Stringer("pendingDelta", deltaPendingResource))
@@ -644,7 +644,7 @@ func (sa *Application) AddAllocationAsk(ask *AllocationAsk) error {
// Move the state and get it scheduling (again)
if sa.stateMachine.Is(New.String()) || sa.stateMachine.Is(Completing.String()) {
if err := sa.HandleApplicationEvent(RunApplication); err != nil {
- log.Logger().Debug("Application state change failed while adding new ask",
+ log.Log(log.SchedApplication).Debug("Application state change failed while adding new ask",
zap.String("currentState", sa.CurrentState()),
zap.Error(err))
}
@@ -668,7 +668,7 @@ func (sa *Application) AddAllocationAsk(ask *AllocationAsk) error {
sa.addPlaceholderData(ask)
}
- log.Logger().Info("ask added successfully to application",
+ log.Log(log.SchedApplication).Info("ask added successfully to application",
zap.String("appID", sa.ApplicationID),
zap.String("ask", ask.GetAllocationKey()),
zap.Bool("placeholder", ask.IsPlaceholder()),
@@ -701,7 +701,7 @@ func (sa *Application) RecoverAllocationAsk(ask *AllocationAsk) {
// progress the application from New to Accepted.
if sa.IsNew() {
if err := sa.HandleApplicationEvent(RunApplication); err != nil {
- log.Logger().Debug("Application state change failed while recovering allocation ask",
+ log.Log(log.SchedApplication).Debug("Application state change failed while recovering allocation ask",
zap.Error(err))
}
}
@@ -787,7 +787,7 @@ func (sa *Application) reserveInternal(node *Node, ask *AllocationAsk) error {
// create the reservation (includes nil checks)
nodeReservation := newReservation(node, sa, ask, true)
if nodeReservation == nil {
- log.Logger().Debug("reservation creation failed unexpectedly",
+ log.Log(log.SchedApplication).Debug("reservation creation failed unexpectedly",
zap.String("app", sa.ApplicationID),
zap.Any("node", node),
zap.Any("ask", ask))
@@ -795,7 +795,7 @@ func (sa *Application) reserveInternal(node *Node, ask *AllocationAsk) error {
}
allocKey := ask.GetAllocationKey()
if sa.requests[allocKey] == nil {
- log.Logger().Debug("ask is not registered to this app",
+ log.Log(log.SchedApplication).Debug("ask is not registered to this app",
zap.String("app", sa.ApplicationID),
zap.String("allocKey", allocKey))
return fmt.Errorf("reservation creation failed ask %s not found on appID %s", allocKey, sa.ApplicationID)
@@ -808,7 +808,7 @@ func (sa *Application) reserveInternal(node *Node, ask *AllocationAsk) error {
return err
}
sa.reservations[nodeReservation.getKey()] = nodeReservation
- log.Logger().Info("reservation added successfully",
+ log.Log(log.SchedApplication).Info("reservation added successfully",
zap.String("app", sa.ApplicationID),
zap.String("node", node.NodeID),
zap.String("ask", allocKey))
@@ -830,7 +830,7 @@ func (sa *Application) UnReserve(node *Node, ask *AllocationAsk) (int, error) {
func (sa *Application) unReserveInternal(node *Node, ask *AllocationAsk) (int, error) {
resKey := reservationKey(node, nil, ask)
if resKey == "" {
- log.Logger().Debug("unreserve reservation key create failed unexpectedly",
+ log.Log(log.SchedApplication).Debug("unreserve reservation key create failed unexpectedly",
zap.String("appID", sa.ApplicationID),
zap.Stringer("node", node),
zap.Stringer("ask", ask))
@@ -846,18 +846,18 @@ func (sa *Application) unReserveInternal(node *Node, ask *AllocationAsk) (int, e
if _, found := sa.reservations[resKey]; found {
// worked on the node means either found or not but no error, log difference here
if num == 0 {
- log.Logger().Info("reservation not found while removing from node, app has reservation",
+ log.Log(log.SchedApplication).Info("reservation not found while removing from node, app has reservation",
zap.String("appID", sa.ApplicationID),
zap.String("nodeID", node.NodeID),
zap.String("ask", ask.GetAllocationKey()))
}
delete(sa.reservations, resKey)
- log.Logger().Info("reservation removed successfully", zap.String("node", node.NodeID),
+ log.Log(log.SchedApplication).Info("reservation removed successfully", zap.String("node", node.NodeID),
zap.String("app", ask.GetApplicationID()), zap.String("ask", ask.GetAllocationKey()))
return 1, nil
}
// reservation was not found
- log.Logger().Info("reservation not found while removing from app",
+ log.Log(log.SchedApplication).Info("reservation not found while removing from app",
zap.String("appID", sa.ApplicationID),
zap.String("nodeID", node.NodeID),
zap.String("ask", ask.GetAllocationKey()),
@@ -889,7 +889,7 @@ func (sa *Application) canAskReserve(ask *AllocationAsk) bool {
pending := int(ask.GetPendingAskRepeat())
resNumber := sa.GetAskReservations(allocKey)
if len(resNumber) >= pending {
- log.Logger().Debug("reservation exceeds repeats",
+ log.Log(log.SchedApplication).Debug("reservation exceeds repeats",
zap.String("askKey", allocKey),
zap.Int("askPending", pending),
zap.Int("askReserved", len(resNumber)))
@@ -972,7 +972,7 @@ func (sa *Application) tryAllocate(headRoom *resources.Resource, preemptionDelay
// the iterator might not have the node we need as it could be reserved, or we have not added it yet
node := getNodeFn(requiredNode)
if node == nil {
- log.Logger().Warn("required node is not found (could be transient)",
+ log.Log(log.SchedApplication).Warn("required node is not found (could be transient)",
zap.String("application ID", sa.ApplicationID),
zap.String("allocationKey", request.GetAllocationKey()),
zap.String("required node", requiredNode))
@@ -990,14 +990,14 @@ func (sa *Application) tryAllocate(headRoom *resources.Resource, preemptionDelay
if alloc != nil {
// check if the node was reserved and we allocated after a release
if _, ok := sa.reservations[reservationKey(node, nil, request)]; ok {
- log.Logger().Debug("allocation on required node after release",
+ log.Log(log.SchedApplication).Debug("allocation on required node after release",
zap.String("appID", sa.ApplicationID),
zap.String("nodeID", requiredNode),
zap.String("allocationKey", request.GetAllocationKey()))
alloc.SetResult(AllocatedReserved)
return alloc
}
- log.Logger().Debug("allocation on required node is completed",
+ log.Log(log.SchedApplication).Debug("allocation on required node is completed",
zap.String("nodeID", node.NodeID),
zap.String("allocationKey", request.GetAllocationKey()),
zap.Stringer("AllocationResult", alloc.GetResult()))
@@ -1034,7 +1034,7 @@ func (sa *Application) cancelReservations(reservations []*reservation) bool {
for _, res := range reservations {
// skip the node
if res.ask.GetRequiredNode() != "" {
- log.Logger().Warn("reservation for ask with required node already exists on the node",
+ log.Log(log.SchedApplication).Warn("reservation for ask with required node already exists on the node",
zap.String("required node", res.node.NodeID),
zap.String("existing ask reservation key", res.getKey()))
return false
@@ -1051,7 +1051,7 @@ func (sa *Application) cancelReservations(reservations []*reservation) bool {
num, err = res.app.UnReserve(res.node, res.ask)
}
if err != nil {
- log.Logger().Warn("Unable to cancel reservations on node",
+ log.Log(log.SchedApplication).Warn("Unable to cancel reservations on node",
zap.String("victim application ID", res.app.ApplicationID),
zap.String("victim allocationKey", res.getKey()),
zap.String("required node", res.node.NodeID),
@@ -1059,7 +1059,7 @@ func (sa *Application) cancelReservations(reservations []*reservation) bool {
zap.String("application ID", sa.ApplicationID))
return false
} else {
- log.Logger().Info("Cancelled reservation on required node",
+ log.Log(log.SchedApplication).Info("Cancelled reservation on required node",
zap.String("affected application ID", res.app.ApplicationID),
zap.String("affected allocationKey", res.getKey()),
zap.String("required node", res.node.NodeID),
@@ -1111,7 +1111,7 @@ func (sa *Application) tryPlaceholderAllocate(nodeIterator func() NodeIterator,
// placeholder. This should trigger the removal of all the placeholder that are part of this task group.
// All placeholders in the same task group are always the same size.
if delta.HasNegativeValue() {
- log.Logger().Warn("releasing placeholder: real allocation is larger than placeholder",
+ log.Log(log.SchedApplication).Warn("releasing placeholder: real allocation is larger than placeholder",
zap.Stringer("requested resource", request.GetAllocatedResource()),
zap.String("placeholderID", ph.GetUUID()),
zap.Stringer("placeholder resource", ph.GetAllocatedResource()))
@@ -1142,7 +1142,7 @@ func (sa *Application) tryPlaceholderAllocate(nodeIterator func() NodeIterator,
ph.SetReleased(true)
_, err := sa.updateAskRepeatInternal(request, -1)
if err != nil {
- log.Logger().Warn("ask repeat update failed unexpectedly",
+ log.Log(log.SchedApplication).Warn("ask repeat update failed unexpectedly",
zap.Error(err))
}
return alloc
@@ -1160,11 +1160,11 @@ func (sa *Application) tryPlaceholderAllocate(nodeIterator func() NodeIterator,
for iterator.HasNext() {
node := iterator.Next()
if node == nil {
- log.Logger().Warn("Node iterator failed to return a node")
+ log.Log(log.SchedApplication).Warn("Node iterator failed to return a node")
return nil
}
if !node.IsSchedulable() {
- log.Logger().Debug("skipping node for placeholder ask as state is unschedulable",
+ log.Log(log.SchedApplication).Debug("skipping node for placeholder ask as state is unschedulable",
zap.String("allocationKey", reqFit.GetAllocationKey()),
zap.String("node", node.NodeID))
continue
@@ -1189,7 +1189,7 @@ func (sa *Application) tryPlaceholderAllocate(nodeIterator func() NodeIterator,
// update just the node to make sure we keep its spot
// no queue update as we're releasing the placeholder and are just temp over the size
if !node.AddAllocation(alloc) {
- log.Logger().Debug("Node update failed unexpectedly",
+ log.Log(log.SchedApplication).Debug("Node update failed unexpectedly",
zap.String("applicationID", sa.ApplicationID),
zap.Stringer("ask", reqFit),
zap.Stringer("placeholder", phFit))
@@ -1197,7 +1197,7 @@ func (sa *Application) tryPlaceholderAllocate(nodeIterator func() NodeIterator,
}
_, err := sa.updateAskRepeatInternal(reqFit, -1)
if err != nil {
- log.Logger().Warn("ask repeat update failed unexpectedly",
+ log.Log(log.SchedApplication).Warn("ask repeat update failed unexpectedly",
zap.Error(err))
}
return alloc
@@ -1289,7 +1289,7 @@ func (sa *Application) tryPreemption(headRoom *resources.Resource, preemptionDel
}
func (sa *Application) tryRequiredNodePreemption(reserve *reservation, ask *AllocationAsk) bool {
- log.Logger().Info("Triggering preemption process for daemon set ask",
+ log.Log(log.SchedApplication).Info("Triggering preemption process for daemon set ask",
zap.String("ds allocation key", ask.GetAllocationKey()))
// try preemption and see if we can free up resource
@@ -1300,7 +1300,7 @@ func (sa *Application) tryRequiredNodePreemption(reserve *reservation, ask *Allo
// Are there any victims/asks to preempt?
victims := preemptor.GetVictims()
if len(victims) > 0 {
- log.Logger().Info("Found victims for required node preemption",
+ log.Log(log.SchedApplication).Info("Found victims for required node preemption",
zap.String("ds allocation key", ask.GetAllocationKey()),
zap.Int("no.of victims", len(victims)))
for _, victim := range victims {
@@ -1314,7 +1314,7 @@ func (sa *Application) tryRequiredNodePreemption(reserve *reservation, ask *Allo
"preempting allocations to free up resources to run daemon set ask: "+ask.GetAllocationKey())
return true
}
- log.Logger().Warn("Problem in finding the victims for preempting resources to meet required ask requirements",
+ log.Log(log.SchedApplication).Warn("Problem in finding the victims for preempting resources to meet required ask requirements",
zap.String("ds allocation key", ask.GetAllocationKey()),
zap.String("node id", reserve.nodeID))
return false
@@ -1326,11 +1326,11 @@ func (sa *Application) tryNodesNoReserve(ask *AllocationAsk, iterator NodeIterat
for iterator.HasNext() {
node := iterator.Next()
if node == nil {
- log.Logger().Warn("Node iterator failed to return a node")
+ log.Log(log.SchedApplication).Warn("Node iterator failed to return a node")
return nil
}
if !node.IsSchedulable() {
- log.Logger().Debug("skipping node for reserved ask as state is unschedulable",
+ log.Log(log.SchedApplication).Debug("skipping node for reserved ask as state is unschedulable",
zap.String("allocationKey", ask.GetAllocationKey()),
zap.String("node", node.NodeID))
continue
@@ -1363,12 +1363,12 @@ func (sa *Application) tryNodes(ask *AllocationAsk, iterator NodeIterator) *Allo
for iterator.HasNext() {
node := iterator.Next()
if node == nil {
- log.Logger().Warn("Node iterator failed to return a node")
+ log.Log(log.SchedApplication).Warn("Node iterator failed to return a node")
return nil
}
// skip the node if the node is not valid for the ask
if !node.IsSchedulable() {
- log.Logger().Debug("skipping node for ask as state is unschedulable",
+ log.Log(log.SchedApplication).Debug("skipping node for ask as state is unschedulable",
zap.String("allocationKey", allocKey),
zap.String("node", node.NodeID))
continue
@@ -1386,7 +1386,7 @@ func (sa *Application) tryNodes(ask *AllocationAsk, iterator NodeIterator) *Allo
// NOTE: this is a safeguard as reserved nodes should never be part of the iterator
// but we have no locking
if _, ok := sa.reservations[reservationKey(node, nil, ask)]; ok {
- log.Logger().Debug("allocate found reserved ask during non reserved allocate",
+ log.Log(log.SchedApplication).Debug("allocate found reserved ask during non reserved allocate",
zap.String("appID", sa.ApplicationID),
zap.String("nodeID", node.NodeID),
zap.String("allocationKey", allocKey))
@@ -1397,7 +1397,7 @@ func (sa *Application) tryNodes(ask *AllocationAsk, iterator NodeIterator) *Allo
// the reserved nodes to unreserve (first one in the list)
if len(reservedAsks) > 0 {
nodeID := strings.TrimSuffix(reservedAsks[0], "|"+allocKey)
- log.Logger().Debug("allocate picking reserved ask during non reserved allocate",
+ log.Log(log.SchedApplication).Debug("allocate picking reserved ask during non reserved allocate",
zap.String("appID", sa.ApplicationID),
zap.String("nodeID", nodeID),
zap.String("allocationKey", allocKey))
@@ -1412,7 +1412,7 @@ func (sa *Application) tryNodes(ask *AllocationAsk, iterator NodeIterator) *Allo
// TODO make this smarter a hardcoded delay is not the right thing
askAge := time.Since(ask.GetCreateTime())
if allowReserve && askAge > reservationDelay {
- log.Logger().Debug("app reservation check",
+ log.Log(log.SchedApplication).Debug("app reservation check",
zap.String("allocationKey", allocKey),
zap.Time("createTime", ask.GetCreateTime()),
zap.Duration("askAge", askAge),
@@ -1428,7 +1428,7 @@ func (sa *Application) tryNodes(ask *AllocationAsk, iterator NodeIterator) *Allo
// we have not allocated yet, check if we should reserve
// NOTE: the node should not be reserved as the iterator filters them but we do not lock the nodes
if nodeToReserve != nil && !nodeToReserve.IsReserved() {
- log.Logger().Debug("found candidate node for app reservation",
+ log.Log(log.SchedApplication).Debug("found candidate node for app reservation",
zap.String("appID", sa.ApplicationID),
zap.String("nodeID", nodeToReserve.NodeID),
zap.String("allocationKey", allocKey),
@@ -1462,7 +1462,7 @@ func (sa *Application) tryNode(node *Node, ask *AllocationAsk) *Allocation {
alloc := NewAllocation(common.GetNewUUID(), node.NodeID, node.GetInstanceType(), ask)
if node.AddAllocation(alloc) {
if err := sa.queue.IncAllocatedResource(alloc.GetAllocatedResource(), false); err != nil {
- log.Logger().Warn("queue update failed unexpectedly",
+ log.Log(log.SchedApplication).Warn("queue update failed unexpectedly",
zap.Error(err))
// revert the node update
node.RemoveAllocation(alloc.GetUUID())
@@ -1471,7 +1471,7 @@ func (sa *Application) tryNode(node *Node, ask *AllocationAsk) *Allocation {
// mark this ask as allocated by lowering the repeat
_, err := sa.updateAskRepeatInternal(ask, -1)
if err != nil {
- log.Logger().Warn("ask repeat update failed unexpectedly",
+ log.Log(log.SchedApplication).Warn("ask repeat update failed unexpectedly",
zap.Error(err))
}
// all is OK, last update for the app
@@ -1604,7 +1604,7 @@ func (sa *Application) addAllocationInternal(info *Allocation) {
// If there are no more placeholder to allocate we should move state
if resources.Equals(sa.allocatedPlaceholder, sa.placeholderAsk) {
if err := sa.HandleApplicationEvent(RunApplication); err != nil {
- log.Logger().Error("Unexpected app state change failure while adding allocation",
+ log.Log(log.SchedApplication).Error("Unexpected app state change failure while adding allocation",
zap.String("currentState", sa.stateMachine.Current()),
zap.Error(err))
}
@@ -1616,7 +1616,7 @@ func (sa *Application) addAllocationInternal(info *Allocation) {
// progress the state based on where we are, we should never fail in this case
// keep track of a failure in log.
if err := sa.HandleApplicationEvent(RunApplication); err != nil {
- log.Logger().Error("Unexpected app state change failure while adding allocation",
+ log.Log(log.SchedApplication).Error("Unexpected app state change failure while adding allocation",
zap.String("currentState", sa.stateMachine.Current()),
zap.Error(err))
}
@@ -1632,7 +1632,7 @@ func (sa *Application) addAllocationInternal(info *Allocation) {
// No locking must be called while holding the lock
func (sa *Application) incUserResourceUsage(resource *resources.Resource) {
if err := ugm.GetUserManager().IncreaseTrackedResource(sa.queuePath, sa.ApplicationID, resource, sa.user); err != nil {
- log.Logger().Error("Unable to track the user resource usage",
+ log.Log(log.SchedApplication).Error("Unable to track the user resource usage",
zap.String("application id", sa.ApplicationID),
zap.String("user", sa.user.User),
zap.String("currentState", sa.stateMachine.Current()),
@@ -1644,7 +1644,7 @@ func (sa *Application) incUserResourceUsage(resource *resources.Resource) {
// No locking must be called while holding the lock
func (sa *Application) decUserResourceUsage(resource *resources.Resource, removeApp bool) {
if err := ugm.GetUserManager().DecreaseTrackedResource(sa.queuePath, sa.ApplicationID, resource, sa.user, removeApp); err != nil {
- log.Logger().Error("Unable to track the user resource usage",
+ log.Log(log.SchedApplication).Error("Unable to track the user resource usage",
zap.String("application id", sa.ApplicationID),
zap.String("user", sa.user.User),
zap.String("currentState", sa.stateMachine.Current()),
@@ -1666,14 +1666,14 @@ func (sa *Application) ReplaceAllocation(uuid string) *Allocation {
ph := sa.removeAllocationInternal(uuid, si.TerminationType_PLACEHOLDER_REPLACED)
// this has already been replaced or it is a duplicate message from the shim
if ph == nil || ph.GetReleaseCount() == 0 {
- log.Logger().Debug("Unexpected placeholder released",
+ log.Log(log.SchedApplication).Debug("Unexpected placeholder released",
zap.String("applicationID", sa.ApplicationID),
zap.Stringer("placeholder", ph))
return nil
}
// weird issue we should never have more than 1 log it for debugging this error
if ph.GetReleaseCount() > 1 {
- log.Logger().Error("Unexpected release number, placeholder released, only 1 real allocations processed",
+ log.Log(log.SchedApplication).Error("Unexpected release number, placeholder released, only 1 real allocations processed",
zap.String("applicationID", sa.ApplicationID),
zap.String("placeholderID", uuid),
zap.Int("releases", ph.GetReleaseCount()))
@@ -1763,7 +1763,7 @@ func (sa *Application) removeAllocationInternal(uuid string, releaseType si.Term
}
if event != EventNotNeeded {
if err := sa.HandleApplicationEvent(event); err != nil {
- log.Logger().Warn(eventWarning,
+ log.Log(log.SchedApplication).Warn(eventWarning,
zap.String("currentState", sa.CurrentState()),
zap.Stringer("event", event),
zap.Error(err))
@@ -1815,7 +1815,7 @@ func (sa *Application) RemoveAllAllocations() []*Allocation {
// When the resource trackers are zero we should not expect anything to come in later.
if resources.IsZero(sa.pending) {
if err := sa.HandleApplicationEvent(CompleteApplication); err != nil {
- log.Logger().Warn("Application state not changed to Waiting while removing all allocations",
+ log.Log(log.SchedApplication).Warn("Application state not changed to Waiting while removing all allocations",
zap.String("currentState", sa.CurrentState()),
zap.Error(err))
}
@@ -1905,9 +1905,9 @@ func (sa *Application) notifyRMAllocationReleased(rmID string, released []*Alloc
// Wait from channel
result := <-c
if result.Succeeded {
- log.Logger().Debug("Successfully synced shim on released allocations. response: " + result.Reason)
+ log.Log(log.SchedApplication).Debug("Successfully synced shim on released allocations. response: " + result.Reason)
} else {
- log.Logger().Info("failed to sync shim on released allocations")
+ log.Log(log.SchedApplication).Info("failed to sync shim on released allocations")
}
}
diff --git a/pkg/scheduler/objects/application_state.go b/pkg/scheduler/objects/application_state.go
index 75c2e37a..f2f7151b 100644
--- a/pkg/scheduler/objects/application_state.go
+++ b/pkg/scheduler/objects/application_state.go
@@ -130,7 +130,7 @@ func NewAppState() *fsm.FSM {
// will occur.
"enter_state": func(_ context.Context, event *fsm.Event) {
app := event.Args[0].(*Application) //nolint:errcheck
- log.Logger().Info("Application state transition",
+ log.Log(log.SchedFSM).Info("Application state transition",
zap.String("appID", app.ApplicationID),
zap.String("source", event.Src),
zap.String("destination", event.Dst),
diff --git a/pkg/scheduler/objects/node.go b/pkg/scheduler/objects/node.go
index 6e57ec1e..07c00b3f 100644
--- a/pkg/scheduler/objects/node.go
+++ b/pkg/scheduler/objects/node.go
@@ -70,7 +70,7 @@ func NewNode(proto *si.NodeInfo) *Node {
var ready bool
var err error
if ready, err = strconv.ParseBool(proto.Attributes[common.NodeReadyAttribute]); err != nil {
- log.Logger().Debug("Could not parse ready flag, assuming true",
+ log.Log(log.SchedNode).Debug("Could not parse ready flag, assuming true",
zap.String("nodeID", proto.NodeID))
ready = true
}
@@ -88,7 +88,7 @@ func NewNode(proto *si.NodeInfo) *Node {
// initialise available resources
sn.availableResource, err = resources.SubErrorNegative(sn.totalResource, sn.occupiedResource)
if err != nil {
- log.Logger().Error("New node created with no available resources",
+ log.Log(log.SchedNode).Error("New node created with no available resources",
zap.Error(err))
}
@@ -160,7 +160,7 @@ func (sn *Node) SetCapacity(newCapacity *resources.Resource) *resources.Resource
sn.Lock()
defer sn.Unlock()
if resources.Equals(sn.totalResource, newCapacity) {
- log.Logger().Debug("skip updating capacity, not changed")
+ log.Log(log.SchedNode).Debug("skip updating capacity, not changed")
return nil
}
delta := resources.Sub(newCapacity, sn.totalResource)
@@ -180,7 +180,7 @@ func (sn *Node) SetOccupiedResource(occupiedResource *resources.Resource) {
sn.Lock()
defer sn.Unlock()
if resources.Equals(sn.occupiedResource, occupiedResource) {
- log.Logger().Debug("skip updating occupiedResource, not changed")
+ log.Log(log.SchedNode).Debug("skip updating occupiedResource, not changed")
return
}
sn.occupiedResource = occupiedResource
@@ -195,7 +195,7 @@ func (sn *Node) refreshAvailableResource() {
sn.availableResource.SubFrom(sn.occupiedResource)
// check if any quantity is negative: a nil resource is all 0's
if !resources.StrictlyGreaterThanOrEquals(sn.availableResource, nil) {
- log.Logger().Warn("Node update triggered over allocated node",
+ log.Log(log.SchedNode).Warn("Node update triggered over allocated node",
zap.Stringer("available", sn.availableResource),
zap.Stringer("total", sn.totalResource),
zap.Stringer("occupied", sn.occupiedResource),
@@ -342,7 +342,7 @@ func (sn *Node) ReplaceAllocation(uuid string, replace *Allocation, delta *resou
sn.allocatedResource.AddTo(delta)
sn.availableResource.SubFrom(delta)
if !resources.FitIn(before, sn.allocatedResource) {
- log.Logger().Warn("unexpected increase in node usage after placeholder replacement",
+ log.Log(log.SchedNode).Warn("unexpected increase in node usage after placeholder replacement",
zap.String("placeholder uuid", uuid),
zap.String("allocation uuid", replace.GetUUID()),
zap.Stringer("delta", delta))
@@ -383,7 +383,7 @@ func (sn *Node) preConditions(ask *AllocationAsk, allocate bool) bool {
NodeID: sn.NodeID,
Allocate: allocate,
}); err != nil {
- log.Logger().Debug("running predicates failed",
+ log.Log(log.SchedNode).Debug("running predicates failed",
zap.String("allocationKey", allocID),
zap.String("nodeID", sn.NodeID),
zap.Bool("allocateFlag", allocate),
@@ -402,14 +402,14 @@ func (sn *Node) preConditions(ask *AllocationAsk, allocate bool) bool {
func (sn *Node) preAllocateCheck(res *resources.Resource, resKey string) bool {
// cannot allocate zero or negative resource
if !resources.StrictlyGreaterThanZero(res) {
- log.Logger().Debug("pre alloc check: requested resource is zero",
+ log.Log(log.SchedNode).Debug("pre alloc check: requested resource is zero",
zap.String("nodeID", sn.NodeID))
return false
}
// check if the node is reserved for this app/alloc
if sn.IsReserved() {
if !sn.isReservedForApp(resKey) {
- log.Logger().Debug("pre alloc check: node reserved for different app or ask",
+ log.Log(log.SchedNode).Debug("pre alloc check: node reserved for different app or ask",
zap.String("nodeID", sn.NodeID),
zap.String("resKey", resKey))
return false
@@ -464,7 +464,7 @@ func (sn *Node) Reserve(app *Application, ask *AllocationAsk) error {
// this should really not happen just guard against panic
// either app or ask are nil
if appReservation == nil {
- log.Logger().Debug("reservation creation failed unexpectedly",
+ log.Log(log.SchedNode).Debug("reservation creation failed unexpectedly",
zap.String("nodeID", sn.NodeID),
zap.Any("app", app),
zap.Any("ask", ask))
@@ -472,7 +472,7 @@ func (sn *Node) Reserve(app *Application, ask *AllocationAsk) error {
}
// reservation must fit on the empty node
if !resources.FitIn(sn.totalResource, ask.GetAllocatedResource()) {
- log.Logger().Debug("reservation does not fit on the node",
+ log.Log(log.SchedNode).Debug("reservation does not fit on the node",
zap.String("nodeID", sn.NodeID),
zap.String("appID", app.ApplicationID),
zap.String("ask", ask.GetAllocationKey()),
@@ -493,7 +493,7 @@ func (sn *Node) unReserve(app *Application, ask *AllocationAsk) (int, error) {
defer sn.Unlock()
resKey := reservationKey(nil, app, ask)
if resKey == "" {
- log.Logger().Debug("unreserve reservation key create failed unexpectedly",
+ log.Log(log.SchedNode).Debug("unreserve reservation key create failed unexpectedly",
zap.String("nodeID", sn.NodeID),
zap.Any("app", app),
zap.Any("ask", ask))
@@ -504,7 +504,7 @@ func (sn *Node) unReserve(app *Application, ask *AllocationAsk) (int, error) {
return 1, nil
}
// reservation was not found
- log.Logger().Debug("reservation not found while removing from node",
+ log.Log(log.SchedNode).Debug("reservation not found while removing from node",
zap.String("nodeID", sn.NodeID),
zap.String("appID", app.ApplicationID),
zap.String("ask", ask.GetAllocationKey()))
diff --git a/pkg/scheduler/objects/node_collection.go b/pkg/scheduler/objects/node_collection.go
index 646c81e5..9c056bd5 100644
--- a/pkg/scheduler/objects/node_collection.go
+++ b/pkg/scheduler/objects/node_collection.go
@@ -108,7 +108,7 @@ func (nc *baseNodeCollection) RemoveNode(nodeID string) *Node {
defer nc.Unlock()
nref := nc.nodes[nodeID]
if nref == nil {
- log.Logger().Debug("node was not found, node already removed",
+ log.Log(log.SchedNode).Debug("node was not found, node already removed",
zap.String("nodeID", nodeID),
zap.String("partition", nc.Partition))
return nil
diff --git a/pkg/scheduler/objects/nodesorting.go b/pkg/scheduler/objects/nodesorting.go
index e7292e7b..e8674b87 100644
--- a/pkg/scheduler/objects/nodesorting.go
+++ b/pkg/scheduler/objects/nodesorting.go
@@ -113,7 +113,7 @@ func defaultResourceWeights() map[string]float64 {
func NewNodeSortingPolicy(policyType string, resourceWeights map[string]float64) NodeSortingPolicy {
pType, err := policies.SortingPolicyFromString(policyType)
if err != nil {
- log.Logger().Debug("node sorting policy defaulted to 'undefined'",
+ log.Log(log.SchedNode).Debug("node sorting policy defaulted to 'undefined'",
zap.Error(err))
}
weights := resourceWeights
@@ -137,7 +137,7 @@ func NewNodeSortingPolicy(policyType string, resourceWeights map[string]float64)
}
}
- log.Logger().Debug("new node sorting policy added",
+ log.Log(log.SchedNode).Debug("new node sorting policy added",
zap.Stringer("type", pType), zap.Any("resourceWeights", weights))
return sp
}
diff --git a/pkg/scheduler/objects/object_state.go b/pkg/scheduler/objects/object_state.go
index f4197d73..7c8a678b 100644
--- a/pkg/scheduler/objects/object_state.go
+++ b/pkg/scheduler/objects/object_state.go
@@ -78,7 +78,7 @@ func NewObjectState() *fsm.FSM {
},
fsm.Callbacks{
"enter_state": func(_ context.Context, event *fsm.Event) {
- log.Logger().Info("object transition",
+ log.Log(log.SchedFSM).Info("object transition",
zap.Any("object", event.Args[0]),
zap.String("source", event.Src),
zap.String("destination", event.Dst),
diff --git a/pkg/scheduler/objects/preemption.go b/pkg/scheduler/objects/preemption.go
index 41c114da..09f340a7 100644
--- a/pkg/scheduler/objects/preemption.go
+++ b/pkg/scheduler/objects/preemption.go
@@ -190,7 +190,7 @@ func (p *Preemptor) checkPreemptionQueueGuarantees() bool {
queues := p.duplicateQueueSnapshots()
currentQueue, ok := queues[p.queuePath]
if !ok {
- log.Logger().Warn("BUG: Didn't find current queue in snapshot list",
+ log.Log(log.SchedPreemption).Warn("BUG: Didn't find current queue in snapshot list",
zap.String("queuePath", p.queuePath))
return false
}
@@ -227,7 +227,7 @@ func (p *Preemptor) calculateVictimsByNode(nodeAvailable *resources.Resource, po
// get the current queue snapshot
askQueue, ok := allocationsByQueueSnap[p.queuePath]
if !ok {
- log.Logger().Warn("BUG: Queue not found by name", zap.String("queuePath", p.queuePath))
+ log.Log(log.SchedPreemption).Warn("BUG: Queue not found by name", zap.String("queuePath", p.queuePath))
return -1, nil
}
@@ -281,7 +281,7 @@ func (p *Preemptor) calculateVictimsByNode(nodeAvailable *resources.Resource, po
// get the current queue snapshot
askQueue, ok2 := allocationsByQueueSnap[p.queuePath]
if !ok2 {
- log.Logger().Warn("BUG: Queue not found by name", zap.String("queuePath", p.queuePath))
+ log.Log(log.SchedPreemption).Warn("BUG: Queue not found by name", zap.String("queuePath", p.queuePath))
return -1, nil
}
@@ -353,7 +353,7 @@ func (p *Preemptor) checkPreemptionPredicates(predicateChecks []*si.PreemptionPr
if plugin == nil {
// if a plugin isn't registered, assume checks will succeed and synthesize a result
check := predicateChecks[0]
- log.Logger().Debug("No RM callback plugin registered, using first selected node for preemption",
+ log.Log(log.SchedPreemption).Debug("No RM callback plugin registered, using first selected node for preemption",
zap.String("NodeID", check.NodeID),
zap.String("AllocationKey", check.AllocationKey))
@@ -412,7 +412,7 @@ func (p *Preemptor) calculateAdditionalVictims(nodeVictims []*Allocation) ([]*Al
// get the current queue snapshot
askQueue, ok := allocationsByQueueSnap[p.queuePath]
if !ok {
- log.Logger().Warn("BUG: Queue not found by name", zap.String("queuePath", p.queuePath))
+ log.Log(log.SchedPreemption).Warn("BUG: Queue not found by name", zap.String("queuePath", p.queuePath))
return nil, false
}
@@ -518,7 +518,7 @@ func (p *Preemptor) tryNodes() (string, string, []*Allocation, bool) {
instType, ok := p.nodeInstanceTypeMap[result.nodeID]
if !ok {
// If the key doesn't exist, log error and use UnknownInstanceType
- log.Logger().Error("BUG: Didn't find instance type in the nodeInstanceTypeMap",
+ log.Log(log.SchedPreemption).Error("BUG: Didn't find instance type in the nodeInstanceTypeMap",
zap.String("nodeId", result.nodeID))
instType = UnknownInstanceType
}
@@ -560,13 +560,13 @@ func (p *Preemptor) TryPreemption() (*Allocation, bool) {
if victimQueue := p.queue.FindQueueByAppID(victim.GetApplicationID()); victimQueue != nil {
victimQueue.IncPreemptingResource(victim.GetAllocatedResource())
victim.MarkPreempted()
- log.Logger().Info("Preempting task",
+ log.Log(log.SchedPreemption).Info("Preempting task",
zap.String("applicationID", victim.GetApplicationID()),
zap.String("allocationKey", victim.GetAllocationKey()),
zap.String("nodeID", victim.GetNodeID()),
zap.Stringer("resources", victim.GetAllocatedResource()))
} else {
- log.Logger().Warn("BUG: Queue not found for preemption victim",
+ log.Log(log.SchedPreemption).Warn("BUG: Queue not found for preemption victim",
zap.String("applicationID", victim.GetApplicationID()),
zap.String("allocationKey", victim.GetAllocationKey()))
}
@@ -581,7 +581,7 @@ func (p *Preemptor) TryPreemption() (*Allocation, bool) {
// reserve the selected node for the new allocation if it will fit
if p.headRoom.FitInMaxUndef(p.ask.GetAllocatedResource()) {
- log.Logger().Info("Reserving node for ask after preemption",
+ log.Log(log.SchedPreemption).Info("Reserving node for ask after preemption",
zap.String("allocationKey", p.ask.GetAllocationKey()),
zap.String("nodeID", nodeID),
zap.Int("victimCount", len(victims)))
@@ -589,7 +589,7 @@ func (p *Preemptor) TryPreemption() (*Allocation, bool) {
}
// can't reserve as queue is still too full, but scheduling should succeed after preemption occurs
- log.Logger().Info("Preempting allocations for ask, but not reserving yet as queue is still above capacity",
+ log.Log(log.SchedPreemption).Info("Preempting allocations for ask, but not reserving yet as queue is still above capacity",
zap.String("allocationKey", p.ask.GetAllocationKey()),
zap.Int("victimCount", len(victims)))
@@ -655,7 +655,7 @@ func (pcr *predicateCheckResult) populateVictims(victimsByNode map[string][]*All
// abort if node was not found
victimList, ok := victimsByNode[pcr.nodeID]
if !ok {
- log.Logger().Warn("BUG: Unable to find node in victim map", zap.String("nodeID", pcr.nodeID))
+ log.Log(log.SchedPreemption).Warn("BUG: Unable to find node in victim map", zap.String("nodeID", pcr.nodeID))
pcr.success = false
pcr.index = -1
return
@@ -663,7 +663,7 @@ func (pcr *predicateCheckResult) populateVictims(victimsByNode map[string][]*All
// abort if index is too large
if pcr.index >= len(victimList) {
- log.Logger().Warn("BUG: Got invalid index into allocation list",
+ log.Log(log.SchedPreemption).Warn("BUG: Got invalid index into allocation list",
zap.String("nodeID", pcr.nodeID),
zap.Int("index", pcr.index),
zap.Int("length", len(victimList)))
diff --git a/pkg/scheduler/objects/queue.go b/pkg/scheduler/objects/queue.go
index 434558bc..25dedca4 100644
--- a/pkg/scheduler/objects/queue.go
+++ b/pkg/scheduler/objects/queue.go
@@ -136,7 +136,7 @@ func NewConfiguredQueue(conf configs.QueueConfig, parent *Queue) (*Queue, error)
}
sq.UpdateQueueProperties()
- log.Logger().Info("configured queue added to scheduler",
+ log.Log(log.SchedQueue).Info("configured queue added to scheduler",
zap.String("queueName", sq.QueuePath))
return sq, nil
@@ -169,7 +169,7 @@ func NewDynamicQueue(name string, leaf bool, parent *Queue) (*Queue, error) {
}
sq.UpdateQueueProperties()
- log.Logger().Info("dynamic queue added to scheduler",
+ log.Log(log.SchedQueue).Info("dynamic queue added to scheduler",
zap.String("queueName", sq.QueuePath))
return sq, nil
@@ -279,19 +279,19 @@ func (sq *Queue) applyConf(conf configs.QueueConfig) error {
var err error
sq.submitACL, err = security.NewACL(conf.SubmitACL)
if err != nil {
- log.Logger().Error("parsing submit ACL failed this should not happen",
+ log.Log(log.SchedQueue).Error("parsing submit ACL failed this should not happen",
zap.Error(err))
return err
}
sq.adminACL, err = security.NewACL(conf.AdminACL)
if err != nil {
- log.Logger().Error("parsing admin ACL failed this should not happen",
+ log.Log(log.SchedQueue).Error("parsing admin ACL failed this should not happen",
zap.Error(err))
return err
}
// Change from unmanaged to managed
if !sq.isManaged {
- log.Logger().Info("changed dynamic queue to managed",
+ log.Log(log.SchedQueue).Info("changed dynamic queue to managed",
zap.String("queue", sq.QueuePath))
sq.isManaged = true
}
@@ -323,7 +323,7 @@ func (sq *Queue) applyConf(conf configs.QueueConfig) error {
func (sq *Queue) setResources(resource configs.Resources) error {
maxResource, err := resources.NewResourceFromConf(resource.Max)
if err != nil {
- log.Logger().Error("parsing failed on max resources this should not happen",
+ log.Log(log.SchedQueue).Error("parsing failed on max resources this should not happen",
zap.Error(err))
return err
}
@@ -331,7 +331,7 @@ func (sq *Queue) setResources(resource configs.Resources) error {
var guaranteedResource *resources.Resource
guaranteedResource, err = resources.NewResourceFromConf(resource.Guaranteed)
if err != nil {
- log.Logger().Error("parsing failed on guaranteed resources this should not happen",
+ log.Log(log.SchedQueue).Error("parsing failed on guaranteed resources this should not happen",
zap.Error(err))
return err
}
@@ -340,14 +340,14 @@ func (sq *Queue) setResources(resource configs.Resources) error {
sq.maxResource = maxResource
sq.updateMaxResourceMetrics()
} else {
- log.Logger().Debug("max resources setting ignored: cannot set zero max resources")
+ log.Log(log.SchedQueue).Debug("max resources setting ignored: cannot set zero max resources")
}
if resources.StrictlyGreaterThanZero(guaranteedResource) {
sq.guaranteedResource = guaranteedResource
sq.updateGuaranteedResourceMetrics()
} else {
- log.Logger().Debug("guaranteed resources setting ignored: cannot set zero max resources")
+ log.Log(log.SchedQueue).Debug("guaranteed resources setting ignored: cannot set zero max resources")
}
return nil
@@ -382,7 +382,7 @@ func (sq *Queue) UpdateQueueProperties() {
if sq.isLeaf {
sq.sortType, err = policies.SortPolicyFromString(value)
if err != nil {
- log.Logger().Debug("application sort property configuration error",
+ log.Log(log.SchedQueue).Debug("application sort property configuration error",
zap.Error(err))
}
// if it is not defined default to fifo
@@ -393,38 +393,38 @@ func (sq *Queue) UpdateQueueProperties() {
case configs.ApplicationSortPriority:
sq.prioritySortEnabled, err = applicationSortPriorityEnabled(value)
if err != nil {
- log.Logger().Debug("queue application sort priority configuration error",
+ log.Log(log.SchedQueue).Debug("queue application sort priority configuration error",
zap.Error(err))
}
case configs.PriorityOffset:
sq.priorityOffset, err = priorityOffset(value)
if err != nil {
- log.Logger().Debug("queue priority offset configuration error",
+ log.Log(log.SchedQueue).Debug("queue priority offset configuration error",
zap.Error(err))
}
case configs.PriorityPolicy:
sq.priorityPolicy, err = policies.PriorityPolicyFromString(value)
if err != nil {
- log.Logger().Debug("queue priority policy configuration error",
+ log.Log(log.SchedQueue).Debug("queue priority policy configuration error",
zap.Error(err))
}
case configs.PreemptionPolicy:
sq.preemptionPolicy, err = policies.PreemptionPolicyFromString(value)
if err != nil {
- log.Logger().Debug("queue preemption policy configuration error",
+ log.Log(log.SchedQueue).Debug("queue preemption policy configuration error",
zap.Error(err))
}
case configs.PreemptionDelay:
if sq.isLeaf {
sq.preemptionDelay, err = preemptionDelay(value)
if err != nil {
- log.Logger().Debug("preemption delay property configuration error",
+ log.Log(log.SchedQueue).Debug("preemption delay property configuration error",
zap.Error(err))
}
}
default:
// skip unknown properties just log them
- log.Logger().Debug("queue property skipped",
+ log.Log(log.SchedQueue).Debug("queue property skipped",
zap.String("key", key),
zap.String("value", value))
}
@@ -646,7 +646,7 @@ func (sq *Queue) decPendingResource(delta *resources.Resource) {
var err error
sq.pending, err = resources.SubErrorNegative(sq.pending, delta)
if err != nil {
- log.Logger().Warn("Pending resources went negative",
+ log.Log(log.SchedQueue).Warn("Pending resources went negative",
zap.String("queueName", sq.QueuePath),
zap.Error(err))
}
@@ -669,19 +669,19 @@ func (sq *Queue) AddApplication(app *Application) {
// need to set a quota: convert json string to resource
res, err := resources.NewResourceFromString(quota)
if err != nil {
- log.Logger().Warn("application resource quota conversion failure",
+ log.Log(log.SchedQueue).Warn("application resource quota conversion failure",
zap.String("json quota string", quota),
zap.Error(err))
return
}
if !resources.StrictlyGreaterThanZero(res) {
- log.Logger().Warn("application resource quota has at least one 0 value: cannot set queue limit",
+ log.Log(log.SchedQueue).Warn("application resource quota has at least one 0 value: cannot set queue limit",
zap.Stringer("maxResource", res))
return
}
// set the quota
if sq.isManaged {
- log.Logger().Warn("Trying to set max resources set on a queue that is not an unmanaged leaf",
+ log.Log(log.SchedQueue).Warn("Trying to set max resources set on a queue that is not an unmanaged leaf",
zap.String("queueName", sq.QueuePath))
return
}
@@ -695,7 +695,7 @@ func (sq *Queue) RemoveApplication(app *Application) {
// clean up any outstanding pending resources
appID := app.ApplicationID
if !sq.appExists(appID) {
- log.Logger().Debug("Application not found while removing from queue",
+ log.Log(log.SchedQueue).Debug("Application not found while removing from queue",
zap.String("queueName", sq.QueuePath),
zap.String("applicationID", appID))
return
@@ -706,7 +706,7 @@ func (sq *Queue) RemoveApplication(app *Application) {
// clean up the allocated resource
if appAllocated := app.GetAllocatedResource(); !resources.IsZero(appAllocated) {
if err := sq.DecAllocatedResource(appAllocated); err != nil {
- log.Logger().Warn("failed to release allocated resources from queue",
+ log.Log(log.SchedQueue).Warn("failed to release allocated resources from queue",
zap.String("appID", appID),
zap.Error(err))
}
@@ -714,7 +714,7 @@ func (sq *Queue) RemoveApplication(app *Application) {
// clean up the allocated placeholder resource
if phAllocated := app.GetPlaceholderResource(); !resources.IsZero(phAllocated) {
if err := sq.DecAllocatedResource(phAllocated); err != nil {
- log.Logger().Warn("failed to release placeholder resources from queue",
+ log.Log(log.SchedQueue).Warn("failed to release placeholder resources from queue",
zap.String("appID", appID),
zap.Error(err))
}
@@ -739,7 +739,7 @@ func (sq *Queue) RemoveApplication(app *Application) {
sq.parent.UpdateQueuePriority(sq.Name, priority)
- log.Logger().Info("Application completed and removed from queue",
+ log.Log(log.SchedQueue).Info("Application completed and removed from queue",
zap.String("queueName", sq.QueuePath),
zap.String("applicationID", appID))
}
@@ -828,7 +828,7 @@ func (sq *Queue) addChildQueue(child *Queue) error {
// 1) try to use template if it is not nil
// 2) otherwise, child leaf copy the configs.ApplicationSortPolicy from parent (old behavior)
if sq.template != nil {
- log.Logger().Debug("applying child template to new leaf queue",
+ log.Log(log.SchedQueue).Debug("applying child template to new leaf queue",
zap.String("child queue", child.QueuePath),
zap.String("parent queue", sq.QueuePath),
zap.Any("template", sq.template))
@@ -836,7 +836,7 @@ func (sq *Queue) addChildQueue(child *Queue) error {
} else {
policyValue, ok := sq.properties[configs.ApplicationSortPolicy]
if ok {
- log.Logger().Warn("inheriting application sort policy is deprecated, use child templates",
+ log.Log(log.Deprecation).Warn("inheriting application sort policy is deprecated, use child templates",
zap.String("child queue", child.QueuePath),
zap.String("parent queue", sq.QueuePath))
child.properties[configs.ApplicationSortPolicy] = policyValue
@@ -847,7 +847,7 @@ func (sq *Queue) addChildQueue(child *Queue) error {
// don't override the template of non-leaf queue
if child.template == nil {
child.template = sq.template
- log.Logger().Debug("new parent queue inheriting template from parent queue",
+ log.Log(log.SchedQueue).Debug("new parent queue inheriting template from parent queue",
zap.String("child queue", child.QueuePath),
zap.String("parent queue", sq.QueuePath))
}
@@ -864,10 +864,10 @@ func (sq *Queue) MarkQueueForRemoval() {
// Mark the managed queue for deletion: it is removed from the config let it drain.
// Also mark all the managed children for deletion.
if sq.isManaged {
- log.Logger().Info("marking managed queue for deletion",
+ log.Log(log.SchedQueue).Info("marking managed queue for deletion",
zap.String("queue", sq.QueuePath))
if err := sq.handleQueueEvent(Remove); err != nil {
- log.Logger().Warn("failed to mark managed queue for deletion",
+ log.Log(log.SchedQueue).Warn("failed to mark managed queue for deletion",
zap.String("queue", sq.QueuePath),
zap.Error(err))
}
@@ -902,7 +902,7 @@ func (sq *Queue) RemoveQueue() bool {
if len(sq.children) > 0 || len(sq.applications) > 0 {
return false
}
- log.Logger().Info("removing queue", zap.String("queue", sq.QueuePath))
+ log.Log(log.SchedQueue).Info("removing queue", zap.String("queue", sq.QueuePath))
// root is always managed and is the only queue with a nil parent: no need to guard
sq.parent.removeChildQueue(sq.Name)
return true
@@ -947,7 +947,7 @@ func (sq *Queue) IncAllocatedResource(alloc *resources.Resource, nodeReported bo
// only log the warning if we get to the leaf: otherwise we could spam the log with the same message
// each time we return from a recursive call. Worst case (hierarchy depth-1) times.
if sq.isLeaf {
- log.Logger().Warn("parent queue exceeds maximum resource",
+ log.Log(log.SchedQueue).Warn("parent queue exceeds maximum resource",
zap.String("leafQueue", sq.QueuePath),
zap.Stringer("allocationRequest", alloc),
zap.Stringer("queueUsage", sq.allocatedResource),
@@ -983,7 +983,7 @@ func (sq *Queue) DecAllocatedResource(alloc *resources.Resource) error {
// only log the warning if we get to the leaf: otherwise we spam the log with the same message
// each time we return from a recursive call. Worst case (hierarchy depth-1) times.
if sq.isLeaf {
- log.Logger().Warn("released allocation is larger than parent queue allocated resource",
+ log.Log(log.SchedQueue).Warn("released allocation is larger than parent queue allocated resource",
zap.String("leafQueue", sq.QueuePath),
zap.Stringer("allocationRequest", alloc),
zap.Stringer("queueUsage", sq.allocatedResource),
@@ -1183,11 +1183,11 @@ func (sq *Queue) SetMaxResource(max *resources.Resource) {
defer sq.Unlock()
if sq.parent != nil {
- log.Logger().Warn("Max resources set on a queue that is not the root",
+ log.Log(log.SchedQueue).Warn("Max resources set on a queue that is not the root",
zap.String("queueName", sq.QueuePath))
return
}
- log.Logger().Info("updating root queue max resources",
+ log.Log(log.SchedQueue).Info("updating root queue max resources",
zap.Stringer("current max", sq.maxResource),
zap.Stringer("new max", max))
sq.maxResource = max.Clone()
@@ -1236,7 +1236,7 @@ func (sq *Queue) TryAllocate(iterator func() NodeIterator, fullIterator func() N
}
alloc := app.tryAllocate(headRoom, preemptionDelay, &preemptAttemptsRemaining, iterator, fullIterator, getnode)
if alloc != nil {
- log.Logger().Debug("allocation found on queue",
+ log.Log(log.SchedQueue).Debug("allocation found on queue",
zap.String("queueName", sq.QueuePath),
zap.String("appID", app.ApplicationID),
zap.Stringer("allocation", alloc))
@@ -1272,7 +1272,7 @@ func (sq *Queue) TryPlaceholderAllocate(iterator func() NodeIterator, getnode fu
for _, app := range sq.sortApplications(true) {
alloc := app.tryPlaceholderAllocate(iterator, getnode)
if alloc != nil {
- log.Logger().Debug("allocation found on queue",
+ log.Log(log.SchedQueue).Debug("allocation found on queue",
zap.String("queueName", sq.QueuePath),
zap.String("appID", app.ApplicationID),
zap.Stringer("allocation", alloc))
@@ -1325,13 +1325,13 @@ func (sq *Queue) TryReservedAllocate(iterator func() NodeIterator) *Allocation {
// process the apps
for appID, numRes := range reservedCopy {
if numRes > 1 {
- log.Logger().Debug("multiple reservations found for application trying to allocate one",
+ log.Log(log.SchedQueue).Debug("multiple reservations found for application trying to allocate one",
zap.String("appID", appID),
zap.Int("reservations", numRes))
}
app := sq.GetApplication(appID)
if app == nil {
- log.Logger().Debug("reservation(s) found but application did not exist in queue",
+ log.Log(log.SchedQueue).Debug("reservation(s) found but application did not exist in queue",
zap.String("queueName", sq.QueuePath),
zap.String("appID", appID))
return nil
@@ -1341,7 +1341,7 @@ func (sq *Queue) TryReservedAllocate(iterator func() NodeIterator) *Allocation {
}
alloc := app.tryReservedAllocate(headRoom, iterator)
if alloc != nil {
- log.Logger().Debug("reservation found for allocation found on queue",
+ log.Log(log.SchedQueue).Debug("reservation found for allocation found on queue",
zap.String("queueName", sq.QueuePath),
zap.String("appID", appID),
zap.Stringer("allocation", alloc),
@@ -1516,7 +1516,7 @@ func (sq *Queue) incRunningApps(appID string) {
sq.runningApps++
// sanity check
if sq.maxRunningApps > 0 && sq.runningApps > sq.maxRunningApps {
- log.Logger().Debug("queue running apps went over maximum",
+ log.Log(log.SchedQueue).Debug("queue running apps went over maximum",
zap.String("queueName", sq.QueuePath))
sq.runningApps = sq.maxRunningApps
}
@@ -1538,7 +1538,7 @@ func (sq *Queue) decRunningApps() {
if sq.runningApps > 0 {
sq.runningApps--
} else {
- log.Logger().Debug("queue running apps went negative",
+ log.Log(log.SchedQueue).Debug("queue running apps went negative",
zap.String("queueName", sq.QueuePath))
}
}
@@ -1596,7 +1596,7 @@ func (sq *Queue) FindEligiblePreemptionVictims(queuePath string, ask *Allocation
queuePriority, ok := priorityMap[fence.QueuePath]
if !ok {
// this shouldn't happen
- log.Logger().Error("BUG: No computed priority found for queue", zap.String("queue", fence.QueuePath))
+ log.Log(log.SchedQueue).Error("BUG: No computed priority found for queue", zap.String("queue", fence.QueuePath))
return nil
}
@@ -1777,7 +1777,7 @@ func (sq *Queue) updateApplicationPriorityInternal(applicationID string, priorit
defer sq.Unlock()
if _, ok := sq.applications[applicationID]; !ok {
- log.Logger().Debug("Unknown application", zap.String("applicationID", applicationID))
+ log.Log(log.SchedQueue).Debug("Unknown application", zap.String("applicationID", applicationID))
return sq.currentPriority
}
@@ -1798,7 +1798,7 @@ func (sq *Queue) updateQueuePriorityInternal(queueName string, priority int32) i
defer sq.Unlock()
if _, ok := sq.children[queueName]; !ok {
- log.Logger().Debug("Unknown queue", zap.String("queueName", queueName))
+ log.Log(log.SchedQueue).Debug("Unknown queue", zap.String("queueName", queueName))
return sq.currentPriority
}
diff --git a/pkg/scheduler/objects/reservation.go b/pkg/scheduler/objects/reservation.go
index f96b7ae9..b5f26c8d 100644
--- a/pkg/scheduler/objects/reservation.go
+++ b/pkg/scheduler/objects/reservation.go
@@ -40,7 +40,7 @@ type reservation struct {
// appBased must be true for a reservation for an app and false for a reservation on a node
func newReservation(node *Node, app *Application, ask *AllocationAsk, appBased bool) *reservation {
if ask == nil || app == nil || node == nil {
- log.Logger().Warn("Illegal reservation requested: one input is nil",
+ log.Log(log.SchedReservation).Warn("Illegal reservation requested: one input is nil",
zap.Stringer("node", node),
zap.Stringer("app", app),
zap.Stringer("ask", ask))
@@ -62,7 +62,7 @@ func newReservation(node *Node, app *Application, ask *AllocationAsk, appBased b
func reservationKey(node *Node, app *Application, ask *AllocationAsk) string {
if ask == nil || (app == nil && node == nil) || (app != nil && node != nil) {
- log.Logger().Warn("Illegal reservation key requested",
+ log.Log(log.SchedReservation).Warn("Illegal reservation key requested",
zap.Any("node", node),
zap.Any("app", app),
zap.Any("ask", ask))
diff --git a/pkg/scheduler/partition.go b/pkg/scheduler/partition.go
index 78f4ae88..4c50ce6b 100644
--- a/pkg/scheduler/partition.go
+++ b/pkg/scheduler/partition.go
@@ -77,7 +77,7 @@ type PartitionContext struct {
func newPartitionContext(conf configs.PartitionConfig, rmID string, cc *ClusterContext) (*PartitionContext, error) {
if conf.Name == "" || rmID == "" {
- log.Logger().Info("partition cannot be created",
+ log.Log(log.SchedPartition).Info("partition cannot be created",
zap.String("partition name", conf.Name),
zap.String("rmID", rmID),
zap.Any("cluster context", cc))
@@ -117,7 +117,7 @@ func (pc *PartitionContext) initialPartitionFromConfig(conf configs.PartitionCon
if err = pc.addQueue(queueConf.Queues, pc.root); err != nil {
return err
}
- log.Logger().Info("root queue added",
+ log.Log(log.SchedPartition).Info("root queue added",
zap.String("partitionName", pc.Name),
zap.String("rmID", pc.RmID))
@@ -139,11 +139,11 @@ func (pc *PartitionContext) updateNodeSortingPolicy(conf configs.PartitionConfig
var configuredPolicy policies.SortingPolicy
configuredPolicy, err := policies.SortingPolicyFromString(conf.NodeSortPolicy.Type)
if err != nil {
- log.Logger().Debug("NodeSorting policy incorrectly set or unknown",
+ log.Log(log.SchedPartition).Debug("NodeSorting policy incorrectly set or unknown",
zap.Error(err))
- log.Logger().Info(fmt.Sprintf("NodeSorting policy not set using '%s' as default", configuredPolicy))
+ log.Log(log.SchedPartition).Info(fmt.Sprintf("NodeSorting policy not set using '%s' as default", configuredPolicy))
} else {
- log.Logger().Info("NodeSorting policy set from config",
+ log.Log(log.SchedPartition).Info("NodeSorting policy set from config",
zap.Stringer("policyName", configuredPolicy))
}
pc.nodes.SetNodeSortingPolicy(objects.NewNodeSortingPolicy(conf.NodeSortPolicy.Type, conf.NodeSortPolicy.ResourceWeights))
@@ -157,15 +157,15 @@ func (pc *PartitionContext) updatePartitionDetails(conf configs.PartitionConfig)
}
if pc.placementManager.IsInitialised() {
- log.Logger().Info("Updating placement manager rules on config reload")
+ log.Log(log.SchedPartition).Info("Updating placement manager rules on config reload")
err := pc.placementManager.UpdateRules(conf.PlacementRules)
if err != nil {
- log.Logger().Info("New placement rules not activated, config reload failed", zap.Error(err))
+ log.Log(log.SchedPartition).Info("New placement rules not activated, config reload failed", zap.Error(err))
return err
}
pc.rules = &conf.PlacementRules
} else {
- log.Logger().Info("Creating new placement manager on config reload")
+ log.Log(log.SchedPartition).Info("Creating new placement manager on config reload")
pc.rules = &conf.PlacementRules
// We need to pass in the locked version of the GetQueue function.
// Placing an application will not have a lock on the partition context.
@@ -249,7 +249,7 @@ func (pc *PartitionContext) updateQueues(config []configs.QueueConfig, parent *o
// The current cleanup sequence is "immediate". This is implemented to allow a graceful cleanup.
func (pc *PartitionContext) markPartitionForRemoval() {
if err := pc.handlePartitionEvent(objects.Remove); err != nil {
- log.Logger().Error("failed to mark partition for deletion",
+ log.Log(log.SchedPartition).Error("failed to mark partition for deletion",
zap.String("partitionName", pc.Name),
zap.Error(err))
}
@@ -394,13 +394,13 @@ func (pc *PartitionContext) removeApplication(appID string) []*objects.Allocatio
currentUUID := alloc.GetUUID()
node := pc.GetNode(alloc.GetNodeID())
if node == nil {
- log.Logger().Warn("unknown node: not found in active node list",
+ log.Log(log.SchedPartition).Warn("unknown node: not found in active node list",
zap.String("appID", appID),
zap.String("nodeID", alloc.GetNodeID()))
continue
}
if nodeAlloc := node.RemoveAllocation(currentUUID); nodeAlloc == nil {
- log.Logger().Warn("unknown allocation: not found on the node",
+ log.Log(log.SchedPartition).Warn("unknown allocation: not found on the node",
zap.String("appID", appID),
zap.String("allocationId", currentUUID),
zap.String("nodeID", alloc.GetNodeID()))
@@ -495,7 +495,7 @@ func (pc *PartitionContext) createQueue(name string, user security.UserGroup) (*
}
current := name
queue := pc.getQueueInternal(current)
- log.Logger().Debug("Checking queue creation")
+ log.Log(log.SchedPartition).Debug("Checking queue creation")
for queue == nil {
toCreate = append(toCreate, current[strings.LastIndex(current, configs.DOT)+1:])
current = current[0:strings.LastIndex(current, configs.DOT)]
@@ -509,7 +509,7 @@ func (pc *PartitionContext) createQueue(name string, user security.UserGroup) (*
if queue.IsLeafQueue() {
return nil, fmt.Errorf("creation of queue %s failed parent is already a leaf: %s", name, current)
}
- log.Logger().Debug("Creating queue(s)",
+ log.Log(log.SchedPartition).Debug("Creating queue(s)",
zap.String("parent", current),
zap.String("fullPath", name))
for i := len(toCreate) - 1; i >= 0; i-- {
@@ -517,7 +517,7 @@ func (pc *PartitionContext) createQueue(name string, user security.UserGroup) (*
var err error
queue, err = objects.NewDynamicQueue(toCreate[i], i == 0, queue)
if err != nil {
- log.Logger().Warn("Queue auto create failed unexpected",
+ log.Log(log.SchedPartition).Warn("Queue auto create failed unexpected",
zap.String("queueName", toCreate[i]),
zap.Error(err))
return nil, err
@@ -540,7 +540,7 @@ func (pc *PartitionContext) AddNode(node *objects.Node, existingAllocations []*o
if node == nil {
return fmt.Errorf("cannot add 'nil' node to partition %s", pc.Name)
}
- log.Logger().Info("adding node to partition",
+ log.Log(log.SchedPartition).Info("adding node to partition",
zap.String("partition", pc.Name),
zap.String("nodeID", node.NodeID))
if pc.isDraining() || pc.isStopped() {
@@ -556,7 +556,7 @@ func (pc *PartitionContext) AddNode(node *objects.Node, existingAllocations []*o
if err := pc.addAllocation(alloc); err != nil {
// not expecting any inflight replacements on node recovery
released, _ := pc.removeNode(node.NodeID)
- log.Logger().Info("Failed to add existing allocations, changes reversed",
+ log.Log(log.SchedPartition).Info("Failed to add existing allocations, changes reversed",
zap.String("nodeID", node.NodeID),
zap.Int("existingAllocations", len(existingAllocations)),
zap.Int("releasedAllocations", len(released)),
@@ -605,7 +605,7 @@ func (pc *PartitionContext) addNodeToList(node *objects.Node) error {
pc.totalPartitionResource.AddTo(node.GetCapacity())
}
pc.root.SetMaxResource(pc.totalPartitionResource)
- log.Logger().Info("Updated available resources from added node",
+ log.Log(log.SchedPartition).Info("Updated available resources from added node",
zap.String("partitionName", pc.Name),
zap.String("nodeID", node.NodeID),
zap.Stringer("partitionResource", pc.totalPartitionResource))
@@ -620,7 +620,7 @@ func (pc *PartitionContext) removeNodeFromList(nodeID string) *objects.Node {
defer pc.Unlock()
node := pc.nodes.RemoveNode(nodeID)
if node == nil {
- log.Logger().Debug("node was not found, node already removed",
+ log.Log(log.SchedPartition).Debug("node was not found, node already removed",
zap.String("nodeID", nodeID),
zap.String("partitionName", pc.Name))
return nil
@@ -632,7 +632,7 @@ func (pc *PartitionContext) removeNodeFromList(nodeID string) *objects.Node {
// found the node cleanup the available resources, partition resources cannot be nil at this point
pc.totalPartitionResource.SubFrom(node.GetCapacity())
pc.root.SetMaxResource(pc.totalPartitionResource)
- log.Logger().Info("Updated available resources from removed node",
+ log.Log(log.SchedPartition).Info("Updated available resources from removed node",
zap.String("partitionName", pc.Name),
zap.String("nodeID", node.NodeID),
zap.Stringer("partitionResource", pc.totalPartitionResource))
@@ -645,7 +645,7 @@ func (pc *PartitionContext) removeNodeFromList(nodeID string) *objects.Node {
// other nodes.
// NOTE: this is a lock free call. It must NOT be called holding the PartitionContext lock.
func (pc *PartitionContext) removeNode(nodeID string) ([]*objects.Allocation, []*objects.Allocation) {
- log.Logger().Info("removing node from partition",
+ log.Log(log.SchedPartition).Info("removing node from partition",
zap.String("partition", pc.Name),
zap.String("nodeID", nodeID))
@@ -679,7 +679,7 @@ func (pc *PartitionContext) removeNodeAllocations(node *objects.Node) ([]*object
// was already removed
app := pc.getApplication(alloc.GetApplicationID())
if app == nil {
- log.Logger().Info("app is not found, skipping while removing the node",
+ log.Log(log.SchedPartition).Info("app is not found, skipping while removing the node",
zap.String("appID", alloc.GetApplicationID()),
zap.String("nodeID", node.NodeID))
continue
@@ -708,13 +708,13 @@ func (pc *PartitionContext) removeNodeAllocations(node *objects.Node) ([]*object
err := app.GetQueue().IncAllocatedResource(delta, false)
// this should not happen as we really decrease the value
if err != nil {
- log.Logger().Warn("unexpected failure during queue update: replacing placeholder",
+ log.Log(log.SchedPartition).Warn("unexpected failure during queue update: replacing placeholder",
zap.String("appID", alloc.GetApplicationID()),
zap.String("placeholderID", alloc.GetUUID()),
zap.String("allocationID", release.GetUUID()),
zap.Error(err))
}
- log.Logger().Warn("replacing placeholder: placeholder is larger than real allocation",
+ log.Log(log.SchedPartition).Warn("replacing placeholder: placeholder is larger than real allocation",
zap.String("allocationID", release.GetUUID()),
zap.Stringer("requested resource", release.GetAllocatedResource()),
zap.String("placeholderID", alloc.GetUUID()),
@@ -724,7 +724,7 @@ func (pc *PartitionContext) removeNodeAllocations(node *objects.Node) ([]*object
confirmed = append(confirmed, release)
// the allocation is removed so add it to the list that we return
released = append(released, alloc)
- log.Logger().Info("allocation removed from node and replacement confirmed",
+ log.Log(log.SchedPartition).Info("allocation removed from node and replacement confirmed",
zap.String("nodeID", node.NodeID),
zap.String("allocationId", allocID),
zap.String("replacement nodeID", release.GetNodeID()),
@@ -739,13 +739,13 @@ func (pc *PartitionContext) removeNodeAllocations(node *objects.Node) ([]*object
// update the repeat on the real alloc to get it re-scheduled
_, err := app.UpdateAskRepeat(askAlloc.GetAsk().GetAllocationKey(), 1)
if err == nil {
- log.Logger().Info("inflight placeholder replacement reversed due to node removal",
+ log.Log(log.SchedPartition).Info("inflight placeholder replacement reversed due to node removal",
zap.String("appID", askAlloc.GetApplicationID()),
zap.String("allocationKey", askAlloc.GetAsk().GetAllocationKey()),
zap.String("nodeID", node.NodeID),
zap.String("replacement allocationId", askAlloc.GetUUID()))
} else {
- log.Logger().Error("node removal: repeat update failure for inflight replacement",
+ log.Log(log.SchedPartition).Error("node removal: repeat update failure for inflight replacement",
zap.String("appID", askAlloc.GetApplicationID()),
zap.String("allocationKey", askAlloc.GetAsk().GetAllocationKey()),
zap.String("nodeID", node.NodeID),
@@ -754,14 +754,14 @@ func (pc *PartitionContext) removeNodeAllocations(node *objects.Node) ([]*object
}
// check allocations on the app
if app.RemoveAllocation(allocID, si.TerminationType_UNKNOWN_TERMINATION_TYPE) == nil {
- log.Logger().Info("allocation is not found, skipping while removing the node",
+ log.Log(log.SchedPartition).Info("allocation is not found, skipping while removing the node",
zap.String("allocationId", allocID),
zap.String("appID", app.ApplicationID),
zap.String("nodeID", node.NodeID))
continue
}
if err := app.GetQueue().DecAllocatedResource(alloc.GetAllocatedResource()); err != nil {
- log.Logger().Warn("failed to release resources from queue",
+ log.Log(log.SchedPartition).Warn("failed to release resources from queue",
zap.String("appID", alloc.GetApplicationID()),
zap.Error(err))
} else {
@@ -774,7 +774,7 @@ func (pc *PartitionContext) removeNodeAllocations(node *objects.Node) ([]*object
// the allocation is removed so add it to the list that we return
released = append(released, alloc)
- log.Logger().Info("allocation removed from node",
+ log.Log(log.SchedPartition).Info("allocation removed from node",
zap.String("nodeID", node.NodeID),
zap.String("allocationId", allocID))
}
@@ -832,7 +832,7 @@ func (pc *PartitionContext) tryPlaceholderAllocate() *objects.Allocation {
// try allocating from the root down
alloc := pc.root.TryPlaceholderAllocate(pc.GetNodeIterator, pc.GetNode)
if alloc != nil {
- log.Logger().Info("scheduler replace placeholder processed",
+ log.Log(log.SchedPartition).Info("scheduler replace placeholder processed",
zap.String("appID", alloc.GetApplicationID()),
zap.String("allocationKey", alloc.GetAllocationKey()),
zap.String("uuid", alloc.GetUUID()),
@@ -850,7 +850,7 @@ func (pc *PartitionContext) allocate(alloc *objects.Allocation) *objects.Allocat
appID := alloc.GetApplicationID()
app := pc.getApplication(appID)
if app == nil {
- log.Logger().Info("Application was removed while allocating",
+ log.Log(log.SchedPartition).Info("Application was removed while allocating",
zap.String("appID", appID))
return nil
}
@@ -862,14 +862,14 @@ func (pc *PartitionContext) allocate(alloc *objects.Allocation) *objects.Allocat
nodeID = alloc.GetNodeID()
} else {
nodeID = alloc.GetReservedNodeID()
- log.Logger().Debug("Reservation allocated on different node",
+ log.Log(log.SchedPartition).Debug("Reservation allocated on different node",
zap.String("current node", alloc.GetNodeID()),
zap.String("reserved node", nodeID),
zap.String("appID", appID))
}
node := pc.GetNode(nodeID)
if node == nil {
- log.Logger().Info("Node was removed while allocating",
+ log.Log(log.SchedPartition).Info("Node was removed while allocating",
zap.String("nodeID", nodeID),
zap.String("appID", appID))
return nil
@@ -892,7 +892,7 @@ func (pc *PartitionContext) allocate(alloc *objects.Allocation) *objects.Allocat
// track the number of allocations
pc.updateAllocationCount(1)
- log.Logger().Info("scheduler allocation processed",
+ log.Log(log.SchedPartition).Info("scheduler allocation processed",
zap.String("appID", alloc.GetApplicationID()),
zap.String("allocationKey", alloc.GetAllocationKey()),
zap.String("uuid", alloc.GetUUID()),
@@ -909,14 +909,14 @@ func (pc *PartitionContext) reserve(app *objects.Application, node *objects.Node
appID := app.ApplicationID
// app has node already reserved cannot reserve again
if app.IsReservedOnNode(node.NodeID) {
- log.Logger().Info("Application is already reserved on node",
+ log.Log(log.SchedPartition).Info("Application is already reserved on node",
zap.String("appID", appID),
zap.String("nodeID", node.NodeID))
return
}
// all ok, add the reservation to the app, this will also reserve the node
if err := app.Reserve(node, ask); err != nil {
- log.Logger().Debug("Failed to handle reservation, error during update of app",
+ log.Log(log.SchedPartition).Debug("Failed to handle reservation, error during update of app",
zap.Error(err))
return
}
@@ -924,7 +924,7 @@ func (pc *PartitionContext) reserve(app *objects.Application, node *objects.Node
// add the reservation to the queue list
app.GetQueue().Reserve(appID)
- log.Logger().Info("allocation ask is reserved",
+ log.Log(log.SchedPartition).Info("allocation ask is reserved",
zap.String("appID", appID),
zap.String("queue", app.GetQueuePath()),
zap.String("allocationKey", ask.GetAllocationKey()),
@@ -938,7 +938,7 @@ func (pc *PartitionContext) unReserve(app *objects.Application, node *objects.No
var err error
var num int
if num, err = app.UnReserve(node, ask); err != nil {
- log.Logger().Info("Failed to unreserve, error during allocate on the app",
+ log.Log(log.SchedPartition).Info("Failed to unreserve, error during allocate on the app",
zap.Error(err))
return
}
@@ -946,7 +946,7 @@ func (pc *PartitionContext) unReserve(app *objects.Application, node *objects.No
appID := app.ApplicationID
app.GetQueue().UnReserve(appID, num)
- log.Logger().Info("allocation ask is unreserved",
+ log.Log(log.SchedPartition).Info("allocation ask is unreserved",
zap.String("appID", appID),
zap.String("queue", app.GetQueuePath()),
zap.String("allocationKey", ask.GetAllocationKey()),
@@ -1119,7 +1119,7 @@ func (pc *PartitionContext) addAllocation(alloc *objects.Allocation) error {
alloc.GetAllocationKey(), alloc.GetApplicationID())
}
- log.Logger().Info("adding recovered allocation",
+ log.Log(log.SchedPartition).Info("adding recovered allocation",
zap.String("partitionName", pc.Name),
zap.String("appID", alloc.GetApplicationID()),
zap.String("allocKey", alloc.GetAllocationKey()),
@@ -1156,7 +1156,7 @@ func (pc *PartitionContext) addAllocation(alloc *objects.Allocation) error {
// track the number of allocations
pc.updateAllocationCount(1)
- log.Logger().Info("recovered allocation",
+ log.Log(log.SchedPartition).Info("recovered allocation",
zap.String("partitionName", pc.Name),
zap.String("appID", alloc.GetApplicationID()),
zap.String("allocKey", alloc.GetAllocationKey()),
@@ -1225,7 +1225,7 @@ func (pc *PartitionContext) removeAllocation(release *si.AllocationRelease) ([]*
app := pc.getApplication(appID)
// no app nothing to do everything should already be clean
if app == nil {
- log.Logger().Info("Application not found while releasing allocation",
+ log.Log(log.SchedPartition).Info("Application not found while releasing allocation",
zap.String("appID", appID),
zap.String("allocationId", uuid),
zap.Stringer("terminationType", release.TerminationType))
@@ -1236,20 +1236,20 @@ func (pc *PartitionContext) removeAllocation(release *si.AllocationRelease) ([]*
var confirmed *objects.Allocation
// when uuid is not specified, remove all allocations from the app
if uuid == "" {
- log.Logger().Info("remove all allocations",
+ log.Log(log.SchedPartition).Info("remove all allocations",
zap.String("appID", appID))
released = append(released, app.RemoveAllAllocations()...)
} else {
// if we have an uuid the termination type is important
if release.TerminationType == si.TerminationType_PLACEHOLDER_REPLACED {
- log.Logger().Info("replacing placeholder allocation",
+ log.Log(log.SchedPartition).Info("replacing placeholder allocation",
zap.String("appID", appID),
zap.String("allocationId", uuid))
if alloc := app.ReplaceAllocation(uuid); alloc != nil {
released = append(released, alloc)
}
} else {
- log.Logger().Info("removing allocation from application",
+ log.Log(log.SchedPartition).Info("removing allocation from application",
zap.String("appID", appID),
zap.String("allocationId", uuid),
zap.Stringer("terminationType", release.TerminationType))
@@ -1265,7 +1265,7 @@ func (pc *PartitionContext) removeAllocation(release *si.AllocationRelease) ([]*
for _, alloc := range released {
node := pc.GetNode(alloc.GetNodeID())
if node == nil {
- log.Logger().Info("node not found while releasing allocation",
+ log.Log(log.SchedPartition).Info("node not found while releasing allocation",
zap.String("appID", appID),
zap.String("allocationId", alloc.GetUUID()),
zap.String("nodeID", alloc.GetNodeID()))
@@ -1282,7 +1282,7 @@ func (pc *PartitionContext) removeAllocation(release *si.AllocationRelease) ([]*
// This looks incorrect but the delta is negative and the result will be an increase of the
// total tracked. The total will later be deducted from the queue usage.
total.SubFrom(delta)
- log.Logger().Warn("replacing placeholder: placeholder is larger than real allocation",
+ log.Log(log.SchedPartition).Warn("replacing placeholder: placeholder is larger than real allocation",
zap.String("allocationID", confirmed.GetUUID()),
zap.Stringer("requested resource", confirmed.GetAllocatedResource()),
zap.String("placeholderID", alloc.GetUUID()),
@@ -1296,14 +1296,14 @@ func (pc *PartitionContext) removeAllocation(release *si.AllocationRelease) ([]*
// we have already added the real allocation to the new node, just remove the placeholder
node.RemoveAllocation(alloc.GetUUID())
}
- log.Logger().Info("replacing placeholder allocation on node",
+ log.Log(log.SchedPartition).Info("replacing placeholder allocation on node",
zap.String("nodeID", alloc.GetNodeID()),
zap.String("allocationId", alloc.GetUUID()),
zap.String("allocation nodeID", confirmed.GetNodeID()))
} else if node.RemoveAllocation(alloc.GetUUID()) != nil {
// all non replacement are real removes: must update the queue usage
total.AddTo(alloc.GetAllocatedResource())
- log.Logger().Info("removing allocation from node",
+ log.Log(log.SchedPartition).Info("removing allocation from node",
zap.String("nodeID", alloc.GetNodeID()),
zap.String("allocationId", alloc.GetUUID()))
}
@@ -1314,7 +1314,7 @@ func (pc *PartitionContext) removeAllocation(release *si.AllocationRelease) ([]*
if resources.StrictlyGreaterThanZero(total) {
queue := app.GetQueue()
if err := queue.DecAllocatedResource(total); err != nil {
- log.Logger().Warn("failed to release resources from queue",
+ log.Log(log.SchedPartition).Warn("failed to release resources from queue",
zap.String("appID", appID),
zap.String("allocationId", uuid),
zap.Error(err))
@@ -1352,14 +1352,14 @@ func (pc *PartitionContext) removeAllocationAsk(release *si.AllocationAskRelease
allocKey := release.AllocationKey
// A timeout termination is send by the core to the shim, ignore on return.
if release.TerminationType == si.TerminationType_TIMEOUT {
- log.Logger().Debug("Ignoring ask release with termination type Timeout",
+ log.Log(log.SchedPartition).Debug("Ignoring ask release with termination type Timeout",
zap.String("appID", appID),
zap.String("ask", allocKey))
return
}
app := pc.getApplication(appID)
if app == nil {
- log.Logger().Info("Invalid ask release requested by shim",
+ log.Log(log.SchedPartition).Info("Invalid ask release requested by shim",
zap.String("appID", appID),
zap.String("ask", allocKey),
zap.Stringer("terminationType", release.TerminationType))
@@ -1411,14 +1411,14 @@ func (pc *PartitionContext) moveTerminatedApp(appID string) {
app := pc.getApplication(appID)
// nothing to do if the app is not found on the partition
if app == nil {
- log.Logger().Debug("Application already removed from app list",
+ log.Log(log.SchedPartition).Debug("Application already removed from app list",
zap.String("appID", appID))
return
}
app.UnSetQueue()
// new ID as completedApplications map key, use negative value to get a divider
newID := appID + strconv.FormatInt(-(time.Now()).Unix(), 10)
- log.Logger().Info("Removing terminated application from the application list",
+ log.Log(log.SchedPartition).Info("Removing terminated application from the application list",
zap.String("appID", appID),
zap.String("app status", app.CurrentState()))
app.LogAppSummary(pc.RmID)
@@ -1431,7 +1431,7 @@ func (pc *PartitionContext) moveTerminatedApp(appID string) {
func (pc *PartitionContext) AddRejectedApplication(rejectedApplication *objects.Application, rejectedMessage string) {
if err := rejectedApplication.RejectApplication(rejectedMessage); err != nil {
- log.Logger().Warn("BUG: Unexpected failure: Application state not changed to Rejected",
+ log.Log(log.SchedPartition).Warn("BUG: Unexpected failure: Application state not changed to Rejected",
zap.String("currentState", rejectedApplication.CurrentState()),
zap.Error(err))
}
diff --git a/pkg/scheduler/partition_manager.go b/pkg/scheduler/partition_manager.go
index 307f8672..ab54a859 100644
--- a/pkg/scheduler/partition_manager.go
+++ b/pkg/scheduler/partition_manager.go
@@ -60,7 +60,7 @@ func newPartitionManager(pc *PartitionContext, cc *ClusterContext) *partitionMan
// - remove rejected applications from the partition
// When the manager exits the partition is removed from the system and must be cleaned up
func (manager *partitionManager) Run() {
- log.Logger().Info("starting partition manager",
+ log.Log(log.SchedPartition).Info("starting partition manager",
zap.String("partition", manager.pc.Name),
zap.Stringer("cleanRootInterval", manager.cleanRootInterval))
go manager.cleanExpiredApps()
@@ -80,7 +80,7 @@ func (manager *partitionManager) cleanRoot() {
case <-time.After(cleanRootInterval):
runStart := time.Now()
manager.cleanQueues(manager.pc.root)
- log.Logger().Debug("time consumed for queue cleaner",
+ log.Log(log.SchedPartition).Debug("time consumed for queue cleaner",
zap.Stringer("duration", time.Since(runStart)))
}
}
@@ -110,20 +110,20 @@ func (manager *partitionManager) cleanQueues(queue *objects.Queue) {
}
// when we have done the children (or have none) this queue might be removable
if queue.IsDraining() || !queue.IsManaged() {
- log.Logger().Debug("removing queue",
+ log.Log(log.SchedPartition).Debug("removing queue",
zap.String("queueName", queue.QueuePath),
zap.String("partitionName", manager.pc.Name))
// make sure the queue is empty
if queue.IsEmpty() {
// all OK update the queue hierarchy and partition
if !queue.RemoveQueue() {
- log.Logger().Debug("unexpected failure removing the queue",
+ log.Log(log.SchedPartition).Debug("unexpected failure removing the queue",
zap.String("partitionName", manager.pc.Name),
zap.String("queue", queue.QueuePath))
}
} else {
// TODO time out waiting for draining and removal
- log.Logger().Debug("skip removing the queue",
+ log.Log(log.SchedPartition).Debug("skip removing the queue",
zap.String("reason", "there are existing assigned apps or leaf queues"),
zap.String("queue", queue.QueuePath),
zap.String("partitionName", manager.pc.Name))
@@ -139,13 +139,13 @@ func (manager *partitionManager) cleanQueues(queue *objects.Queue) {
// last action is to remove the cluster links
//nolint:errcheck
func (manager *partitionManager) remove() {
- log.Logger().Info("marking all queues for removal",
+ log.Log(log.SchedPartition).Info("marking all queues for removal",
zap.String("partitionName", manager.pc.Name))
// mark all queues for removal
manager.pc.root.MarkQueueForRemoval()
// remove applications: we do not care about return values or issues
apps := manager.pc.GetApplications()
- log.Logger().Info("removing all applications from partition",
+ log.Log(log.SchedPartition).Info("removing all applications from partition",
zap.Int("numOfApps", len(apps)),
zap.String("partitionName", manager.pc.Name))
for i := range apps {
@@ -155,13 +155,13 @@ func (manager *partitionManager) remove() {
}
// remove the nodes
nodes := manager.pc.GetNodes()
- log.Logger().Info("removing all nodes from partition",
+ log.Log(log.SchedPartition).Info("removing all nodes from partition",
zap.Int("numOfNodes", len(nodes)),
zap.String("partitionName", manager.pc.Name))
for i := range nodes {
_, _ = manager.pc.removeNode(nodes[i].NodeID)
}
- log.Logger().Info("removing partition",
+ log.Log(log.SchedPartition).Info("removing partition",
zap.String("partitionName", manager.pc.Name))
// remove the scheduler object
manager.cc.removePartition(manager.pc.Name)
diff --git a/pkg/scheduler/placement/filter.go b/pkg/scheduler/placement/filter.go
index b2c296a9..72f8181f 100644
--- a/pkg/scheduler/placement/filter.go
+++ b/pkg/scheduler/placement/filter.go
@@ -50,7 +50,7 @@ func (filter Filter) allowUser(userObj security.UserGroup) bool {
filteredUser := filter.filterUser(user)
// if we have found the user in the list stop looking and return
if filteredUser {
- log.Logger().Debug("Filter matched user getName", zap.String("user", user))
+ log.Log(log.Config).Debug("Filter matched user getName", zap.String("user", user))
return filteredUser && filter.allow
}
// not in the user list, check the groups in the list
@@ -58,7 +58,7 @@ func (filter Filter) allowUser(userObj security.UserGroup) bool {
for _, group := range groups {
filteredUser = filter.filterGroup(group)
if filteredUser {
- log.Logger().Debug("Filter matched user group", zap.String("group", group))
+ log.Log(log.Config).Debug("Filter matched user group", zap.String("group", group))
return filteredUser && filter.allow
}
}
@@ -104,7 +104,7 @@ func newFilter(conf configs.Filter) Filter {
if configs.SpecialRegExp.MatchString(user) {
filter.userExp, err = regexp.Compile(user)
if err != nil {
- log.Logger().Debug("Filter user expression does not compile", zap.Any("userFilter", conf.Users))
+ log.Log(log.Config).Debug("Filter user expression does not compile", zap.Any("userFilter", conf.Users))
}
} else if configs.UserRegExp.MatchString(user) {
// regexp not found consider this a user, sanity check the entry
@@ -122,14 +122,14 @@ func newFilter(conf configs.Filter) Filter {
}
}
if len(filter.userList) != len(conf.Users) {
- log.Logger().Info("Filter creation duplicate or invalid users found", zap.Any("userFilter", conf.Users))
+ log.Log(log.Config).Info("Filter creation duplicate or invalid users found", zap.Any("userFilter", conf.Users))
}
filter.empty = false
}
// check what we have created
if len(conf.Users) > 0 && filter.userExp == nil && len(filter.userList) == 0 {
- log.Logger().Info("Filter creation partially failed (user)", zap.Any("userFilter", conf.Users))
+ log.Log(log.Config).Info("Filter creation partially failed (user)", zap.Any("userFilter", conf.Users))
}
// create the group list or regexp
@@ -139,7 +139,7 @@ func newFilter(conf configs.Filter) Filter {
if configs.SpecialRegExp.MatchString(group) {
filter.groupExp, err = regexp.Compile(group)
if err != nil {
- log.Logger().Debug("Filter group expression does not compile", zap.Any("groupFilter", conf.Groups))
+ log.Log(log.Config).Debug("Filter group expression does not compile", zap.Any("groupFilter", conf.Groups))
}
} else if configs.GroupRegExp.MatchString(group) {
// regexp not found consider this a group, sanity check the entry
@@ -157,14 +157,14 @@ func newFilter(conf configs.Filter) Filter {
}
}
if len(filter.groupList) != len(conf.Groups) {
- log.Logger().Info("Filter creation duplicate or invalid groups found", zap.Any("groupFilter", conf.Groups))
+ log.Log(log.Config).Info("Filter creation duplicate or invalid groups found", zap.Any("groupFilter", conf.Groups))
}
filter.empty = false
}
// check what we have created
if len(conf.Groups) > 0 && filter.groupExp == nil && len(filter.groupList) == 0 {
- log.Logger().Info("Filter creation partially failed (groups)", zap.Any("groupFilter", conf.Groups))
+ log.Log(log.Config).Info("Filter creation partially failed (groups)", zap.Any("groupFilter", conf.Groups))
}
// log the filter with all details (only at debug)
@@ -184,7 +184,7 @@ func logFilter(filter *Filter) {
} else {
groupfilter = filter.groupExp.String()
}
- log.Logger().Debug("Filter creation passed",
+ log.Log(log.Config).Debug("Filter creation passed",
zap.Bool("allow", filter.allow),
zap.Bool("empty", filter.empty),
zap.Any("userList", filter.userList),
diff --git a/pkg/scheduler/placement/fixed_rule.go b/pkg/scheduler/placement/fixed_rule.go
index d12560c8..8dce0bba 100644
--- a/pkg/scheduler/placement/fixed_rule.go
+++ b/pkg/scheduler/placement/fixed_rule.go
@@ -66,7 +66,7 @@ func (fr *fixedRule) initialise(conf configs.PlacementRule) error {
func (fr *fixedRule) placeApplication(app *objects.Application, queueFn func(string) *objects.Queue) (string, error) {
// before anything run the filter
if !fr.filter.allowUser(app.GetUser()) {
- log.Logger().Debug("Fixed rule filtered",
+ log.Log(log.Config).Debug("Fixed rule filtered",
zap.String("application", app.ApplicationID),
zap.Any("user", app.GetUser()),
zap.String("queueName", fr.queue))
@@ -105,7 +105,7 @@ func (fr *fixedRule) placeApplication(app *objects.Application, queueFn func(str
queueName = parentName + configs.DOT + fr.queue
}
// Log the result before we really create
- log.Logger().Debug("Fixed rule intermediate result",
+ log.Log(log.Config).Debug("Fixed rule intermediate result",
zap.String("application", app.ApplicationID),
zap.String("queue", queueName))
// get the queue object
@@ -114,7 +114,7 @@ func (fr *fixedRule) placeApplication(app *objects.Application, queueFn func(str
if !fr.create && queue == nil {
return "", nil
}
- log.Logger().Info("Fixed rule application placed",
+ log.Log(log.Config).Info("Fixed rule application placed",
zap.String("application", app.ApplicationID),
zap.String("queue", queueName))
return queueName, nil
diff --git a/pkg/scheduler/placement/placement.go b/pkg/scheduler/placement/placement.go
index f420c353..c4b6ae8d 100644
--- a/pkg/scheduler/placement/placement.go
+++ b/pkg/scheduler/placement/placement.go
@@ -42,13 +42,13 @@ type AppPlacementManager struct {
func NewPlacementManager(rules []configs.PlacementRule, queueFunc func(string) *objects.Queue) *AppPlacementManager {
m := &AppPlacementManager{}
if queueFunc == nil {
- log.Logger().Info("Placement manager created without queue function: not active")
+ log.Log(log.Config).Info("Placement manager created without queue function: not active")
return m
}
m.queueFn = queueFunc
if len(rules) > 0 {
if err := m.initialise(rules); err != nil {
- log.Logger().Info("Placement manager created without rules: not active",
+ log.Log(log.Config).Info("Placement manager created without rules: not active",
zap.Error(err))
}
}
@@ -59,9 +59,9 @@ func NewPlacementManager(rules []configs.PlacementRule, queueFunc func(string) *
// Note that this will only be called when the manager is created earlier and the config is updated.
func (m *AppPlacementManager) UpdateRules(rules []configs.PlacementRule) error {
if len(rules) > 0 {
- log.Logger().Info("Building new rule list for placement manager")
+ log.Log(log.Config).Info("Building new rule list for placement manager")
if err := m.initialise(rules); err != nil {
- log.Logger().Info("Placement manager rules not reloaded",
+ log.Log(log.Config).Info("Placement manager rules not reloaded",
zap.Error(err))
return err
}
@@ -70,7 +70,7 @@ func (m *AppPlacementManager) UpdateRules(rules []configs.PlacementRule) error {
if len(rules) == 0 && m.initialised {
m.Lock()
defer m.Unlock()
- log.Logger().Info("Placement manager rules removed on config reload")
+ log.Log(log.Config).Info("Placement manager rules removed on config reload")
m.initialised = false
m.rules = make([]rule, 0)
}
@@ -86,7 +86,7 @@ func (m *AppPlacementManager) IsInitialised() bool {
// Initialise the rules from a parsed config.
func (m *AppPlacementManager) initialise(rules []configs.PlacementRule) error {
- log.Logger().Info("Building new rule list for placement manager")
+ log.Log(log.Config).Info("Building new rule list for placement manager")
// build temp list from new config
tempRules, err := m.buildRules(rules)
if err != nil {
@@ -98,12 +98,12 @@ func (m *AppPlacementManager) initialise(rules []configs.PlacementRule) error {
return fmt.Errorf("placement manager queue function nil")
}
- log.Logger().Info("Activated rule set in placement manager")
+ log.Log(log.Config).Info("Activated rule set in placement manager")
m.rules = tempRules
// all done manager is initialised
m.initialised = true
for rule := range m.rules {
- log.Logger().Debug("rule set",
+ log.Log(log.Config).Debug("rule set",
zap.Int("ruleNumber", rule),
zap.String("ruleName", m.rules[rule].getName()))
}
@@ -140,12 +140,12 @@ func (m *AppPlacementManager) PlaceApplication(app *objects.Application) error {
var queueName string
var err error
for _, checkRule := range m.rules {
- log.Logger().Debug("Executing rule for placing application",
+ log.Log(log.Config).Debug("Executing rule for placing application",
zap.String("ruleName", checkRule.getName()),
zap.String("application", app.ApplicationID))
queueName, err = checkRule.placeApplication(app, m.queueFn)
if err != nil {
- log.Logger().Error("rule execution failed",
+ log.Log(log.Config).Error("rule execution failed",
zap.String("ruleName", checkRule.getName()),
zap.Error(err))
app.SetQueuePath("")
@@ -165,7 +165,7 @@ func (m *AppPlacementManager) PlaceApplication(app *objects.Application) error {
}
// Check if the user is allowed to submit to this queueName, if not next rule
if !queue.CheckSubmitAccess(app.GetUser()) {
- log.Logger().Debug("Submit access denied on queue",
+ log.Log(log.Config).Debug("Submit access denied on queue",
zap.String("queueName", queue.GetQueuePath()),
zap.String("ruleName", checkRule.getName()),
zap.String("application", app.ApplicationID))
@@ -176,7 +176,7 @@ func (m *AppPlacementManager) PlaceApplication(app *objects.Application) error {
} else {
// Check if this final queue is a leaf queue, if not next rule
if !queue.IsLeafQueue() {
- log.Logger().Debug("Rule returned parent queue",
+ log.Log(log.Config).Debug("Rule returned parent queue",
zap.String("queueName", queueName),
zap.String("ruleName", checkRule.getName()),
zap.String("application", app.ApplicationID))
@@ -186,7 +186,7 @@ func (m *AppPlacementManager) PlaceApplication(app *objects.Application) error {
}
// Check if the user is allowed to submit to this queueName, if not next rule
if !queue.CheckSubmitAccess(app.GetUser()) {
- log.Logger().Debug("Submit access denied on queue",
+ log.Log(log.Config).Debug("Submit access denied on queue",
zap.String("queueName", queueName),
zap.String("ruleName", checkRule.getName()),
zap.String("application", app.ApplicationID))
@@ -199,7 +199,7 @@ func (m *AppPlacementManager) PlaceApplication(app *objects.Application) error {
break
}
}
- log.Logger().Debug("Rule result for placing application",
+ log.Log(log.Config).Debug("Rule result for placing application",
zap.String("application", app.ApplicationID),
zap.String("queueName", queueName))
// no more rules to check no queueName found reject placement
diff --git a/pkg/scheduler/placement/provided_rule.go b/pkg/scheduler/placement/provided_rule.go
index 7edcf01e..203cc28c 100644
--- a/pkg/scheduler/placement/provided_rule.go
+++ b/pkg/scheduler/placement/provided_rule.go
@@ -60,7 +60,7 @@ func (pr *providedRule) placeApplication(app *objects.Application, queueFn func(
}
// before anything run the filter
if !pr.filter.allowUser(app.GetUser()) {
- log.Logger().Debug("Provided rule filtered",
+ log.Log(log.Config).Debug("Provided rule filtered",
zap.String("application", app.ApplicationID),
zap.Any("user", app.GetUser()))
return "", nil
@@ -97,7 +97,7 @@ func (pr *providedRule) placeApplication(app *objects.Application, queueFn func(
// Make it a fully qualified queue
queueName = parentName + configs.DOT + replaceDot(queueName)
}
- log.Logger().Debug("Provided rule intermediate result",
+ log.Log(log.Config).Debug("Provided rule intermediate result",
zap.String("application", app.ApplicationID),
zap.String("queue", queueName))
// get the queue object
@@ -106,7 +106,7 @@ func (pr *providedRule) placeApplication(app *objects.Application, queueFn func(
if !pr.create && queue == nil {
return "", nil
}
- log.Logger().Info("Provided rule application placed",
+ log.Log(log.Config).Info("Provided rule application placed",
zap.String("application", app.ApplicationID),
zap.String("queue", queueName))
return queueName, nil
diff --git a/pkg/scheduler/placement/rule.go b/pkg/scheduler/placement/rule.go
index 0cb6b4ac..3120d886 100644
--- a/pkg/scheduler/placement/rule.go
+++ b/pkg/scheduler/placement/rule.go
@@ -105,10 +105,10 @@ func newRule(conf configs.PlacementRule) (rule, error) {
// initialise the rule: do not expect the rule to log errors
err = newRule.initialise(conf)
if err != nil {
- log.Logger().Error("Rule init failed", zap.Error(err))
+ log.Log(log.Config).Error("Rule init failed", zap.Error(err))
return nil, err
}
- log.Logger().Debug("New rule created", zap.Any("ruleConf", conf))
+ log.Log(log.Config).Debug("New rule created", zap.Any("ruleConf", conf))
return newRule, nil
}
diff --git a/pkg/scheduler/placement/tag_rule.go b/pkg/scheduler/placement/tag_rule.go
index 6b637b31..99030b75 100644
--- a/pkg/scheduler/placement/tag_rule.go
+++ b/pkg/scheduler/placement/tag_rule.go
@@ -65,7 +65,7 @@ func (tr *tagRule) placeApplication(app *objects.Application, queueFn func(strin
}
// before anything run the filter
if !tr.filter.allowUser(app.GetUser()) {
- log.Logger().Debug("Tag rule filtered",
+ log.Log(log.Config).Debug("Tag rule filtered",
zap.String("application", app.ApplicationID),
zap.Any("user", app.GetUser()),
zap.String("tagName", tr.tagName))
@@ -103,7 +103,7 @@ func (tr *tagRule) placeApplication(app *objects.Application, queueFn func(strin
}
queueName = parentName + configs.DOT + replaceDot(tagVal)
}
- log.Logger().Debug("Tag rule intermediate result",
+ log.Log(log.Config).Debug("Tag rule intermediate result",
zap.String("application", app.ApplicationID),
zap.String("queue", queueName))
// get the queue object
@@ -112,7 +112,7 @@ func (tr *tagRule) placeApplication(app *objects.Application, queueFn func(strin
if !tr.create && queue == nil {
return "", nil
}
- log.Logger().Info("Tag rule application placed",
+ log.Log(log.Config).Info("Tag rule application placed",
zap.String("application", app.ApplicationID),
zap.String("queue", queueName))
return queueName, nil
diff --git a/pkg/scheduler/placement/user_rule.go b/pkg/scheduler/placement/user_rule.go
index a29d366d..9ecb9eae 100644
--- a/pkg/scheduler/placement/user_rule.go
+++ b/pkg/scheduler/placement/user_rule.go
@@ -53,7 +53,7 @@ func (ur *userRule) placeApplication(app *objects.Application, queueFn func(stri
// before anything run the filter
userName := app.GetUser().User
if !ur.filter.allowUser(app.GetUser()) {
- log.Logger().Debug("User rule filtered",
+ log.Log(log.Config).Debug("User rule filtered",
zap.String("application", app.ApplicationID),
zap.Any("user", app.GetUser()))
return "", nil
@@ -86,7 +86,7 @@ func (ur *userRule) placeApplication(app *objects.Application, queueFn func(stri
parentName = configs.RootQueue
}
queueName := parentName + configs.DOT + replaceDot(userName)
- log.Logger().Debug("User rule intermediate result",
+ log.Log(log.Config).Debug("User rule intermediate result",
zap.String("application", app.ApplicationID),
zap.String("queue", queueName))
// get the queue object
@@ -95,7 +95,7 @@ func (ur *userRule) placeApplication(app *objects.Application, queueFn func(stri
if !ur.create && queue == nil {
return "", nil
}
- log.Logger().Info("User rule application placed",
+ log.Log(log.Config).Info("User rule application placed",
zap.String("application", app.ApplicationID),
zap.String("queue", queueName))
return queueName, nil
diff --git a/pkg/scheduler/scheduler.go b/pkg/scheduler/scheduler.go
index 9e6ed7b7..9f2cf782 100644
--- a/pkg/scheduler/scheduler.go
+++ b/pkg/scheduler/scheduler.go
@@ -93,12 +93,12 @@ func (s *Scheduler) HandleEvent(ev interface{}) {
func enqueueAndCheckFull(queue chan interface{}, ev interface{}) {
select {
case queue <- ev:
- log.Logger().Debug("enqueued event",
+ log.Log(log.Scheduler).Debug("enqueued event",
zap.Stringer("eventType", reflect.TypeOf(ev)),
zap.Any("event", ev),
zap.Int("currentQueueSize", len(queue)))
default:
- log.Logger().DPanic("failed to enqueue event",
+ log.Log(log.Scheduler).DPanic("failed to enqueue event",
zap.Stringer("event", reflect.TypeOf(ev)))
}
}
@@ -120,7 +120,7 @@ func (s *Scheduler) handleRMEvent() {
case *rmevent.RMConfigUpdateEvent:
s.clusterContext.processRMConfigUpdateEvent(v)
default:
- log.Logger().Error("Received type is not an acceptable type for RM event.",
+ log.Log(log.Scheduler).Error("Received type is not an acceptable type for RM event.",
zap.Stringer("received type", reflect.TypeOf(v)))
}
s.registerActivity()
@@ -154,13 +154,13 @@ func (s *Scheduler) awaitActivity() {
// state through the ContainerSchedulingStateUpdaterPlugin in order
// to trigger the auto-scaling.
func (s *Scheduler) inspectOutstandingRequests() {
- log.Logger().Debug("inspect outstanding requests")
+ log.Log(log.Scheduler).Debug("inspect outstanding requests")
// schedule each partition defined in the cluster
for _, psc := range s.clusterContext.GetPartitionMapClone() {
requests := psc.calculateOutstandingRequests()
if len(requests) > 0 {
for _, ask := range requests {
- log.Logger().Debug("outstanding request",
+ log.Log(log.Scheduler).Debug("outstanding request",
zap.String("appID", ask.GetApplicationID()),
zap.String("allocationKey", ask.GetAllocationKey()))
// these asks are queue outstanding requests,
@@ -187,7 +187,7 @@ func (s *Scheduler) GetClusterContext() *ClusterContext {
// Visible by tests
func (s *Scheduler) MultiStepSchedule(nAlloc int) {
for i := 0; i < nAlloc; i++ {
- log.Logger().Debug("Scheduler manual stepping",
+ log.Log(log.Scheduler).Debug("Scheduler manual stepping",
zap.Int("count", i))
s.clusterContext.schedule()
diff --git a/pkg/scheduler/tests/utilities_test.go b/pkg/scheduler/tests/utilities_test.go
index 968a66e7..df493517 100644
--- a/pkg/scheduler/tests/utilities_test.go
+++ b/pkg/scheduler/tests/utilities_test.go
@@ -64,7 +64,7 @@ func waitForPendingQueueResource(t *testing.T, queue *objects.Queue, memory reso
return queue.GetPendingResource().Resources[siCommon.Memory] == memory
})
if err != nil {
- log.Logger().Info("queue detail",
+ log.Log(log.Test).Info("queue detail",
zap.Any("queue", queue))
t.Fatalf("Failed to wait pending resource on queue %s, expected %v, actual %v, called from: %s", queue.QueuePath, memory, queue.GetPendingResource().Resources[siCommon.Memory], caller())
}
diff --git a/pkg/scheduler/ugm/manager.go b/pkg/scheduler/ugm/manager.go
index a73d5458..be5b5679 100644
--- a/pkg/scheduler/ugm/manager.go
+++ b/pkg/scheduler/ugm/manager.go
@@ -67,12 +67,12 @@ func GetUserManager() *Manager {
// As and when every allocation or asks requests fulfilled on application, corresponding user and group
// resource usage would be increased against specific application.
func (m *Manager) IncreaseTrackedResource(queuePath string, applicationID string, usage *resources.Resource, user security.UserGroup) error {
- log.Logger().Debug("Increasing resource usage", zap.String("user", user.User),
+ log.Log(log.SchedUGM).Debug("Increasing resource usage", zap.String("user", user.User),
zap.String("queue path", queuePath),
zap.String("application", applicationID),
zap.Stringer("resource", usage))
if queuePath == "" || applicationID == "" || usage == nil || user.User == "" {
- log.Logger().Error("Mandatory parameters are missing to increase the resource usage",
+ log.Log(log.SchedUGM).Error("Mandatory parameters are missing to increase the resource usage",
zap.String("user", user.User),
zap.String("queue path", queuePath),
zap.String("application", applicationID),
@@ -88,12 +88,12 @@ func (m *Manager) IncreaseTrackedResource(queuePath string, applicationID string
// Set the limits for all configured queue paths of the user
for configQueuePath, config := range m.userLimitsConfig[user.User] {
- log.Logger().Debug("Setting the limit max applications settings.",
+ log.Log(log.SchedUGM).Debug("Setting the limit max applications settings.",
zap.String("user", user.User),
zap.String("queue path", configQueuePath))
maxApps, ok := config[maxapplications].(uint64)
if !ok {
- log.Logger().Warn("Problem in setting the limit max applications settings. Unable to cast the value from interface to uint64",
+ log.Log(log.SchedUGM).Warn("Problem in setting the limit max applications settings. Unable to cast the value from interface to uint64",
zap.String("user", user.User),
zap.String("queue path", configQueuePath),
zap.Uint64("limit max applications", maxApps))
@@ -102,7 +102,7 @@ func (m *Manager) IncreaseTrackedResource(queuePath string, applicationID string
}
err := userTracker.setMaxApplications(maxApps, configQueuePath)
if err != nil {
- log.Logger().Warn("Problem in setting the limit max applications settings.",
+ log.Log(log.SchedUGM).Warn("Problem in setting the limit max applications settings.",
zap.String("user", user.User),
zap.String("queue path", configQueuePath),
zap.Uint64("limit max applications", maxApps),
@@ -112,7 +112,7 @@ func (m *Manager) IncreaseTrackedResource(queuePath string, applicationID string
}
maxResources, ok := config[maxresources].(map[string]string)
if !ok {
- log.Logger().Warn("Problem in setting the limit max resources settings. Unable to cast the value from interface to resource",
+ log.Log(log.SchedUGM).Warn("Problem in setting the limit max resources settings. Unable to cast the value from interface to resource",
zap.String("user", user.User),
zap.String("queue path", configQueuePath),
zap.Any("limit max resources", maxResources))
@@ -121,7 +121,7 @@ func (m *Manager) IncreaseTrackedResource(queuePath string, applicationID string
}
resource, resourceErr := resources.NewResourceFromConf(maxResources)
if resourceErr != nil {
- log.Logger().Warn("Problem in setting the limit max resources settings.",
+ log.Log(log.SchedUGM).Warn("Problem in setting the limit max resources settings.",
zap.String("user", user.User),
zap.String("queue path", configQueuePath),
zap.Any("limit max resources", maxResources),
@@ -131,7 +131,7 @@ func (m *Manager) IncreaseTrackedResource(queuePath string, applicationID string
}
setMaxResourcesErr := userTracker.setMaxResources(resource, configQueuePath)
if setMaxResourcesErr != nil {
- log.Logger().Warn("Problem in setting the limit max resources settings.",
+ log.Log(log.SchedUGM).Warn("Problem in setting the limit max resources settings.",
zap.String("user", user.User),
zap.String("queue path", configQueuePath),
zap.Any("limit max resources", maxResources),
@@ -146,7 +146,7 @@ func (m *Manager) IncreaseTrackedResource(queuePath string, applicationID string
}
err := userTracker.increaseTrackedResource(queuePath, applicationID, usage)
if err != nil {
- log.Logger().Error("Problem in increasing the user resource usage",
+ log.Log(log.SchedUGM).Error("Problem in increasing the user resource usage",
zap.String("user", user.User),
zap.String("queue path", queuePath),
zap.String("application", applicationID),
@@ -165,7 +165,7 @@ func (m *Manager) IncreaseTrackedResource(queuePath string, applicationID string
if groupTracker != nil {
err = groupTracker.increaseTrackedResource(queuePath, applicationID, usage)
if err != nil {
- log.Logger().Error("Problem in increasing the group resource usage",
+ log.Log(log.SchedUGM).Error("Problem in increasing the group resource usage",
zap.String("user", user.User),
zap.String("group", group),
zap.String("queue path", queuePath),
@@ -183,13 +183,13 @@ func (m *Manager) IncreaseTrackedResource(queuePath string, applicationID string
// resource usage would be decreased against specific application. When the final asks release happens, removeApp should be set to true and
// application itself would be removed from the tracker and no more usage would be tracked further for that specific application.
func (m *Manager) DecreaseTrackedResource(queuePath string, applicationID string, usage *resources.Resource, user security.UserGroup, removeApp bool) error {
- log.Logger().Debug("Decreasing resource usage", zap.String("user", user.User),
+ log.Log(log.SchedUGM).Debug("Decreasing resource usage", zap.String("user", user.User),
zap.String("queue path", queuePath),
zap.String("application", applicationID),
zap.Stringer("resource", usage),
zap.Bool("removeApp", removeApp))
if queuePath == "" || applicationID == "" || usage == nil || user.User == "" {
- log.Logger().Error("Mandatory parameters are missing to decrease the resource usage",
+ log.Log(log.SchedUGM).Error("Mandatory parameters are missing to decrease the resource usage",
zap.String("user", user.User),
zap.String("queue path", queuePath),
zap.String("application", applicationID),
@@ -204,7 +204,7 @@ func (m *Manager) DecreaseTrackedResource(queuePath string, applicationID string
if userTracker != nil {
removeQT, err := userTracker.decreaseTrackedResource(queuePath, applicationID, usage, removeApp)
if err != nil {
- log.Logger().Error("Problem in decreasing the user resource usage",
+ log.Log(log.SchedUGM).Error("Problem in decreasing the user resource usage",
zap.String("user", user.User),
zap.String("queue path", queuePath),
zap.String("application", applicationID),
@@ -217,7 +217,7 @@ func (m *Manager) DecreaseTrackedResource(queuePath string, applicationID string
delete(m.userTrackers, user.User)
}
} else {
- log.Logger().Error("user tracker must be available in userTrackers map",
+ log.Log(log.SchedUGM).Error("user tracker must be available in userTrackers map",
zap.String("user", user.User))
return fmt.Errorf("user tracker for %s is missing in userTrackers map", user.User)
}
@@ -230,7 +230,7 @@ func (m *Manager) DecreaseTrackedResource(queuePath string, applicationID string
if groupTracker != nil {
removeQT, err := groupTracker.decreaseTrackedResource(queuePath, applicationID, usage, removeApp)
if err != nil {
- log.Logger().Error("Problem in decreasing the group resource usage",
+ log.Log(log.SchedUGM).Error("Problem in decreasing the group resource usage",
zap.String("user", user.User),
zap.String("group", group),
zap.String("queue path", queuePath),
@@ -244,7 +244,7 @@ func (m *Manager) DecreaseTrackedResource(queuePath string, applicationID string
delete(m.groupTrackers, group)
}
} else {
- log.Logger().Error("appGroupTrackers tracker must be available in groupTrackers map",
+ log.Log(log.SchedUGM).Error("appGroupTrackers tracker must be available in groupTrackers map",
zap.String("appGroupTrackers", group))
return fmt.Errorf("appGroupTrackers tracker for %s is missing in groupTrackers map", group)
}
@@ -318,7 +318,7 @@ func (m *Manager) ensureGroupTrackerForApp(queuePath string, applicationID strin
return err
}
if m.groupTrackers[group] == nil {
- log.Logger().Debug("Group tracker does not exist. Creating group tracker object and linking the same with application",
+ log.Log(log.SchedUGM).Debug("Group tracker does not exist. Creating group tracker object and linking the same with application",
zap.String("application", applicationID),
zap.String("queue path", queuePath),
zap.String("user", user.User),
@@ -327,12 +327,12 @@ func (m *Manager) ensureGroupTrackerForApp(queuePath string, applicationID strin
// Set the limits for all configured queue paths of the group
for configQueuePath, config := range m.groupLimitsConfig[group] {
- log.Logger().Debug("Setting the limit max applications settings.",
+ log.Log(log.SchedUGM).Debug("Setting the limit max applications settings.",
zap.String("group", group),
zap.String("queue path", configQueuePath))
maxApps, ok := config[maxapplications].(uint64)
if !ok {
- log.Logger().Warn("Problem in setting the limit max applications settings. Unable to cast the value from interface to uint64",
+ log.Log(log.SchedUGM).Warn("Problem in setting the limit max applications settings. Unable to cast the value from interface to uint64",
zap.String("group", group),
zap.String("queue path", configQueuePath),
zap.Uint64("limit max applications", maxApps))
@@ -340,7 +340,7 @@ func (m *Manager) ensureGroupTrackerForApp(queuePath string, applicationID strin
group, configQueuePath, applicationID)
}
if setMaxApplicationsErr := groupTracker.setMaxApplications(maxApps, configQueuePath); setMaxApplicationsErr != nil {
- log.Logger().Warn("Problem in setting the limit max applications settings.",
+ log.Log(log.SchedUGM).Warn("Problem in setting the limit max applications settings.",
zap.String("group", group),
zap.String("queue path", configQueuePath),
zap.Uint64("limit max applications", maxApps),
@@ -351,7 +351,7 @@ func (m *Manager) ensureGroupTrackerForApp(queuePath string, applicationID strin
maxResources, ok := config[maxresources].(map[string]string)
if !ok {
- log.Logger().Warn("Problem in setting the limit max resources settings. Unable to cast the value from interface to resource",
+ log.Log(log.SchedUGM).Warn("Problem in setting the limit max resources settings. Unable to cast the value from interface to resource",
zap.String("group", group),
zap.String("queue path", configQueuePath),
zap.Any("limit max resources", maxResources))
@@ -360,7 +360,7 @@ func (m *Manager) ensureGroupTrackerForApp(queuePath string, applicationID strin
}
resource, resourceErr := resources.NewResourceFromConf(maxResources)
if resourceErr != nil {
- log.Logger().Warn("Problem in setting the limit max resources settings.",
+ log.Log(log.SchedUGM).Warn("Problem in setting the limit max resources settings.",
zap.String("group", group),
zap.String("queue path", configQueuePath),
zap.Any("limit max resources", maxResources),
@@ -369,7 +369,7 @@ func (m *Manager) ensureGroupTrackerForApp(queuePath string, applicationID strin
group, configQueuePath, applicationID, resourceErr)
}
if setMaxResourcesErr := groupTracker.setMaxResources(resource, configQueuePath); setMaxResourcesErr != nil {
- log.Logger().Warn("Problem in setting the limit max resources settings.",
+ log.Log(log.SchedUGM).Warn("Problem in setting the limit max resources settings.",
zap.String("group", group),
zap.String("queue path", configQueuePath),
zap.Any("limit max resources", maxResources),
@@ -380,7 +380,7 @@ func (m *Manager) ensureGroupTrackerForApp(queuePath string, applicationID strin
}
m.groupTrackers[group] = groupTracker
} else {
- log.Logger().Debug("Group tracker already exists and linking (reusing) the same with application",
+ log.Log(log.SchedUGM).Debug("Group tracker already exists and linking (reusing) the same with application",
zap.String("application", applicationID),
zap.String("queue path", queuePath),
zap.String("user", user.User),
@@ -434,7 +434,7 @@ func (m *Manager) internalProcessConfig(cur configs.QueueConfig, queuePath strin
tempLimitsMap[maxresources] = limit.MaxResources
tempLimitsMap[maxapplications] = limit.MaxApplications
for _, user := range limit.Users {
- log.Logger().Debug("Processing user limits configuration",
+ log.Log(log.SchedUGM).Debug("Processing user limits configuration",
zap.String("user", user),
zap.String("limit", limit.Limit),
zap.String("queue path", queuePath),
@@ -447,7 +447,7 @@ func (m *Manager) internalProcessConfig(cur configs.QueueConfig, queuePath strin
}
}
for _, group := range limit.Groups {
- log.Logger().Debug("Processing group limits configuration",
+ log.Log(log.SchedUGM).Debug("Processing group limits configuration",
zap.String("group", group),
zap.String("limit", limit.Limit),
zap.String("queue path", queuePath),
@@ -481,7 +481,7 @@ func (m *Manager) processUserConfig(user string, limit configs.Limit, queuePath
for u, ut := range m.userTrackers {
// Is this user already tracked for the queue path?
if m.IsQueuePathTrackedCompletely(ut.queueTracker, queuePath) {
- log.Logger().Debug("Processing wild card user limits configuration for all existing users",
+ log.Log(log.SchedUGM).Debug("Processing wild card user limits configuration for all existing users",
zap.String("user", u),
zap.String("limit", limit.Limit),
zap.String("queue path", queuePath),
@@ -521,7 +521,7 @@ func (m *Manager) processGroupConfig(group string, limit configs.Limit, queuePat
for g, gt := range m.groupTrackers {
// Is this group already tracked for the queue path?
if m.IsQueuePathTrackedCompletely(gt.queueTracker, queuePath) {
- log.Logger().Debug("Processing wild card user limits configuration for all existing groups",
+ log.Log(log.SchedUGM).Debug("Processing wild card user limits configuration for all existing groups",
zap.String("group", g),
zap.String("limit", limit.Limit),
zap.String("queue path", queuePath),
@@ -590,7 +590,7 @@ func (m *Manager) clearEarlierSetLimits(userGroupLimits map[string]bool, queuePa
}
func (m *Manager) setUserLimits(user string, limit configs.Limit, queuePath string) error {
- log.Logger().Debug("Setting user limits",
+ log.Log(log.SchedUGM).Debug("Setting user limits",
zap.String("user", user),
zap.String("limit", limit.Limit),
zap.String("queue path", queuePath),
@@ -598,14 +598,14 @@ func (m *Manager) setUserLimits(user string, limit configs.Limit, queuePath stri
zap.Any("max resources", limit.MaxResources))
userTracker, ok := m.userTrackers[user]
if !ok {
- log.Logger().Debug("User tracker does not exist. Creating user tracker object to set the limit configuration",
+ log.Log(log.SchedUGM).Debug("User tracker does not exist. Creating user tracker object to set the limit configuration",
zap.String("user", user),
zap.String("queue path", queuePath))
userTracker = newUserTracker(user)
m.userTrackers[user] = userTracker
}
if err := userTracker.setMaxApplications(limit.MaxApplications, queuePath); err != nil {
- log.Logger().Warn("Problem in setting the limit max applications settings.",
+ log.Log(log.SchedUGM).Warn("Problem in setting the limit max applications settings.",
zap.String("user", user),
zap.String("queue path", queuePath),
zap.Uint64("limit max applications", limit.MaxApplications),
@@ -615,7 +615,7 @@ func (m *Manager) setUserLimits(user string, limit configs.Limit, queuePath stri
if resource, err := resources.NewResourceFromConf(limit.MaxResources); err == nil {
if err = userTracker.setMaxResources(resource, queuePath); err != nil {
- log.Logger().Warn("Problem in setting the limit max resources settings.",
+ log.Log(log.SchedUGM).Warn("Problem in setting the limit max resources settings.",
zap.String("user", user),
zap.String("queue path", queuePath),
zap.Any("limit max resources", limit.MaxResources),
@@ -623,7 +623,7 @@ func (m *Manager) setUserLimits(user string, limit configs.Limit, queuePath stri
return fmt.Errorf("unable to set the limit for user %s because %w", user, err)
}
} else {
- log.Logger().Warn("Problem in using the limit max resources settings.",
+ log.Log(log.SchedUGM).Warn("Problem in using the limit max resources settings.",
zap.String("user", user),
zap.String("queue path", queuePath),
zap.Any("limit max resources", limit.MaxResources),
@@ -634,7 +634,7 @@ func (m *Manager) setUserLimits(user string, limit configs.Limit, queuePath stri
}
func (m *Manager) setGroupLimits(group string, limit configs.Limit, queuePath string) error {
- log.Logger().Debug("Setting group limits",
+ log.Log(log.SchedUGM).Debug("Setting group limits",
zap.String("group", group),
zap.String("limit", limit.Limit),
zap.String("queue path", queuePath),
@@ -642,14 +642,14 @@ func (m *Manager) setGroupLimits(group string, limit configs.Limit, queuePath st
zap.Any("max resources", limit.MaxResources))
groupTracker, ok := m.groupTrackers[group]
if !ok {
- log.Logger().Debug("Group tracker does not exist. Creating group tracker object to set the limit configuration",
+ log.Log(log.SchedUGM).Debug("Group tracker does not exist. Creating group tracker object to set the limit configuration",
zap.String("group", group),
zap.String("queue path", queuePath))
groupTracker = newGroupTracker(group)
m.groupTrackers[group] = groupTracker
}
if err := groupTracker.setMaxApplications(limit.MaxApplications, queuePath); err != nil {
- log.Logger().Warn("Problem in setting the limit max applications settings.",
+ log.Log(log.SchedUGM).Warn("Problem in setting the limit max applications settings.",
zap.String("group", group),
zap.String("queue path", queuePath),
zap.Uint64("limit max applications", limit.MaxApplications),
@@ -659,7 +659,7 @@ func (m *Manager) setGroupLimits(group string, limit configs.Limit, queuePath st
if resource, err := resources.NewResourceFromConf(limit.MaxResources); err == nil {
if err = groupTracker.setMaxResources(resource, queuePath); err != nil {
- log.Logger().Warn("Problem in setting the limit max resources settings.",
+ log.Log(log.SchedUGM).Warn("Problem in setting the limit max resources settings.",
zap.String("group", group),
zap.String("queue path", queuePath),
zap.Any("limit max resources", limit.MaxResources),
@@ -667,7 +667,7 @@ func (m *Manager) setGroupLimits(group string, limit configs.Limit, queuePath st
return fmt.Errorf("unable to set the limit for group %s because %w", group, err)
}
} else {
- log.Logger().Warn("Problem in using the limit max resources settings.",
+ log.Log(log.SchedUGM).Warn("Problem in using the limit max resources settings.",
zap.String("group", group),
zap.String("queue path", queuePath),
zap.Any("limit max resources", limit.MaxResources),
diff --git a/pkg/scheduler/ugm/queue_tracker.go b/pkg/scheduler/ugm/queue_tracker.go
index 9113b7be..415ab3aa 100644
--- a/pkg/scheduler/ugm/queue_tracker.go
+++ b/pkg/scheduler/ugm/queue_tracker.go
@@ -43,7 +43,7 @@ func newRootQueueTracker() *QueueTracker {
}
func newQueueTracker(queueName string) *QueueTracker {
- log.Logger().Debug("Creating queue tracker object for queue",
+ log.Log(log.SchedUGM).Debug("Creating queue tracker object for queue",
zap.String("queue", queueName))
queueTracker := &QueueTracker{
queueName: queueName,
@@ -55,7 +55,7 @@ func newQueueTracker(queueName string) *QueueTracker {
}
func (qt *QueueTracker) increaseTrackedResource(queuePath string, applicationID string, usage *resources.Resource) error {
- log.Logger().Debug("Increasing resource usage",
+ log.Log(log.SchedUGM).Debug("Increasing resource usage",
zap.String("queue path", queuePath),
zap.String("application", applicationID),
zap.Stringer("resource", usage))
@@ -66,7 +66,7 @@ func (qt *QueueTracker) increaseTrackedResource(queuePath string, applicationID
qt.resourceUsage.AddTo(usage)
qt.runningApplications[applicationID] = true
- log.Logger().Debug("Successfully increased resource usage",
+ log.Log(log.SchedUGM).Debug("Successfully increased resource usage",
zap.String("queue path", queuePath),
zap.String("application", applicationID),
zap.Stringer("resource", usage),
@@ -87,7 +87,7 @@ func (qt *QueueTracker) increaseTrackedResource(queuePath string, applicationID
}
func (qt *QueueTracker) decreaseTrackedResource(queuePath string, applicationID string, usage *resources.Resource, removeApp bool) (bool, error) {
- log.Logger().Debug("Decreasing resource usage",
+ log.Log(log.SchedUGM).Debug("Decreasing resource usage",
zap.String("queue path", queuePath),
zap.String("application", applicationID),
zap.Stringer("resource", usage),
@@ -100,7 +100,7 @@ func (qt *QueueTracker) decreaseTrackedResource(queuePath string, applicationID
if removeApp {
delete(qt.runningApplications, applicationID)
}
- log.Logger().Debug("Successfully decreased resource usage",
+ log.Log(log.SchedUGM).Debug("Successfully decreased resource usage",
zap.String("queue path", queuePath),
zap.String("application", applicationID),
zap.Stringer("resource", usage),
@@ -118,7 +118,7 @@ func (qt *QueueTracker) decreaseTrackedResource(queuePath string, applicationID
delete(qt.childQueueTrackers, immediateChildQueueName)
}
} else {
- log.Logger().Error("Child queueTracker tracker must be available in child queues map",
+ log.Log(log.SchedUGM).Error("Child queueTracker tracker must be available in child queues map",
zap.String("child queueTracker name", immediateChildQueueName))
return false, fmt.Errorf("child queueTracker tracker for %s is missing in child queues map", immediateChildQueueName)
}
@@ -151,12 +151,12 @@ func (qt *QueueTracker) getChildQueueTracker(queuePath string) *QueueTracker {
}
func (qt *QueueTracker) setMaxApplications(count uint64, queuePath string) error {
- log.Logger().Debug("Setting max applications",
+ log.Log(log.SchedUGM).Debug("Setting max applications",
zap.String("queue path", queuePath),
zap.Uint64("max applications", count))
childQueueTracker := qt.getChildQueueTracker(queuePath)
if childQueueTracker.maxRunningApps != 0 && count != 0 && len(childQueueTracker.runningApplications) > int(count) {
- log.Logger().Warn("Current running applications is greater than config max applications",
+ log.Log(log.SchedUGM).Warn("Current running applications is greater than config max applications",
zap.String("queue path", queuePath),
zap.Uint64("current max applications", childQueueTracker.maxRunningApps),
zap.Int("total running applications", len(childQueueTracker.runningApplications)),
@@ -169,12 +169,12 @@ func (qt *QueueTracker) setMaxApplications(count uint64, queuePath string) error
}
func (qt *QueueTracker) setMaxResources(resource *resources.Resource, queuePath string) error {
- log.Logger().Debug("Setting max resources",
+ log.Log(log.SchedUGM).Debug("Setting max resources",
zap.String("queue path", queuePath),
zap.String("max resources", resource.String()))
childQueueTracker := qt.getChildQueueTracker(queuePath)
if (!resources.Equals(childQueueTracker.maxResourceUsage, resources.NewResource()) && !resources.Equals(resource, resources.NewResource())) && resources.StrictlyGreaterThan(childQueueTracker.resourceUsage, resource) {
- log.Logger().Warn("Current resource usage is greater than config max resource",
+ log.Log(log.SchedUGM).Warn("Current resource usage is greater than config max resource",
zap.String("queue path", queuePath),
zap.String("current max resource usage", childQueueTracker.maxResourceUsage.String()),
zap.String("total resource usage", childQueueTracker.resourceUsage.String()),
diff --git a/pkg/trace/scheduler_tracer.go b/pkg/trace/scheduler_tracer.go
index a5c12e67..84933e1c 100644
--- a/pkg/trace/scheduler_tracer.go
+++ b/pkg/trace/scheduler_tracer.go
@@ -64,7 +64,7 @@ func (s *SchedulerTracerImpl) SetParams(params *SchedulerTracerImplParams) {
return
}
if params.Mode == DebugWithFilter && len(params.FilterTags) == 0 {
- log.Logger().Warn("FilterTags is empty while trying to run in DebugWithFilter mode." +
+ log.Log(log.OpenTracing).Warn("FilterTags is empty while trying to run in DebugWithFilter mode." +
" Please use Debug mode instead.")
}
s.Lock()
diff --git a/pkg/trace/utils.go b/pkg/trace/utils.go
index 49289e41..327a73fb 100644
--- a/pkg/trace/utils.go
+++ b/pkg/trace/utils.go
@@ -54,7 +54,7 @@ func NewConstTracer(serviceName string, collect bool) (opentracing.Tracer, io.Cl
},
}
return cfg.NewTracer(
- jaegercfg.Logger(zap.NewLogger(log.Logger().Named(serviceName))),
+ jaegercfg.Logger(zap.NewLogger(log.Log(log.OpenTracing).Named(serviceName))),
jaegercfg.Metrics(metrics.NullFactory),
)
}
@@ -73,7 +73,7 @@ func NewTracerFromEnv(serviceName string) (opentracing.Tracer, io.Closer, error)
// frameworks.
// Initialize tracer with a logger and a metrics factory
return cfg.NewTracer(
- jaegercfg.Logger(zap.NewLogger(log.Logger().Named(cfg.ServiceName))),
+ jaegercfg.Logger(zap.NewLogger(log.Log(log.OpenTracing).Named(cfg.ServiceName))),
jaegercfg.Metrics(metrics.NullFactory),
)
}
diff --git a/pkg/webservice/handlers.go b/pkg/webservice/handlers.go
index 1bdabc30..a311d837 100644
--- a/pkg/webservice/handlers.go
+++ b/pkg/webservice/handlers.go
@@ -70,7 +70,7 @@ func getStackInfo(w http.ResponseWriter, r *http.Request) {
}
}
if _, err := w.Write(stack()); err != nil {
- log.Logger().Error("GetStackInfo error", zap.Error(err))
+ log.Log(log.REST).Error("GetStackInfo error", zap.Error(err))
buildJSONErrorResponse(w, err.Error(), http.StatusInternalServerError)
}
}
@@ -129,7 +129,7 @@ func buildJSONErrorResponse(w http.ResponseWriter, detail string, code int) {
w.WriteHeader(code)
errorInfo := dao.NewYAPIError(nil, code, detail)
if jsonErr := json.NewEncoder(w).Encode(errorInfo); jsonErr != nil {
- log.Logger().Error(fmt.Sprintf("Problem in sending error response in JSON format. Error response: %s", detail))
+ log.Log(log.REST).Error(fmt.Sprintf("Problem in sending error response in JSON format. Error response: %s", detail))
}
}
@@ -448,16 +448,16 @@ func checkHealthStatus(w http.ResponseWriter, r *http.Request) {
result := schedulerContext.GetLastHealthCheckResult()
if result != nil {
if !result.Healthy {
- log.Logger().Error("Scheduler is not healthy", zap.Any("health check info", *result))
+ log.Log(log.SchedHealth).Error("Scheduler is not healthy", zap.Any("health check info", *result))
buildJSONErrorResponse(w, "Scheduler is not healthy", http.StatusServiceUnavailable)
} else {
- log.Logger().Info("Scheduler is healthy", zap.Any("health check info", *result))
+ log.Log(log.SchedHealth).Info("Scheduler is healthy", zap.Any("health check info", *result))
if err := json.NewEncoder(w).Encode(result); err != nil {
buildJSONErrorResponse(w, err.Error(), http.StatusInternalServerError)
}
}
} else {
- log.Logger().Info("The healthy status of scheduler is not found", zap.Any("health check info", ""))
+ log.Log(log.SchedHealth).Info("The healthy status of scheduler is not found", zap.Any("health check info", ""))
buildJSONErrorResponse(w, "The healthy status of scheduler is not found", http.StatusNotFound)
}
}
@@ -469,7 +469,7 @@ func buildUpdateResponse(err error, w http.ResponseWriter) {
buildJSONErrorResponse(w, err.Error(), http.StatusInternalServerError)
}
} else {
- log.Logger().Info("Configuration update failed with errors",
+ log.Log(log.REST).Info("Configuration update failed with errors",
zap.Error(err))
buildJSONErrorResponse(w, err.Error(), http.StatusConflict)
}
@@ -623,12 +623,12 @@ func getApplication(w http.ResponseWriter, r *http.Request) {
func setLogLevel(w http.ResponseWriter, r *http.Request) {
writeHeaders(w)
- log.Logger().Warn("Setting log levels via the REST API is deprecated. The /ws/v1/loglevel endpoint will be removed in a future release.")
+ log.Log(log.Deprecation).Warn("Setting log levels via the REST API is deprecated. The /ws/v1/loglevel endpoint will be removed in a future release.")
}
func getLogLevel(w http.ResponseWriter, r *http.Request) {
writeHeaders(w)
- log.Logger().Warn("Getting log levels via the REST API is deprecated. The /ws/v1/loglevel endpoint will be removed in a future release.")
+ log.Log(log.Deprecation).Warn("Getting log levels via the REST API is deprecated. The /ws/v1/loglevel endpoint will be removed in a future release.")
if _, err := w.Write([]byte("info")); err != nil {
buildJSONErrorResponse(w, err.Error(), http.StatusInternalServerError)
}
@@ -779,14 +779,14 @@ func getResourceManagerDiagnostics() map[string]interface{} {
dumpStr, err := plugin.GetStateDump()
if err != nil {
// might be not implemented
- log.Logger().Debug("Unable to get RM state dump", zap.Error(err))
+ log.Log(log.REST).Debug("Unable to get RM state dump", zap.Error(err))
result["Error"] = err.Error()
return result
}
// convert to JSON map
if err = json.Unmarshal([]byte(dumpStr), &result); err != nil {
- log.Logger().Warn("Unable to parse RM state dump", zap.Error(err))
+ log.Log(log.REST).Warn("Unable to parse RM state dump", zap.Error(err))
result["Error"] = err.Error()
}
diff --git a/pkg/webservice/state_dump.go b/pkg/webservice/state_dump.go
index 1c605f0f..54c462ed 100644
--- a/pkg/webservice/state_dump.go
+++ b/pkg/webservice/state_dump.go
@@ -58,7 +58,7 @@ func getFullStateDump(w http.ResponseWriter, r *http.Request) {
func handlePeriodicStateDump(w http.ResponseWriter, r *http.Request) {
writeHeaders(w)
- yunikornLog.Logger().Warn("Periodic state dumps are no longer supported. The /ws/v1/periodicstatedump endpoint will be removed in a future release.")
+ yunikornLog.Log(yunikornLog.Deprecation).Warn("Periodic state dumps are no longer supported. The /ws/v1/periodicstatedump endpoint will be removed in a future release.")
}
func doStateDump(w io.Writer) error {
diff --git a/pkg/webservice/webservice.go b/pkg/webservice/webservice.go
index 0a285768..05e56eca 100644
--- a/pkg/webservice/webservice.go
+++ b/pkg/webservice/webservice.go
@@ -54,7 +54,7 @@ func loggingHandler(inner http.Handler, name string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
inner.ServeHTTP(w, r)
- log.Logger().Debug("Web router call details",
+ log.Log(log.REST).Debug("Web router call details",
zap.String("name", name),
zap.String("method", r.Method),
zap.String("uri", r.RequestURI),
@@ -67,11 +67,11 @@ func (m *WebService) StartWebApp() {
router := newRouter()
m.httpServer = &http.Server{Addr: ":9080", Handler: router}
- log.Logger().Info("web-app started", zap.Int("port", 9080))
+ log.Log(log.REST).Info("web-app started", zap.Int("port", 9080))
go func() {
httpError := m.httpServer.ListenAndServe()
if httpError != nil && httpError != http.ErrServerClosed {
- log.Logger().Error("HTTP serving error",
+ log.Log(log.REST).Error("HTTP serving error",
zap.Error(httpError))
}
}()
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@yunikorn.apache.org
For additional commands, e-mail: issues-help@yunikorn.apache.org