Skip to content

Commit 78a69d0

Browse files
lucian-tosaMaciejKaras
authored andcommitted
Cleanup unused evg functions
1 parent d886cea commit 78a69d0

27 files changed

+212
-300
lines changed

.evergreen-functions.yml

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -396,29 +396,6 @@ functions:
396396
- bin
397397
binary: scripts/evergreen/e2e/dump_diagnostic_information_from_all_namespaces.sh
398398

399-
### Publish and release image ###
400-
401-
# Tags and pushes an image into an external Docker registry. The source image
402-
# needs to exist before it can be pushed to a remote registry.
403-
# It is expected that IMAGE_SOURCE is accessible with no authentication (like a
404-
# local image), and the IMAGE_TARGET will be authenticated with DOCKER_* series of
405-
# environment variables.
406-
release_docker_image_to_registry:
407-
- command: subprocess.exec
408-
type: system
409-
params:
410-
working_dir: src/github.com/mongodb/mongodb-kubernetes
411-
add_to_path:
412-
- ${workdir}/bin
413-
include_expansions_in_env:
414-
- tag_source
415-
- tag_dest
416-
- image_source
417-
- image_target
418-
- docker_username
419-
- docker_password
420-
binary: scripts/evergreen/tag_push_docker_image.sh
421-
422399
#
423400
# Performs some AWS cleanup
424401
#
@@ -431,33 +408,6 @@ functions:
431408
- ${workdir}/bin
432409
command: scripts/evergreen/prepare_aws.sh
433410

434-
build-dockerfiles:
435-
- command: subprocess.exec
436-
type: setup
437-
params:
438-
add_to_path:
439-
- ${workdir}/bin
440-
working_dir: src/github.com/mongodb/mongodb-kubernetes
441-
binary: scripts/dev/run_python.sh scripts/update_supported_dockerfiles.py
442-
- command: subprocess.exec
443-
type: setup
444-
params:
445-
working_dir: src/github.com/mongodb/mongodb-kubernetes
446-
include_expansions_in_env:
447-
- triggered_by_git_tag
448-
# if you ever change the target folder structure, the same needs to be reflected in PCT
449-
command: "tar -czvf ./public/dockerfiles-${triggered_by_git_tag}.tgz ./public/dockerfiles"
450-
451-
enable_QEMU:
452-
- command: shell.exec
453-
type: setup
454-
params:
455-
shell: bash
456-
working_dir: src/github.com/mongodb/mongodb-kubernetes
457-
script: |
458-
echo "Enabling QEMU building for Docker"
459-
docker run --rm --privileged 268558157000.dkr.ecr.eu-west-1.amazonaws.com/docker-hub-mirrors/multiarch/qemu-user-static --reset -p yes
460-
461411
# upload_e2e_logs has the responsibility of dumping as much information as
462412
# possible into the S3 bucket that corresponds to this ${version}. The
463413
# Kubernetes cluster where the test finished running, should still be

Makefile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,6 @@ bundle: manifests kustomize
403403
bundle-build:
404404
docker build $(EXPIRES) --platform linux/amd64 -f ./bundle/$(VERSION)/bundle.Dockerfile -t $(BUNDLE_IMG) .
405405

406-
.PHONY: dockerfiles
407-
dockerfiles:
408-
python scripts/update_supported_dockerfiles.py
409-
tar -czvf ./public/dockerfiles-$(VERSION).tgz ./public/dockerfiles
410-
411406
prepare-local-e2e: reset-mco # prepares the local environment to run a local operator
412407
scripts/dev/prepare_local_e2e_run.sh
413408

controllers/operator/authentication_test.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func TestX509CanBeEnabled_WhenThereAreOnlyTlsDeployments_ReplicaSet(t *testing.T
4747

4848
addKubernetesTlsResources(ctx, kubeClient, rs)
4949

50-
reconciler := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, omConnectionFactory.GetConnectionFunc)
50+
reconciler := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, false, "", omConnectionFactory.GetConnectionFunc)
5151
checkReconcileSuccessful(ctx, t, reconciler, rs, kubeClient)
5252
}
5353

