Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
drupal
paas
drupalSite-operator
Commits
9f9d0c8f
Commit
9f9d0c8f
authored
Dec 01, 2021
by
Konstantinos Samaras-Tsakiris
Browse files
Merge branch 'fix-clone-db' into 'master'
Made DB procedure more flexible to use paths See merge request
!134
parents
425e1b90
f9d3d214
Pipeline
#3306690
passed with stages
in 4 minutes and 25 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
controllers/drupalsite_controller.go
View file @
9f9d0c8f
...
...
@@ -730,7 +730,8 @@ func (r *DrupalSiteReconciler) updateDBSchema(ctx context.Context, d *webservice
// Take backup
backupFileName
:=
"db_backup_update_rollback.sql"
if
_
,
err
:=
r
.
execToServerPodErrOnStderr
(
ctx
,
d
,
"php-fpm"
,
nil
,
takeBackup
(
backupFileName
)
...
);
err
!=
nil
{
// We set Backup on "Drupal-data" so the DB backup is stored on the PV of the website
if
_
,
err
:=
r
.
execToServerPodErrOnStderr
(
ctx
,
d
,
"php-fpm"
,
nil
,
takeBackup
(
"/drupal-data/"
+
backupFileName
)
...
);
err
!=
nil
{
setConditionStatus
(
d
,
"DBUpdatesFailed"
,
true
,
newApplicationError
(
err
,
ErrPodExec
),
false
)
return
true
}
...
...
controllers/drupalsite_resources.go
View file @
9f9d0c8f
...
...
@@ -1631,6 +1631,8 @@ func jobForDrupalSiteInstallation(currentobject *batchv1.Job, databaseSecret str
// jobForDrupalSiteClone returns a job object thats clones a drupalsite
func
jobForDrupalSiteClone
(
currentobject
*
batchv1
.
Job
,
databaseSecret
string
,
d
*
webservicesv1a1
.
DrupalSite
)
error
{
ls
:=
labelsForDrupalSite
(
d
.
Name
)
// Temporary folder to store ephemeral files used during cloning procedure
var
emptyDir
=
"/var/empty-run/"
if
currentobject
.
CreationTimestamp
.
IsZero
()
{
addOwnerRefToObject
(
currentobject
,
asOwner
(
d
))
currentobject
.
Labels
=
map
[
string
]
string
{}
...
...
@@ -1643,7 +1645,7 @@ func jobForDrupalSiteClone(currentobject *batchv1.Job, databaseSecret string, d
Image
:
sitebuilderImageRefToUse
(
d
,
releaseID
(
d
))
.
Name
,
Name
:
"src-db-backup"
,
ImagePullPolicy
:
"Always"
,
Command
:
takeBackup
(
"dbBackUp.sql"
),
Command
:
takeBackup
(
emptyDir
+
"dbBackUp.sql"
),
Resources
:
corev1
.
ResourceRequirements
{
Requests
:
corev1
.
ResourceList
{
corev1
.
ResourceMemory
:
resource
.
MustParse
(
jobMemoryRequest
),
...
...
@@ -1664,10 +1666,13 @@ func jobForDrupalSiteClone(currentobject *batchv1.Job, databaseSecret string, d
},
},
},
VolumeMounts
:
[]
corev1
.
VolumeMount
{{
Name
:
"drupal-directory-"
+
string
(
d
.
Spec
.
Configuration
.
CloneFrom
),
MountPath
:
"/drupal-data"
,
}},
VolumeMounts
:
[]
corev1
.
VolumeMount
{
{
Name
:
"tmp-dir"
,
MountPath
:
emptyDir
,
},
},
},
},
RestartPolicy
:
"Never"
,
...
...
@@ -1675,7 +1680,7 @@ func jobForDrupalSiteClone(currentobject *batchv1.Job, databaseSecret string, d
Image
:
sitebuilderImageRefToUse
(
d
,
releaseID
(
d
))
.
Name
,
Name
:
"dest-clone"
,
ImagePullPolicy
:
"Always"
,
Command
:
cloneSource
(
"dbBackUp.sql"
),
Command
:
cloneSource
(
emptyDir
+
"dbBackUp.sql"
),
Env
:
[]
corev1
.
EnvVar
{
{
Name
:
"DRUPAL_SHARED_VOLUME"
,
...
...
@@ -1719,6 +1724,10 @@ func jobForDrupalSiteClone(currentobject *batchv1.Job, databaseSecret string, d
SubPath
:
"settings.php"
,
ReadOnly
:
true
,
},
{
Name
:
"tmp-dir"
,
MountPath
:
emptyDir
,
},
},
}},
Volumes
:
[]
corev1
.
Volume
{
...
...
@@ -1758,6 +1767,11 @@ func jobForDrupalSiteClone(currentobject *batchv1.Job, databaseSecret string, d
},
},
},
{
// Tmp Dir storage to address issue https://gitlab.cern.ch/webservices/webframeworks-planning/-/issues/692
Name
:
"tmp-dir"
,
VolumeSource
:
corev1
.
VolumeSource
{
EmptyDir
:
&
corev1
.
EmptyDirVolumeSource
{}},
},
},
}
ls
[
"app"
]
=
"clone"
...
...
@@ -2036,8 +2050,8 @@ func runUpDBCommand() []string {
}
// takeBackup outputs the command need to take the database backup to a given filename
func
takeBackup
(
file
name
string
)
[]
string
{
return
[]
string
{
"/operations/database-backup.sh"
,
"-
f
"
,
file
name
}
func
takeBackup
(
file
path
string
)
[]
string
{
return
[]
string
{
"/operations/database-backup.sh"
,
"-
p
"
,
file
path
}
}
// restoreBackup outputs the command need to restore the database backup from a given filename
...
...
@@ -2046,8 +2060,8 @@ func restoreBackup(filename string) []string {
}
// cloneSource outputs the command need to clone a drupal site
func
cloneSource
(
file
name
string
)
[]
string
{
return
[]
string
{
"/operations/clone.sh"
,
"-
f
"
,
file
name
}
func
cloneSource
(
file
path
string
)
[]
string
{
return
[]
string
{
"/operations/clone.sh"
,
"-
p
"
,
file
path
}
}
// encryptBasicAuthPassword encrypts a password for basic authentication
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment