Skip to content

Commit ab5576a

Browse files
committed
Merge branch 'custom-roles' into feature/mk-custom-roles-telemetry
# Conflicts: # go.sum
2 parents 09bf09c + 8053895 commit ab5576a

File tree

97 files changed

+1986
-743
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+1986
-743
lines changed

.evergreen-functions.yml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,6 @@ functions:
160160
- ${workdir}/bin
161161
binary: scripts/evergreen/setup_kind.sh
162162

163-
setup_docker_datadir: &setup_docker_datadir
164-
command: subprocess.exec
165-
type: setup
166-
params:
167-
working_dir: src/github.com/mongodb/mongodb-kubernetes
168-
binary: scripts/evergreen/configure-docker-datadir.sh
169-
170163
setup_preflight:
171164
- command: subprocess.exec
172165
type: setup
@@ -227,6 +220,15 @@ functions:
227220
- ${workdir}/bin
228221
binary: scripts/dev/configure_docker_auth.sh
229222

223+
setup_evg_host: &setup_evg_host
224+
command: subprocess.exec
225+
type: setup
226+
params:
227+
working_dir: src/github.com/mongodb/mongodb-kubernetes
228+
add_to_path:
229+
- ${workdir}/bin
230+
binary: scripts/dev/setup_evg_host.sh
231+
230232
lint_repo:
231233
- command: subprocess.exec
232234
type: setup
@@ -249,7 +251,7 @@ functions:
249251
- *switch_context
250252
- *setup_aws
251253
- *configure_docker_auth
252-
- *setup_docker_datadir
254+
- *setup_evg_host
253255
- *python_venv
254256

255257
prune_docker_resources:
@@ -447,7 +449,20 @@ functions:
447449
aws_secret: ${enterprise_aws_secret_access_key}
448450
local_files_include_filter:
449451
- src/github.com/mongodb/mongodb-kubernetes/public/architectures/**/*.log
452+
- src/github.com/mongodb/mongodb-kubernetes/docs/**/*.log
453+
remote_file: logs/${task_id}/${execution}/
454+
bucket: operator-e2e-artifacts
455+
permissions: private
456+
visibility: signed
457+
content_type: text/plain
458+
- command: s3.put
459+
params:
460+
aws_key: ${enterprise_aws_access_key_id}
461+
aws_secret: ${enterprise_aws_secret_access_key}
462+
local_files_include_filter:
450463
- src/github.com/mongodb/mongodb-kubernetes/public/architectures/**/*.out
464+
- src/github.com/mongodb/mongodb-kubernetes/docs/**/*.out
465+
preserve_path: true
451466
remote_file: logs/${task_id}/${execution}/
452467
bucket: operator-e2e-artifacts
453468
permissions: private

.evergreen.yml

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ patch_aliases:
216216
variant_tags: [ "release_all_agents_manually" ]
217217
task: ".*"
218218
- alias: "release"
219-
variant_tags: [ "release" ]
220-
task_tags: [ "image_release", "image_preflight", "openshift_bundles", "code_snippets" ]
219+
variant_tags: [ "release", "e2e_smoke_release_test_suite" ]
220+
task_tags: [ "image_release", "image_preflight", "openshift_bundles", "code_snippets", "patch-run" ]
221221
- alias: "smoke_test_release"
222222
variant_tags: [ "e2e_smoke_release_test_suite" ]
223223
task_tags: [ "patch-run" ]
@@ -247,8 +247,8 @@ github_checks_aliases:
247247
# Triggered on git tag
248248
git_tag_aliases:
249249
- git_tag: "^(\\d+\\.)?(\\d+\\.)?(\\d+)$"
250-
variant_tags: [ "release" ]
251-
task_tags: [ "image_release", "image_preflight", "openshift_bundles", "code_snippets" ]
250+
variant_tags: [ "release", "e2e_smoke_release_test_suite" ]
251+
task_tags: [ "image_release", "image_preflight", "openshift_bundles", "code_snippets", "patch-run" ]
252252

253253
tasks:
254254
- name: unit_tests_golang
@@ -587,7 +587,6 @@ tasks:
587587
- func: clone
588588
- func: setup_aws
589589
- func: configure_docker_auth
590-
- func: quay_login
591590
- func: setup_prepare_openshift_bundles
592591
- func: prepare_openshift_bundles
593592
- func: update_evergreen_expansions
@@ -1390,9 +1389,10 @@ buildvariants:
13901389

