Skip to content

Commit 22d82c1

Browse files
mitdesaipbacsko
authored andcommitted
[YUNIKORN-656] Add LDAP resolver for group resolution (apache#1021)
Closes: apache#1021 Signed-off-by: Peter Bacsko <[email protected]>
1 parent ceb8ca5 commit 22d82c1

15 files changed

+3216
-289
lines changed

go.mod

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ toolchain go1.23.7
2525

2626
require (
2727
github.com/apache/yunikorn-scheduler-interface v0.0.0-20251021140208-d3b357b98dcd
28+
github.com/go-ldap/ldap/v3 v3.4.11
2829
github.com/google/btree v1.1.3
2930
github.com/google/go-cmp v0.7.0
3031
github.com/google/uuid v1.6.0
@@ -44,13 +45,16 @@ require (
4445
)
4546

4647
require (
48+
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 // indirect
4749
github.com/beorn7/perks v1.0.1 // indirect
4850
github.com/cespare/xxhash/v2 v2.3.0 // indirect
4951
github.com/davecgh/go-spew v1.1.1 // indirect
52+
github.com/go-asn1-ber/asn1-ber v1.5.8-0.20250403174932-29230038a667 // indirect
5053
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
5154
github.com/petermattis/goid v0.0.0-20250813065127-a731cc31b4fe // indirect
5255
github.com/prometheus/procfs v0.12.0 // indirect
5356
go.uber.org/multierr v1.10.0 // indirect
57+
golang.org/x/crypto v0.41.0 // indirect
5458
golang.org/x/sys v0.35.0 // indirect
5559
golang.org/x/text v0.28.0 // indirect
5660
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect

go.sum

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 h1:mFRzDkZVAjdal+s7s0MwaRv9igoPqLRdzOLzw/8Xvq8=
2+
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU=
3+
github.com/alexbrainman/sspi v0.0.0-20231016080023-1a75b4708caa h1:LHTHcTQiSGT7VVbI0o4wBRNQIgn917usHWOd6VAffYI=
4+
github.com/alexbrainman/sspi v0.0.0-20231016080023-1a75b4708caa/go.mod h1:cEWa1LVoE5KvSD9ONXsZrj0z6KqySlCCNKHlLzbqAt4=
15
github.com/apache/yunikorn-scheduler-interface v0.0.0-20251021140208-d3b357b98dcd h1:7HA8EmjMbw81fQpRDRtLAt2i96PKG080ure1V8Bl7K4=
26
github.com/apache/yunikorn-scheduler-interface v0.0.0-20251021140208-d3b357b98dcd/go.mod h1:fQPKbRdD2fYEjjJG9Gjop95NG2/DoJb939XXSxiuu10=
37
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
@@ -6,6 +10,10 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF
610
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
711
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
812
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
13+
github.com/go-asn1-ber/asn1-ber v1.5.8-0.20250403174932-29230038a667 h1:BP4M0CvQ4S3TGls2FvczZtj5Re/2ZzkV9VwqPHH/3Bo=
14+
github.com/go-asn1-ber/asn1-ber v1.5.8-0.20250403174932-29230038a667/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
15+
github.com/go-ldap/ldap/v3 v3.4.11 h1:4k0Yxweg+a3OyBLjdYn5OKglv18JNvfDykSoI8bW0gU=
16+
github.com/go-ldap/ldap/v3 v3.4.11/go.mod h1:bY7t0FLK8OAVpp/vV6sSlpz3EQDGcQwc8pF0ujLgKvM=
917
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
1018
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
1119
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
@@ -18,6 +26,20 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
1826
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
1927
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
2028
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
29+
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
30+
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
31+
github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8=
32+
github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs=
33+
github.com/jcmturner/dnsutils/v2 v2.0.0 h1:lltnkeZGL0wILNvrNiVCR6Ro5PGU/SeBvVO/8c/iPbo=
34+
github.com/jcmturner/dnsutils/v2 v2.0.0/go.mod h1:b0TnjGOvI/n42bZa+hmXL+kFJZsFT7G4t3HTlQ184QM=
35+
github.com/jcmturner/gofork v1.7.6 h1:QH0l3hzAU1tfT3rZCnW5zXl+orbkNMMRGJfdJjHVETg=
36+
github.com/jcmturner/gofork v1.7.6/go.mod h1:1622LH6i/EZqLloHfE7IeZ0uEJwMSUyQ/nDd82IeqRo=
37+
github.com/jcmturner/goidentity/v6 v6.0.1 h1:VKnZd2oEIMorCTsFBnJWbExfNN7yZr3EhJAxwOkZg6o=
38+
github.com/jcmturner/goidentity/v6 v6.0.1/go.mod h1:X1YW3bgtvwAXju7V3LCIMpY0Gbxyjn/mY9zx4tFonSg=
39+
github.com/jcmturner/gokrb5/v8 v8.4.4 h1:x1Sv4HaTpepFkXbt2IkL29DXRf8sOfZXo8eRKh687T8=
40+
github.com/jcmturner/gokrb5/v8 v8.4.4/go.mod h1:1btQEpgT6k+unzCwX1KdWMEwPPkkgBtP+F6aCACiMrs=
41+
github.com/jcmturner/rpc/v2 v2.0.3 h1:7FXXj8Ti1IaVFpSAziCZWNzbNuZmnvw/i6CqLNdWfZY=
42+
github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc=
2143
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
2244
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
2345
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
@@ -66,6 +88,8 @@ go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
6688
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
6789
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
6890
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
91+
golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs=
92+
golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ=
6993
golang.org/x/exp v0.0.0-20250228200357-dead58393ab7 h1:aWwlzYV971S4BXRS9AmqwDLAD85ouC6X+pocatKY58c=
7094
golang.org/x/exp v0.0.0-20250228200357-dead58393ab7/go.mod h1:BHOTPb3L19zxehTsLoJXVaTktb06DFgmdW6Wb9s8jqk=
7195
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=

pkg/common/configs/config.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,19 @@ type SchedulerConfig struct {
4545
// - a list of placement rule definition objects
4646
// - a list of users specifying limits on the partition
4747
// - the preemption configuration for the partition
48+
// - user group resolver type (os, ldap, "")
4849
type PartitionConfig struct {
49-
Name string
50-
Queues []QueueConfig
51-
PlacementRules []PlacementRule `yaml:",omitempty" json:",omitempty"`
52-
Limits []Limit `yaml:",omitempty" json:",omitempty"`
53-
Preemption PartitionPreemptionConfig `yaml:",omitempty" json:",omitempty"`
54-
NodeSortPolicy NodeSortingPolicy `yaml:",omitempty" json:",omitempty"`
50+
Name string
51+
Queues []QueueConfig
52+
PlacementRules []PlacementRule `yaml:",omitempty" json:",omitempty"`
53+
Limits []Limit `yaml:",omitempty" json:",omitempty"`
54+
Preemption PartitionPreemptionConfig `yaml:",omitempty" json:",omitempty"`
55+
NodeSortPolicy NodeSortingPolicy `yaml:",omitempty" json:",omitempty"`
56+
UserGroupResolver UserGroupResolver `yaml:",omitempty" json:",omitempty"`
57+
}
58+
59+
type UserGroupResolver struct {
60+
Type string `yaml:"type,omitempty" json:"type,omitempty"`
5561
}
5662

5763
// The partition preemption configuration

pkg/common/configs/config_test.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,3 +2181,53 @@ partitions:
21812181
_, err = CreateConfig(data)
21822182
assert.ErrorContains(t, err, "group * max resource map[memory:90000 vcore:100000] of queue leaf is greater than immediate or ancestor parent maximum resource map[memory:10000 vcore:10000000]")
21832183
}
2184+
2185+
// TestUserGroupResolverConfig: tests the user group resolver configuration
2186+
func TestUserGroupResolverConfig(t *testing.T) {
2187+
data := `
2188+
partitions:
2189+
-
2190+
name: default
2191+
usergroupresolver:
2192+
type: ldap
2193+
placementrules:
2194+
- name: tag
2195+
value: namespace
2196+
create: true
2197+
queues:
2198+
- name: root
2199+
submitacl: '*'
2200+
properties:
2201+
application.sort.policy: fifo
2202+
sample: value2
2203+
`
2204+
// validate the config and check after the update
2205+
config, err := CreateConfig(data)
2206+
assert.NilError(t, err)
2207+
2208+
// check if the user group resolver is set correctly
2209+
assert.Equal(t, "ldap", config.Partitions[0].UserGroupResolver.Type)
2210+
2211+
// partition with no user group resolver
2212+
data = `
2213+
partitions:
2214+
-
2215+
name: default
2216+
placementrules:
2217+
- name: tag
2218+
value: namespace
2219+
create: true
2220+
queues:
2221+
- name: root
2222+
submitacl: '*'
2223+
properties:
2224+
application.sort.policy: fifo
2225+
sample: value2
2226+
`
2227+
// validate the config and check after the update
2228+
config, err = CreateConfig(data)
2229+
assert.NilError(t, err)
2230+
2231+
// check if the user group resolver is set to empty
2232+
assert.Equal(t, "", config.Partitions[0].UserGroupResolver.Type)
2233+
}

pkg/common/constants.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,32 @@ const (
2929
RecoveryQueue = "@recovery@"
3030
RecoveryQueueFull = "root." + RecoveryQueue
3131
DefaultPlacementQueue = "root.default"
32+
LdapHost = "Host"
33+
LdapPort = "Port"
34+
LdapBaseDN = "BaseDN"
35+
LdapFilter = "Filter"
36+
LdapGroupAttr = "GroupAttr"
37+
LdapReturnAttr = "ReturnAttr"
38+
LdapBindUser = "BindUser"
39+
LdapBindPassword = "BindPassword"
40+
LdapInsecure = "Insecure"
41+
LdapSSL = "SSL"
42+
)
43+
44+
const (
45+
DefaultLdapHost = "localhost"
46+
DefaultLdapPort = 389
47+
DefaultLdapBaseDN = "dc=example,dc=com"
48+
DefaultLdapFilter = "(&(sAMAccountName=%s))"
49+
DefaultLdapGroupAttr = "memberOf"
50+
DefaultLdapBindUser = "admin"
51+
DefaultLdapBindPassword = "admin"
52+
DefaultLdapInsecure = false
53+
DefaultLdapSSL = false
54+
DefaultLdapUserUID = "1211"
55+
)
56+
57+
var (
58+
LdapMountPath = "/run/secrets/ldap"
59+
DefaultLdapReturnAttr = []string{"memberOf"}
3260
)

0 commit comments

Comments
 (0)