Skip to content

Commit

Permalink
Fix NPE
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
  • Loading branch information
dvaldivia committed Oct 21, 2021
1 parent fddbc69 commit cde9ff6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pkg/controller/cluster/main-controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const (
StatusNotOwned = "Statefulset not controlled by operator"
StatusFailedAlreadyExists = "Another MinIO Tenant already exists in the namespace"
StatusInconsistentMinIOVersions = "Different versions across MinIO Pools"
StatusRestartingMinIO = "Different versions across MinIO Pools"
StatusRestartingMinIO = "Restarting MinIO"
)

// ErrMinIONotReady is the error returned when MinIO is not Ready
Expand Down
33 changes: 19 additions & 14 deletions pkg/resources/statefulsets/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func logVolumeMounts(t *miniov2.Tenant) []corev1.VolumeMount {
func logDbContainer(t *miniov2.Tenant) corev1.Container {
container := corev1.Container{
Name: miniov2.LogPgContainerName,
Image: t.Spec.Log.Db.Image,
Image: miniov2.LogPgImage,
Ports: []corev1.ContainerPort{
{
ContainerPort: miniov2.LogPgPort,
Expand Down Expand Up @@ -207,19 +207,24 @@ func NewForLogDb(t *miniov2.Tenant, serviceName string) *appsv1.StatefulSet {
RunAsNonRoot: &runAsNonRoot,
AllowPrivilegeEscalation: &allowPrivilegeEscalation,
}
initContainers = []corev1.Container{
{
Name: "postgres-init-chown-data",
Image: t.Spec.Log.Db.InitImage,
Command: []string{
"chown",
"-R",
fmt.Sprintf("%s:%s", strconv.FormatInt(*dbPod.Spec.SecurityContext.RunAsUser, 10), strconv.FormatInt(*dbPod.Spec.SecurityContext.RunAsGroup, 10)),
"/var/lib/postgresql/data",
},
SecurityContext: &initContainerSecurityContext,
VolumeMounts: logVolumeMounts(t),
},

if t.Spec.Log != nil && t.Spec.Log.Db != nil {
if t.Spec.Log.Db.InitImage != "" {
initContainers = []corev1.Container{
{
Name: "postgres-init-chown-data",
Image: t.Spec.Log.Db.InitImage,
Command: []string{
"chown",
"-R",
fmt.Sprintf("%s:%s", strconv.FormatInt(*dbPod.Spec.SecurityContext.RunAsUser, 10), strconv.FormatInt(*dbPod.Spec.SecurityContext.RunAsGroup, 10)),
"/var/lib/postgresql/data",
},
SecurityContext: &initContainerSecurityContext,
VolumeMounts: logVolumeMounts(t),
},
}
}
}
}

Expand Down

0 comments on commit cde9ff6

Please sign in to comment.