13911390
- name: e2e_smoke
13921391
display_name: e2e_smoke
1393-
tags: [ "e2e_test_suite" ]
1392+
tags: [ "e2e_test_suite", "e2e_smoke_release_test_suite" ]
13941393
run_on:
13951394
- ubuntu2204-large
1395+
allowed_requesters: [ "patch", "github_tag" ]
13961396
depends_on:
13971397
- name: build_test_image
13981398
variant: init_test_run
@@ -1401,30 +1401,7 @@ buildvariants:
14011401

14021402
- name: e2e_static_smoke
14031403
display_name: e2e_static_smoke
1404-
tags: [ "e2e_test_suite" ]
1405-
run_on:
1406-
- ubuntu2204-large
1407-
depends_on:
1408-
- name: build_test_image
1409-
variant: init_test_run
1410-
tasks:
1411-
- name: e2e_smoke_task_group
1412-
1413-
- name: e2e_smoke_release
1414-
display_name: e2e_smoke_release
1415-
tags: [ "e2e_smoke_release_test_suite" ]
1416-
run_on:
1417-
- ubuntu2204-large
1418-
allowed_requesters: [ "patch", "github_tag" ]
1419-
depends_on:
1420-
- name: build_test_image
1421-
variant: init_test_run
1422-
tasks:
1423-
- name: e2e_smoke_task_group
1424-
1425-
- name: e2e_static_smoke_release
1426-
display_name: e2e_static_smoke_release
1427-
tags: [ "e2e_smoke_release_test_suite" ]
1404+
tags: [ "e2e_test_suite", "e2e_smoke_release_test_suite" ]
14281405
run_on:
14291406
- ubuntu2204-large
14301407
allowed_requesters: [ "patch", "github_tag" ]
@@ -1863,13 +1840,30 @@ buildvariants:
18631840

18641841
- name: private_kind_code_snippets
18651842
display_name: private_kind_code_snippets
1866-
allowed_requesters: ["patch"]
1843+
tags: [ "e2e_test_suite" ]
1844+
allowed_requesters: ["patch", "github_pr"]
18671845
run_on:
18681846
- ubuntu2204-large
18691847
<<: *base_om8_dependency
18701848
tasks:
18711849
- name: kind_code_snippets_task_group
18721850

1851+
- name: prerelease_kind_code_snippets
1852+
display_name: prerelease_kind_code_snippets
1853+
allowed_requesters: ["patch"]
1854+
run_on:
1855+
- ubuntu2204-large
1856+
tasks:
1857+
- name: kind_code_snippets_task_group
1858+
1859+
- name: public_kind_code_snippets
1860+
display_name: public_kind_code_snippets
1861+
allowed_requesters: ["patch"]
1862+
run_on:
1863+
- ubuntu2204-large
1864+
tasks:
1865+
- name: kind_code_snippets_task_group
1866+
18731867
### Build variants for manual patch only
18741868

18751869
- name: publish_om60_images

.githooks/pre-commit

Lines changed: 43 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
set -Eeou pipefail
44

55
source scripts/dev/set_env_context.sh
6+
source scripts/funcs/printing
7+
68
if [ -f "${PROJECT_DIR}"/venv/bin/activate ]; then
79
source "${PROJECT_DIR}"/venv/bin/activate
810
fi
@@ -107,55 +109,64 @@ function update_release_json() {
107109
git add release.json
108110
}
109111