@@ -57,7 +57,7 @@ func TestX509ClusterAuthentication_CanBeEnabled_IfX509AuthenticationIsEnabled_Re
5757
kubeClient, omConnectionFactory := mock.NewDefaultFakeClient(rs)
5858
addKubernetesTlsResources(ctx, kubeClient, rs)
5959

60-
reconciler := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, omConnectionFactory.GetConnectionFunc)
60+
reconciler := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, false, "", omConnectionFactory.GetConnectionFunc)
6161
checkReconcileSuccessful(ctx, t, reconciler, rs, kubeClient)
6262
}
6363

@@ -90,7 +90,7 @@ func TestUpdateOmAuthentication_NoAuthenticationEnabled(t *testing.T) {
9090
processNames := []string{"my-rs-0", "my-rs-1", "my-rs-2"}
9191

9292
kubeClient, omConnectionFactory := mock.NewDefaultFakeClient(rs)
93-
r := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, omConnectionFactory.GetConnectionFunc)
93+
r := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, false, "", omConnectionFactory.GetConnectionFunc)
9494
r.updateOmAuthentication(ctx, conn, processNames, rs, "", "", "", false, zap.S())
9595

9696
ac, _ := conn.ReadAutomationConfig()
@@ -111,7 +111,7 @@ func TestUpdateOmAuthentication_EnableX509_TlsNotEnabled(t *testing.T) {
111111
rs.Spec.Security.TLSConfig.Enabled = true
112112

113113
kubeClient, omConnectionFactory := mock.NewDefaultFakeClient(rs)
114-
r := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, omConnectionFactory.GetConnectionFunc)
114+
r := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, false, "", omConnectionFactory.GetConnectionFunc)
115115
status, isMultiStageReconciliation := r.updateOmAuthentication(ctx, conn, []string{"my-rs-0", "my-rs-1", "my-rs-2"}, rs, "", "", "", false, zap.S())
116116

117117
assert.True(t, status.IsOK(), "configuring both options at once should not result in a failed status")
@@ -123,7 +123,7 @@ func TestUpdateOmAuthentication_EnableX509_WithTlsAlreadyEnabled(t *testing.T) {
123123
rs := DefaultReplicaSetBuilder().SetName("my-rs").SetMembers(3).EnableTLS().Build()
124124
omConnectionFactory := om.NewCachedOMConnectionFactoryWithInitializedConnection(om.NewMockedOmConnection(deployment.CreateFromReplicaSet("fake-mongoDBImage", false, rs)))
125125
kubeClient := mock.NewDefaultFakeClientWithOMConnectionFactory(omConnectionFactory, rs)
126-
r := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, omConnectionFactory.GetConnectionFunc)
126+
r := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, false, "", omConnectionFactory.GetConnectionFunc)
127127
status, isMultiStageReconciliation := r.updateOmAuthentication(ctx, omConnectionFactory.GetConnection(), []string{"my-rs-0", "my-rs-1", "my-rs-2"}, rs, "", "", "", false, zap.S())
128128

129129
assert.True(t, status.IsOK(), "configuring x509 when tls has already been enabled should not result in a failed status")
@@ -138,7 +138,7 @@ func TestUpdateOmAuthentication_AuthenticationIsNotConfigured_IfAuthIsNotSet(t *
138138

139139
omConnectionFactory := om.NewCachedOMConnectionFactoryWithInitializedConnection(om.NewMockedOmConnection(deployment.CreateFromReplicaSet("fake-mongoDBImage", false, rs)))
140140
kubeClient := mock.NewDefaultFakeClientWithOMConnectionFactory(omConnectionFactory, rs)
141-
r := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, omConnectionFactory.GetConnectionFunc)
141+
r := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, false, "", omConnectionFactory.GetConnectionFunc)
142142

143143
status, _ := r.updateOmAuthentication(ctx, omConnectionFactory.GetConnection(), []string{"my-rs-0", "my-rs-1", "my-rs-2"}, rs, "", "", "", false, zap.S())
144144
assert.True(t, status.IsOK(), "no authentication should have been configured")
@@ -161,7 +161,7 @@ func TestUpdateOmAuthentication_DoesNotDisableAuth_IfAuthIsNotSet(t *testing.T)
161161
Build()
162162

