Skip to content

Commit f39c9c7

Browse files
committed
CR
1 parent 7354e87 commit f39c9c7

File tree

6 files changed

+33
-17
lines changed

6 files changed

+33
-17
lines changed

api/v1alpha1/reason.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ const (
2929
ReasonCreatingAtlasClient = "CreatingAtlasClient"
3030
// ReasonCreatingWorkingDir represents the reason for creating a working directory.
3131
ReasonCreatingWorkingDir = "CreatingWorkingDir"
32+
// ReasonLogin represents the reason for logging in to Atlas.
33+
ReasonLogin = "Login"
3234
)
3335

3436
// isFailedReason returns true if the given reason is a failed reason.

charts/atlas-operator/templates/deployment.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ spec:
3131
kubectl.kubernetes.io/default-container: manager
3232
{{- end }}
3333
spec:
34+
securityContext:
35+
{{- if .Values.persistence.fsGroup }}
36+
fsGroup: {{ .Values.persistence.fsGroup }}
37+
{{- else }}
38+
{{- with .Values.podSecurityContext }}
39+
{{- toYaml . | nindent 8 }}
40+
{{- end }}
41+
{{- end }}
3442
{{- if or .Values.persistence.enabled .Values.extraVolumes }}
3543
volumes:
3644
{{- if .Values.persistence.enabled }}

config/manager/manager.yaml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
apiVersion: v1
16+
kind: Namespace
17+
metadata:
18+
labels:
19+
control-plane: controller-manager
20+
app.kubernetes.io/name: namespace
21+
app.kubernetes.io/instance: system
22+
app.kubernetes.io/component: manager
23+
app.kubernetes.io/created-by: atlas-operator
24+
app.kubernetes.io/part-of: atlas-operator
25+
app.kubernetes.io/managed-by: kustomize
26+
name: system
27+
---
1528
apiVersion: v1
1629
kind: PersistentVolumeClaim
1730
metadata:
@@ -32,19 +45,6 @@ spec:
3245
requests:
3346
storage: 1Gi
3447
---
35-
apiVersion: v1
36-
kind: Namespace
37-
metadata:
38-
labels:
39-
control-plane: controller-manager
40-
app.kubernetes.io/name: namespace
41-
app.kubernetes.io/instance: system
42-
app.kubernetes.io/component: manager
43-
app.kubernetes.io/created-by: atlas-operator
44-
app.kubernetes.io/part-of: atlas-operator
45-
app.kubernetes.io/managed-by: kustomize
46-
name: system
47-
---
4848
apiVersion: apps/v1
4949
kind: Deployment
5050
metadata:
@@ -92,6 +92,8 @@ spec:
9292
# - linux
9393
securityContext:
9494
runAsNonRoot: true
95+
fsGroup: 1000
96+
fsGroupChangePolicy: OnRootMismatch
9597
# TODO(user): For common cases that do not require escalating privileges
9698
# it is recommended to ensure that all your Pods/Containers are restrictive.
9799
# More info: https://kubernetes.io/docs/concepts/security/pod-security-standards/#restricted

internal/controller/atlasmigration_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ func (r *AtlasMigrationReconciler) reconcile(ctx context.Context, data *migratio
275275
}
276276
if data.Cloud != nil && data.Cloud.Token != "" {
277277
if err := c.Login(ctx, &atlasexec.LoginParams{Token: data.Cloud.Token, GrantOnly: true}); err != nil {
278-
return r.resultErr(res, err, dbv1alpha1.ReasonCreatingAtlasClient)
278+
return r.resultErr(res, err, dbv1alpha1.ReasonLogin)
279279
}
280280
}
281281
var whoami *atlasexec.WhoAmI

internal/controller/atlasschema_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func (r *AtlasSchemaReconciler) Reconcile(ctx context.Context, req ctrl.Request)
176176
}
177177
if data.Cloud != nil && data.Cloud.Token != "" {
178178
if err := cli.Login(ctx, &atlasexec.LoginParams{Token: data.Cloud.Token, GrantOnly: true}); err != nil {
179-
return r.resultErr(res, err, dbv1alpha1.ReasonCreatingAtlasClient)
179+
return r.resultErr(res, err, dbv1alpha1.ReasonLogin)
180180
}
181181
}
182182
// Calculate the hash of the current schema.

internal/controller/common.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ type (
7676
// SetStderr specifies a writer to stream stderr to for every command.
7777
SetStderr(io.Writer)
7878
}
79-
// AtlasExecFn is a function that returns an AtlasExec
80-
// with the working directory and HOME directory.
79+
// AtlasExecFn is a function that returns an AtlasExec configured
80+
// with the given working directory, cloud configuration, and HOME directory.
8181
AtlasExecFn func(dir string, c *Cloud, home string) (AtlasExec, error)
8282
// Cloud holds the cloud configuration.
8383
Cloud struct {
@@ -109,6 +109,10 @@ func NewAtlasExec(dir string, c *Cloud, home string) (AtlasExec, error) {
109109
return nil, fmt.Errorf("creating resource home directory: %w", err)
110110
}
111111
env["HOME"] = homeDir
112+
} else if env["HOME"] == "" {
113+
// Ensure HOME is set to a safe default when not provided by the environment
114+
// and no DATA_DIR-based home directory is configured.
115+
env["HOME"] = "/tmp"
112116
}
113117
if c != nil && c.Token != "" {
114118
env["ATLAS_TOKEN"] = c.Token

0 commit comments

Comments
 (0)