110-
function pre_commit() {
111-
# Update release.json first in case there is a newer version
112-
update_release_json
113-
# Generate operator manifests (CRDs, etc)
114-
generate_manifests
115-
# We need to generate the values files first
116-
update_values_yaml_files
117-
# The values files are used for generating the standalone yaml
118-
generate_standalone_yaml
119-
# Run black on python files that have changed
120-
python_formatting
121-
# Generate MCO evergreen tests
122-
update_mco_tests
123-
124-
source scripts/evergreen/lint_code.sh
112+
function regenerate_public_rbac_multi_cluster() {
113+
if echo "$git_last_changed" | grep -q 'public/tools/multicluster'; then
114+
echo 'regenerating multicluster RBAC public example'
115+
pushd public/tools/multicluster
116+
EXPORT_RBAC_SAMPLES="true" go test -run TestPrintingOutRolesServiceAccountsAndRoleBindings
117+
popd
118+
git add public/samples/multi-cluster-cli-gitops
119+
fi
120+
}
125121

126-
echo 'regenerating licenses.csv'
127-
scripts/evergreen/update_licenses.sh
128-
git add LICENSE-THIRD-PARTY
122+
function update_licenses() {
123+
echo 'regenerating licenses'
124+
time scripts/evergreen/update_licenses.sh 2>&1 | prepend "update_licenses"
125+
git add LICENSE-THIRD-PARTY
126+
}
129127

130-
if echo "$git_last_changed" | grep -q 'public/tools/multicluster'; then
131-
echo 'regenerating multicluster RBAC public example'
132-
pushd public/tools/multicluster
133-
EXPORT_RBAC_SAMPLES="true" go test -run TestPrintingOutRolesServiceAccountsAndRoleBindings
134-
popd
135-
git add public/samples/multi-cluster-cli-gitops
128+
function check_erroneous_kubebuilder_annotations() {
129+
# Makes sure there are not erroneous kubebuilder annotations that can
130+
# end up in CRDs as descriptions.
131+
if grep "// kubebuilder" ./* -r --exclude-dir=vendor --include=\*.go; then
132+
echo "Found an erroneous kubebuilder annotation"
133+
exit 1
136134
fi
135+
}
137136

137+
function check_incorrect_makefile_variable_brackets() {
138138
if find . -name "Makefile" | grep -v vendor | xargs grep "\${"; then
139139
echo 'ERROR: Makefiles should NEVER contain curly brackets variables'
140140
exit 1
141141
fi
142+
}
142143

143-
# Makes sure there are not erroneous kubebuilder annotations that can
144-
# end up in CRDs as descriptions.
145-
if grep "// kubebuilder" ./* -r --exclude-dir=vendor --include=\*.go; then
146-
echo "Found an erroneous kubebuilder annotation"
147-
exit 1
148-
fi
144+
function pre_commit() {
145+
# Update release.json first in case there is a newer version
146+
(time update_release_json) 2>&1 | prepend "update_release_json"
147+
# We need to generate the values files first
148+
(time update_values_yaml_files) 2>&1 | prepend "update_values_yaml_files"
149+
# The values files are used for generating the standalone yaml
150+
(time generate_standalone_yaml) 2>&1 | prepend "generate_standalone_yaml"
151+
# Run black on python files that have changed
152+
(time python_formatting) 2>&1 | prepend "python_formatting"
149153

150-
start_shellcheck
154+
(time regenerate_public_rbac_multi_cluster) 2>&1 | prepend "regenerate_public_rbac_multi_cluster"
155+
156+
(time start_shellcheck) 2>&1 | prepend "shellcheck"
157+
158+
(time check_erroneous_kubebuilder_annotations) 2>&1 | prepend "check_erroneous_kubebuilder_annotations"
159+
160+
(time scripts/evergreen/lint_code.sh) 2>&1 | prepend "lint_code.sh"
151161

162+
(time update_licenses) 2>&1 | prepend "update_licenses"
152163
}
153164

154165
# Function to run shellcheck on a single file
155166
run_shellcheck() {
156167
local file="$1"
157168
echo "Running shellcheck on $file"
158-
if ! shellcheck -x "$file" -e SC2154 -e SC1091 -e SC1090 -e SC2148 -o require-variable-braces -P "scripts"; then
169+
if ! shellcheck --color=always -x "$file" -e SC2154 -e SC1091 -e SC1090 -e SC2148 -o require-variable-braces -P "scripts"; then
159170
echo "shellcheck failed on $file"
160171
exit 1
161172
fi

.github/dependabot.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,27 @@ updates:
55
schedule:
66
interval: weekly
77
day: monday
8+
groups:
9+
go-deps:
10+
applies-to: "version-updates"
11+
patterns:
12+
- "*"
813
ignore:
914
- dependency-name: k8s.io/api
1015
- dependency-name: k8s.io/apimachinery
1116
- dependency-name: k8s.io/client-go
1217
- dependency-name: k8s.io/code-generator
1318
- dependency-name: sigs.k8s.io/controller-runtime
19+
1420
- package-ecosystem: pip
1521
directory: "/"
1622
schedule:
1723
interval: weekly
1824
day: monday
25+
groups:
26+
pip-deps:
27+
applies-to: "version-updates"
28+
patterns:
29+
- "*"
30+
ignore:
31+
- dependency-name: kubernetes

LICENSE-THIRD-PARTY

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ github.com/prometheus/common,v0.62.0,https://github.com/prometheus/common/blob/v
5050
github.com/prometheus/procfs,v0.15.1,https://github.com/prometheus/procfs/blob/v0.15.1/LICENSE,Apache-2.0
5151
github.com/r3labs/diff/v3,v3.0.1,https://github.com/r3labs/diff/blob/v3.0.1/LICENSE,MPL-2.0
5252
github.com/ryanuber/go-glob,v1.0.0,https://github.com/ryanuber/go-glob/blob/v1.0.0/LICENSE,MIT
53-
github.com/spf13/cast,v1.7.1,https://github.com/spf13/cast/blob/v1.7.1/LICENSE,MIT
53+
github.com/spf13/cast,v1.8.0,https://github.com/spf13/cast/blob/v1.8.0/LICENSE,MIT
5454
github.com/spf13/pflag,v1.0.5,https://github.com/spf13/pflag/blob/v1.0.5/LICENSE,BSD-3-Clause
5555
github.com/stretchr/objx,v0.5.2,https://github.com/stretchr/objx/blob/v0.5.2/LICENSE,MIT
5656
github.com/stretchr/testify/assert,v1.10.0,https://github.com/stretchr/testify/blob/v1.10.0/LICENSE,MIT

api/v1/mdb/mongodb_validation.go

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ func oidcAuthValidators(db DbCommonSpec) []func(DbCommonSpec) v1.ValidationResul
113113

114114
authentication := db.Security.Authentication
115115
validators = append(validators, oidcAuthModeValidator(authentication))
116+
validators = append(validators, oidcAuthRequiresEnterprise)
116117

117118
providerConfigs := authentication.OIDCProviderConfigs
118119
if len(providerConfigs) == 0 {
@@ -122,6 +123,7 @@ func oidcAuthValidators(db DbCommonSpec) []func(DbCommonSpec) v1.ValidationResul
122123
validators = append(validators,
123124
oidcProviderConfigsUniqueNameValidation(providerConfigs),
124125
oidcProviderConfigsSingleWorkforceIdentityFederationValidation(providerConfigs),
126+
oidcProviderConfigUniqueIssuerURIValidation(providerConfigs),
125127
)
126128

127129
for _, config := range providerConfigs {
@@ -130,13 +132,58 @@ func oidcAuthValidators(db DbCommonSpec) []func(DbCommonSpec) v1.ValidationResul
130132
oidcProviderConfigClientIdValidator(config),
131133
oidcProviderConfigRequestedScopesValidator(config),
132134
oidcProviderConfigAuthorizationTypeValidator(config),
133-
oidcAuthRequiresEnterprise,
134135
)
135136
}
136137

137138
return validators
138139
}
139140

141+
// oidcProviderConfigUniqueIssuerURIValidation is based on the documentation here:
142+
// https://www.mongodb.com/docs/manual/reference/parameters/#oidcidentityproviders-fields
143+
func oidcProviderConfigUniqueIssuerURIValidation(configs []OIDCProviderConfig) func(DbCommonSpec) v1.ValidationResult {
144+
return func(d DbCommonSpec) v1.ValidationResult {
145+
if len(configs) == 0 {
146+
return v1.ValidationSuccess()
147+
}
148+
149+
// Check if version supports duplicate issuers (7.0, 7.3, or 8.0+)
150+
versionParts := strings.Split(strings.TrimSuffix(d.Version, "-ent"), ".")
151+
supportsMultipleIssuers := false
152+
if len(versionParts) >= 2 {
153+
major := versionParts[0]
154+
minor := versionParts[1]
155+
if major == "8" || (major == "7" && (minor == "0" || minor == "3")) {
156+
supportsMultipleIssuers = true
157+
}
158+
}
159+
160+
if supportsMultipleIssuers {
161+
// Track issuer+audience combinations
162+
issuerAudienceCombos := make(map[string]string)
163+
for _, config := range configs {
164+
comboKey := config.IssuerURI + ":" + config.Audience
165+
if previousConfig, exists := issuerAudienceCombos[comboKey]; exists {
166+
return v1.ValidationWarning("OIDC provider configs %q and %q have duplicate IssuerURI and Audience combination",
167+
previousConfig, config.ConfigurationName)
168+
}
169+
issuerAudienceCombos[comboKey] = config.ConfigurationName
170+
}
171+
} else {
172+
// For older versions, require unique issuers
173+
uris := make(map[string]string)
174+
for _, config := range configs {
175+
if previousConfig, exists := uris[config.IssuerURI]; exists {
176+
return v1.ValidationError("OIDC provider configs %q and %q have duplicate IssuerURI: %s",
177+
previousConfig, config.ConfigurationName, config.IssuerURI)
178+
}
179+
uris[config.IssuerURI] = config.ConfigurationName
180+
}
181+
}
182+
183+
return v1.ValidationSuccess()
184+
}
185+
}
186+
140187
func oidcAuthModeValidator(authentication *Authentication) func(DbCommonSpec) v1.ValidationResult {
141188
return func(spec DbCommonSpec) v1.ValidationResult {
142189
// OIDC cannot be used for agent authentication so other auth mode has to enabled as well

0 commit comments

Comments
 (0)