163163
kubeClient, omConnectionFactory := mock.NewDefaultFakeClient(rs)
164-
reconciler := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, omConnectionFactory.GetConnectionFunc)
164+
reconciler := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, false, "", omConnectionFactory.GetConnectionFunc)
165165

166166
addKubernetesTlsResources(ctx, kubeClient, rs)
167167

@@ -174,7 +174,7 @@ func TestUpdateOmAuthentication_DoesNotDisableAuth_IfAuthIsNotSet(t *testing.T)
174174

175175
rs.Spec.Security.Authentication = nil
176176

177-
reconciler = newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, omConnectionFactory.GetConnectionFunc)
177+
reconciler = newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, false, "", omConnectionFactory.GetConnectionFunc)
178178

179179
checkReconcileSuccessful(ctx, t, reconciler, rs, kubeClient)
180180

@@ -196,7 +196,7 @@ func TestCanConfigureAuthenticationDisabled_WithNoModes(t *testing.T) {
196196
Build()
197197

198198
kubeClient, omConnectionFactory := mock.NewDefaultFakeClient(rs)
199-
reconciler := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, omConnectionFactory.GetConnectionFunc)
199+
reconciler := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, false, "", omConnectionFactory.GetConnectionFunc)
200200

201201
addKubernetesTlsResources(ctx, kubeClient, rs)
202202

@@ -208,7 +208,7 @@ func TestUpdateOmAuthentication_EnableX509_FromEmptyDeployment(t *testing.T) {
208208
rs := DefaultReplicaSetBuilder().SetName("my-rs").SetMembers(3).EnableTLS().EnableAuth().EnableX509().Build()
209209
omConnectionFactory := om.NewCachedOMConnectionFactoryWithInitializedConnection(om.NewMockedOmConnection(om.NewDeployment()))
210210
kubeClient := mock.NewDefaultFakeClientWithOMConnectionFactory(omConnectionFactory, rs)
211-
r := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, omConnectionFactory.GetConnectionFunc)
211+
r := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, false, "", omConnectionFactory.GetConnectionFunc)
212212
secretName := util.AgentSecretName
213213
createAgentCSRs(t, ctx, r.client, secretName, certsv1.CertificateApproved)
214214

@@ -229,7 +229,7 @@ func TestX509AgentUserIsCorrectlyConfigured(t *testing.T) {
229229

230230
// configure x509/tls resources
231231
addKubernetesTlsResources(ctx, kubeClient, rs)
232-
reconciler := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, omConnectionFactory.GetConnectionFunc)
232+
reconciler := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, false, "", omConnectionFactory.GetConnectionFunc)
233233

234234
checkReconcileSuccessful(ctx, t, reconciler, rs, kubeClient)
235235

@@ -265,7 +265,7 @@ func TestScramAgentUserIsCorrectlyConfigured(t *testing.T) {
265265

266266
assert.NoError(t, err)
267267

268-
reconciler := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, omConnectionFactory.GetConnectionFunc)
268+
reconciler := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, false, "", omConnectionFactory.GetConnectionFunc)
269269

270270
checkReconcileSuccessful(ctx, t, reconciler, rs, kubeClient)
271271

@@ -295,7 +295,7 @@ func TestScramAgentUser_IsNotOverridden(t *testing.T) {
295295
}
296296
})
297297

298-
reconciler := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, omConnectionFactory.GetConnectionFunc)
298+
reconciler := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, false, "", omConnectionFactory.GetConnectionFunc)
299299

300300
checkReconcileSuccessful(ctx, t, reconciler, rs, kubeClient)
301301

@@ -314,7 +314,7 @@ func TestX509InternalClusterAuthentication_CanBeEnabledWithScram_ReplicaSet(t *t
314314
Build()
315315

316316
kubeClient, omConnectionFactory := mock.NewDefaultFakeClient(rs)
317-
r := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, omConnectionFactory.GetConnectionFunc)
317+
r := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, false, "", omConnectionFactory.GetConnectionFunc)
318318
addKubernetesTlsResources(ctx, r.client, rs)
319319

