-
Notifications
You must be signed in to change notification settings - Fork 546
/
resourcemanager_util.go
36 lines (31 loc) · 1.22 KB
/
resourcemanager_util.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package resourcemanager
import (
"context"
rmConfig "github.com/flyteorg/flyte/flytepropeller/pkg/controller/nodes/task/resourcemanager/config"
"github.com/flyteorg/flyte/flytestdlib/logger"
"github.com/flyteorg/flyte/flytestdlib/promutils"
)
const (
resourceManagerPrometheusScope = "resourcemanager"
redisResourceManagerPrometheusScope = "redis"
)
func GetResourceManagerBuilderByType(ctx context.Context, managerType rmConfig.Type, scope promutils.Scope) (
Builder, error) {
rmScope := scope.NewSubScope(resourceManagerPrometheusScope)
switch managerType {
case rmConfig.TypeNoop:
logger.Infof(ctx, "Using the NOOP resource manager")
return &NoopResourceManagerBuilder{}, nil
case rmConfig.TypeRedis:
logger.Infof(ctx, "Using Redis based resource manager")
config := rmConfig.GetConfig()
redisClient, err := NewRedisClient(ctx, config.RedisConfig)
if err != nil {
logger.Errorf(ctx, "Unable to initialize a redis client for the resource manager: [%v]", err)
return nil, err
}
return NewRedisResourceManagerBuilder(ctx, redisClient, rmScope.NewSubScope(redisResourceManagerPrometheusScope))
}
logger.Infof(ctx, "Using the NOOP resource manager by default")
return &NoopResourceManagerBuilder{}, nil
}