Skip to content

Commit 6408031

Browse files
authored
[db] Run test against the same (bitnami/)mysql:8.0.33 version (#18373)
1 parent 1b1c907 commit 6408031

File tree

5 files changed

+39
-9
lines changed

5 files changed

+39
-9
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,12 @@ jobs:
145145
cancel-in-progress: ${{ needs.configuration.outputs.is_main_branch == 'false' }}
146146
services:
147147
mysql:
148-
image: mysql:5.7
148+
image: bitnami/mysql:8.0.33-debian-11-r24
149149
env:
150150
MYSQL_ROOT_PASSWORD: test
151-
MYSQL_TCP_PORT: 23306
151+
#MYSQL_TCP_PORT: 23306 bitnami/mysql does not honor this, but has it's own:
152+
MYSQL_PORT_NUMBER: 23306
153+
MYSQL_AUTHENTICATION_PLUGIN: mysql_native_password
152154
ports:
153155
- 23306:23306
154156
redis:
@@ -161,6 +163,8 @@ jobs:
161163
DB_HOST: "mysql"
162164
DB_PORT: "23306"
163165
REDIS_HOST: "redis"
166+
# GitHub action + MySQL 8.0 need longer to initialize
167+
DB_RETRIES: 5
164168
steps:
165169
- uses: actions/checkout@v3
166170
- uses: ./.github/actions/setup-environment
@@ -222,8 +226,6 @@ jobs:
222226
id: leeway
223227
shell: bash
224228
env:
225-
DB_HOST: "mysql"
226-
DB_PORT: "23306"
227229
NODE_OPTIONS: "--max_old_space_size=4096"
228230
JAVA_HOME: /home/gitpod/.sdkman/candidates/java/current
229231
VERSION: ${{needs.configuration.outputs.version}}

components/gitpod-db/BUILD.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ packages:
7676
# Check if a DB is present. If not: start one and wait until it's up
7777
# Note: In CI there is a DB running as sidecar; in workspaces we're starting it once.
7878
# Re-use of the instance because of the init scripts (cmp. next step).
79-
- ["sh", "-c", "mysqladmin ping -h $DB_HOST --port $DB_PORT -p$DB_PASSWORD -u$DB_USER --silent || (docker run --name test-mysql -d -e MYSQL_ROOT_PASSWORD=$DB_PASSWORD -e MYSQL_TCP_PORT=$DB_PORT -p $DB_PORT:$DB_PORT mysql:5.7; while ! mysqladmin ping -h \"$DB_HOST\" -P \"$DB_PORT\" -p$DB_PASSWORD -u$DB_USER --silent; do echo \"waiting for DB...\"; sleep 2; done)"]
79+
# (gpl): It would be nice to use bitnami/mysql here as we do in previews. However the container does not start in Gitpod workspaces due to some docker/kernel/namespace issue.
80+
- ["sh", "-c", "mysqladmin ping --wait=${DB_RETRIES:-1} -h $DB_HOST --port $DB_PORT -p$DB_PASSWORD -u$DB_USER --default-auth=mysql_native_password --silent || (docker run --name test-mysql -d -e MYSQL_ROOT_PASSWORD=$DB_PASSWORD -e MYSQL_TCP_PORT=$DB_PORT -p $DB_PORT:$DB_PORT mysql:8.0.33 --default-authentication-plugin=mysql_native_password; while ! mysqladmin ping -h \"$DB_HOST\" -P \"$DB_PORT\" -p$DB_PASSWORD -u$DB_USER --default-auth=mysql_native_password --silent; do echo \"waiting for DB...\"; sleep 2; done)"]
8081
# Apply the DB initialization scripts (re-creates the "gitpod" DB if already there)
8182
- ["mkdir", "-p", "init-scripts"]
8283
- ["sh", "-c", "find . -name \"*.sql\" | sort | xargs -I file cp file init-scripts"]

install/installer/pkg/components/database/incluster/helm.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/gitpod-io/gitpod/installer/pkg/helm"
1111
"github.com/gitpod-io/gitpod/installer/third_party/charts"
1212
"helm.sh/helm/v3/pkg/cli/values"
13+
"sigs.k8s.io/yaml"
1314
)
1415

1516
var Helm = common.CompositeHelmFunc(
@@ -26,10 +27,28 @@ var Helm = common.CompositeHelmFunc(
2627

2728
imageRegistry := common.ThirdPartyContainerRepo(cfg.Config.Repository, common.DockerRegistryURL)
2829

29-
// We switched to specific tags because we got subtle broken versions with just specifying major versions
30+
type EnvVar struct {
31+
// json because: https://pkg.go.dev/sigs.k8s.io/[email protected]#Marshal
32+
Name string `json:"name,omitempty"`
33+
Value string `json:"value,omitempty"`
34+
}
35+
extraEnvVars := []EnvVar{}
36+
// MySQL 5.7: We switched to specific tags because we got subtle broken versions with just specifying major versions
3037
mysqlBitnamiImageTag := "5.7.34-debian-10-r55"
3138
if cfg.Config.Database.InClusterMysSQL_8_0 {
3239
mysqlBitnamiImageTag = "8.0.33-debian-11-r24"
40+
extraEnvVars = append(extraEnvVars, EnvVar{
41+
Name: "MYSQL_AUTHENTICATION_PLUGIN",
42+
Value: "mysql_native_password",
43+
})
44+
}
45+
extraEnvVarsBytes, err := yaml.Marshal(extraEnvVars)
46+
if err != nil {
47+
return nil, err
48+
}
49+
extraEnvVarsTemplate, err := helm.KeyFileValue("mysql.primary.extraEnvVars", extraEnvVarsBytes)
50+
if err != nil {
51+
return nil, err
3352
}
3453

3554
return &common.HelmConfig{
@@ -57,6 +76,7 @@ var Helm = common.CompositeHelmFunc(
5776
// This is too complex to be sent as a string
5877
FileValues: []string{
5978
primaryAffinityTemplate,
79+
extraEnvVarsTemplate,
6080
},
6181
},
6282
}, nil

install/installer/pkg/helm/common.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,23 @@ package helm
66

77
import (
88
"fmt"
9-
"github.com/gitpod-io/gitpod/installer/pkg/common"
109
"os"
10+
"strings"
11+
12+
"github.com/gitpod-io/gitpod/installer/pkg/common"
1113
)
1214

1315
// KeyValue ensure that a key/value pair is correctly formatted for Values
1416
func KeyValue(key string, value string) string {
1517
return fmt.Sprintf("%s=%s", key, value)
1618
}
1719

20+
// KeyValueArray ensure that a key/value pair is correctly formatted for Arrays
21+
func KeyValueArray(key string, arr []string) string {
22+
// Helm array nomenclature
23+
return KeyValue(key, fmt.Sprintf("{%s}", strings.Join(arr, ",")))
24+
}
25+
1826
// KeyFileValue ensure that a key/value pair is correctly formatted for FileValues
1927
func KeyFileValue(key string, data []byte) (string, error) {
2028
dir, err := os.MkdirTemp("", "helm")

install/installer/pkg/helm/helm.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,7 @@ func ImagePullSecrets(key string, ctx *common.RenderContext) string {
154154
pullSecrets = append(pullSecrets, i.Name)
155155
}
156156

157-
// Helm array nomenclature
158-
return KeyValue(key, fmt.Sprintf("{%s}", strings.Join(pullSecrets, ",")))
157+
return KeyValueArray(key, pullSecrets)
159158
}
160159

161160
// Nothing to be set

0 commit comments

Comments
 (0)