320320
checkReconcileSuccessful(ctx, t, r, rs, kubeClient)
@@ -367,7 +367,7 @@ func TestConfigureLdapDeploymentAuthentication_WithScramAgentAuthentication(t *t
367367
Build()
368368

369369
kubeClient, omConnectionFactory := mock.NewDefaultFakeClient(rs)
370-
r := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, omConnectionFactory.GetConnectionFunc)
370+
r := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, false, "", omConnectionFactory.GetConnectionFunc)
371371
data := map[string]string{
372372
"password": "LITZTOd6YiCV8j",
373373
}
@@ -424,7 +424,7 @@ func TestConfigureLdapDeploymentAuthentication_WithCustomRole(t *testing.T) {
424424
Build()
425425

426426
kubeClient, omConnectionFactory := mock.NewDefaultFakeClient(rs)
427-
r := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, omConnectionFactory.GetConnectionFunc)
427+
r := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, false, "", omConnectionFactory.GetConnectionFunc)
428428
data := map[string]string{
429429
"password": "LITZTOd6YiCV8j",
430430
}
@@ -478,7 +478,7 @@ func TestConfigureLdapDeploymentAuthentication_WithAuthzQueryTemplate_AndUserToD
478478
Build()
479479

480480
kubeClient, omConnectionFactory := mock.NewDefaultFakeClient(rs)
481-
r := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, omConnectionFactory.GetConnectionFunc)
481+
r := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, false, "", omConnectionFactory.GetConnectionFunc)
482482
data := map[string]string{
483483
"password": "LITZTOd6YiCV8j",
484484
}
@@ -741,7 +741,7 @@ func TestInvalidPEM_SecretDoesNotContainKey(t *testing.T) {
741741
Build()
742742

743743
kubeClient, omConnectionFactory := mock.NewDefaultFakeClient(rs)
744-
reconciler := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, omConnectionFactory.GetConnectionFunc)
744+
reconciler := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, false, "", omConnectionFactory.GetConnectionFunc)
745745
addKubernetesTlsResources(ctx, kubeClient, rs)
746746

747747
// Replace the secret with an empty one
@@ -771,7 +771,7 @@ func Test_NoAdditionalDomainsPresent(t *testing.T) {
771771
rs.Spec.Security.TLSConfig.AdditionalCertificateDomains = []string{"foo"}
772772

773773
kubeClient, omConnectionFactory := mock.NewDefaultFakeClient(rs)
774-
reconciler := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, omConnectionFactory.GetConnectionFunc)
774+
reconciler := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, false, "", omConnectionFactory.GetConnectionFunc)
775775
addKubernetesTlsResources(ctx, kubeClient, rs)
776776

777777
certSecret := &corev1.Secret{}
@@ -797,7 +797,7 @@ func Test_NoExternalDomainPresent(t *testing.T) {
797797
rs.Spec.ExternalAccessConfiguration = &mdbv1.ExternalAccessConfiguration{ExternalDomain: ptr.To("foo")}
798798

799799
kubeClient, omConnectionFactory := mock.NewDefaultFakeClient(rs)
800-
reconciler := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, omConnectionFactory.GetConnectionFunc)
800+
reconciler := newReplicaSetReconciler(ctx, kubeClient, nil, "", "", false, false, false, "", omConnectionFactory.GetConnectionFunc)
801801
addKubernetesTlsResources(ctx, kubeClient, rs)
802802

803803
secret := &corev1.Secret{}

controllers/operator/construct/database_construction.go

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ type DatabaseStatefulSetOptions struct {
122122
// The certificate secrets and other dependencies named using the resource name will use the `Name` field.
123123
StatefulSetNameOverride string // this needs to be overriden of the
124124
HostNameOverrideConfigmapName string
125+
126+
AgentDebug bool
127+
AgentDebugImage string
125128
}
126129

127130
func (d DatabaseStatefulSetOptions) IsMongos() bool {
@@ -480,7 +483,6 @@ func buildDatabaseStatefulSetConfigurationFunction(mdb databaseStatefulSetSource
480483
}
481484

482485
shareProcessNs := statefulset.NOOP()
483-
secondContainerModification := podtemplatespec.NOOP()
484486

485487
var databaseImage string
486488
var staticMods []podtemplatespec.Modification
@@ -500,17 +502,39 @@ func buildDatabaseStatefulSetConfigurationFunction(mdb databaseStatefulSetSource
500502
databaseImage = opts.DatabaseNonStaticImage
501503
}
502504

505+
agentDebugMod := podtemplatespec.NOOP()
506+
if opts.AgentDebug {
507+
if opts.AgentDebugImage == "" {
508+
log.Warnf("%s is true but delve image is not configured. Plese configure %s", util.EnvVarDebug, util.EnvVarDebugImage)
509+
} else {
510+
shareProcessNs = func(sts *appsv1.StatefulSet) {
511+
sts.Spec.Template.Spec.ShareProcessNamespace = ptr.To(true)
512+
}
513+
514+
agentDebugMod = podtemplatespec.WithInitContainer("delve-sidecar", func(c *corev1.Container) {
515+
container.WithImage(opts.AgentDebugImage)(c)
516+
container.WithRestartPolicy(corev1.ContainerRestartPolicyAlways)(c)
517+
container.WithPorts([]corev1.ContainerPort{
518+
{
519+
Name: "delve",
520+
ContainerPort: 2345,
521+
},
522+
})(c)
523+
})
524+
}
525+
}
526+
503527
podTemplateModifications := []podtemplatespec.Modification{
504528
podTemplateAnnotationFunc,
505529
podtemplatespec.WithAffinity(podAffinity, PodAntiAffinityLabelKey, 100),
506530
podtemplatespec.WithTerminationGracePeriodSeconds(util.DefaultPodTerminationPeriodSeconds),
507531
podtemplatespec.WithPodLabels(podLabels),
508532
podtemplatespec.WithContainerByIndex(0, sharedDatabaseContainerFunc(databaseImage, *opts.PodSpec, volumeMounts, configureContainerSecurityContext, opts.ServicePort)),
509-
secondContainerModification,
510533
volumesFunc,
511534
configurePodSpecSecurityContext,
512535
configureImagePullSecrets,
513536
podTemplateSpecFunc,
537+
agentDebugMod,
514538
}
515539
podTemplateModifications = append(podTemplateModifications, staticMods...)
516540

@@ -1001,12 +1025,6 @@ func databaseEnvVars(opts DatabaseStatefulSetOptions) []corev1.EnvVar {
10011025
)
10021026
}
10031027

1004-
// This is only used for debugging
1005-
if useDebugAgent := os.Getenv(util.EnvVarDebug); useDebugAgent != "" { // nolint:forbidigo
1006-
zap.S().Debugf("running the agent in debug mode")
1007-
vars = append(vars, corev1.EnvVar{Name: util.EnvVarDebug, Value: useDebugAgent})
1008-
}
1009-
10101028
// This is only used for debugging
10111029
if agentVersion := os.Getenv(util.EnvVarAgentVersion); agentVersion != "" { // nolint:forbidigo
10121030
zap.S().Debugf("using a custom agent version: %s", agentVersion)

controllers/operator/database_statefulset_options.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,15 @@ func WithAgentImage(image string) func(*construct.DatabaseStatefulSetOptions) {
134134
opts.AgentImage = image
135135
}
136136
}
137+
138+
func WithAgentDebug(debug bool) func(options *construct.DatabaseStatefulSetOptions) {
139+
return func(options *construct.DatabaseStatefulSetOptions) {
140+
options.AgentDebug = debug
141+
}
142+
}
143+
144+
func WithAgentDebugImage(debugImage string) func(options *construct.DatabaseStatefulSetOptions) {
145+
return func(options *construct.DatabaseStatefulSetOptions) {
146+
options.AgentDebugImage = debugImage
147+
}
148+
}

0 commit comments

Comments
 (0)