Skip to content

Commit

Permalink
Fix migration CI job and remove unused lifecycleServer properties (#…
Browse files Browse the repository at this point in the history
…1392)

- Fix migration CI job
- Ensure plugin version is removed when migrating to Cloud
- Remove unused Lifecycle server properties
  • Loading branch information
pkosiec authored Feb 22, 2024
1 parent 64149cc commit 2b9f03c
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 106 deletions.
143 changes: 71 additions & 72 deletions helm/botkube/README.md

Large diffs are not rendered by default.

7 changes: 1 addition & 6 deletions helm/botkube/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if or .Values.serviceMonitor.enabled (.Values.settings.lifecycleServer.enabled ) (.Values.plugins.incomingWebhook.enabled) }}
{{- if or .Values.serviceMonitor.enabled (.Values.plugins.incomingWebhook.enabled) }}
apiVersion: v1
kind: Service
metadata:
Expand All @@ -17,11 +17,6 @@ spec:
port: {{ .Values.plugins.incomingWebhook.port }}
targetPort: {{ .Values.plugins.incomingWebhook.targetPort }}
{{- end }}
{{- if .Values.settings.lifecycleServer.enabled }}
- name: "lifecycle"
port: {{ .Values.settings.lifecycleServer.port }}
targetPort: {{ .Values.settings.lifecycleServer.port }}
{{- end }}
{{- if .Values.serviceMonitor.enabled }}
- name: {{ .Values.service.name }}
port: {{ .Values.service.port }}
Expand Down
3 changes: 2 additions & 1 deletion helm/botkube/templates/systemroles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ rules:
resources: ["nodes"]
verbs: ["get"]
{{ end }}
{{- if .Values.settings.lifecycleServer.enabled }}
{{- if .Values.configWatcher.enabled }}
# Ensure Botkube can restart itself via Kubernetes API to avoid CrashLoopBackOff errors
- apiGroups: ["apps"]
resources: ["deployments"]
verbs: ["patch"]
Expand Down
5 changes: 1 addition & 4 deletions helm/botkube/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -692,10 +692,7 @@ settings:
# -- Cluster name to differentiate incoming messages.
clusterName: not-configured

# -- Server configuration which exposes functionality related to the app lifecycle.
lifecycleServer:
enabled: true
port: 2113
# -- Health check port.
healthPort: 2114
# -- If true, notifies about new Botkube releases.
upgradeNotifier: true
Expand Down
27 changes: 19 additions & 8 deletions internal/cli/migrate/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import (
"github.com/kubeshop/botkube/pkg/ptr"
)

const (
defaultPluginRepoPrefix = "botkube/"
)

// Converter converts OS config into GraphQL create input.
type Converter struct {
pluginNames map[string]string
Expand Down Expand Up @@ -105,22 +109,25 @@ func (c *Converter) convertExecutors(executors map[string]bkconfig.Executors) ([

errs := multierror.New()
for cfgName, conf := range executors {
for name, p := range conf.Plugins {
if !strings.HasPrefix(name, "botkube") { // skip all 3rd party plugins
for pName, p := range conf.Plugins {
if !strings.HasPrefix(pName, defaultPluginRepoPrefix) { // skip all 3rd party plugins
continue
}

repo, name, _, _ := bkconfig.DecomposePluginKey(pName)
pluginNameWithoutVersion := fmt.Sprintf("%s/%s", repo, name)

rawCfg, err := json.Marshal(p.Config)
if err != nil {
errs = multierror.Append(errs, fmt.Errorf("while marshalling config for executor %q: %w", name, err))
continue
}
displayName := conf.DisplayName
if displayName == "" {
displayName = name
displayName = pluginNameWithoutVersion
}
out = append(out, &gqlModel.PluginConfigurationGroupInput{
Name: name,
Name: pluginNameWithoutVersion,
DisplayName: displayName,
Type: gqlModel.PluginTypeExecutor,
Enabled: p.Enabled,
Expand All @@ -143,21 +150,25 @@ func (c *Converter) convertSources(sources map[string]bkconfig.Sources) ([]*gqlM

errs := multierror.New()
for cfgName, conf := range sources {
for name, p := range conf.Plugins {
if !strings.HasPrefix(name, "botkube") { // skip all 3rd party plugins
for pName, p := range conf.Plugins {
if !strings.HasPrefix(pName, defaultPluginRepoPrefix) { // skip all 3rd party plugins
continue
}

repo, name, _, _ := bkconfig.DecomposePluginKey(pName)
pluginNameWithoutVersion := fmt.Sprintf("%s/%s", repo, name)

rawCfg, err := json.Marshal(p.Config)
if err != nil {
errs = multierror.Append(errs, fmt.Errorf("while marshalling config for source %q: %w", name, err))
continue
}
displayName := conf.DisplayName
if displayName == "" {
displayName = name
displayName = pluginNameWithoutVersion
}
out = append(out, &gqlModel.PluginConfigurationGroupInput{
Name: name,
Name: pluginNameWithoutVersion,
DisplayName: displayName,
Type: gqlModel.PluginTypeSource,
Enabled: p.Enabled,
Expand Down
7 changes: 0 additions & 7 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,6 @@ type Settings struct {
PersistentConfig PersistentConfig `yaml:"persistentConfig"`
MetricsPort string `yaml:"metricsPort"`
HealthPort string `yaml:"healthPort"`
LifecycleServer LifecycleServer `yaml:"lifecycleServer"`
Log Logger `yaml:"log"`
InformersResyncPeriod time.Duration `yaml:"informersResyncPeriod"`
Kubeconfig string `yaml:"kubeconfig"`
Expand All @@ -632,12 +631,6 @@ type Logger struct {
Formatter Formatter `yaml:"formatter"`
}

// LifecycleServer contains configuration for the server with app lifecycle methods.
type LifecycleServer struct {
Enabled bool `yaml:"enabled"`
Port int `yaml:"port"` // String for consistency
}

// PersistentConfig contains configuration for persistent storage.
type PersistentConfig struct {
Startup PartialPersistentConfig `yaml:"startup"`
Expand Down
3 changes: 0 additions & 3 deletions pkg/config/testdata/TestLoadConfigSuccess/config.golden.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ settings:
name: runtime-config
metricsPort: "1313"
healthPort: "1314"
lifecycleServer:
enabled: false
port: 0
log:
level: error
disableColors: false
Expand Down
3 changes: 0 additions & 3 deletions pkg/execute/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ func TestConfigExecutorShowConfig(t *testing.T) {
configMap: {}
metricsPort: ""
healthPort: ""
lifecycleServer:
enabled: false
port: 0
log:
level: ""
disableColors: false
Expand Down
5 changes: 3 additions & 2 deletions test/e2e/migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
)

const (
// using latest version (without `--version` flag)
// using latest version (without `--version` flag; `--devel` allows to use the version with `-{commitHash}` suffix)
helmCmdFmt = `helm upgrade botkube --install --namespace botkube --create-namespace --wait \
--set communications.default-group.discord.enabled=true \
--set communications.default-group.discord.channels.default.id=%s \
Expand All @@ -38,6 +38,7 @@ const (
--set executors.k8s-default-tools.botkube/kubectl.enabled=true \
--set analytics.disable=true \
--set image.tag=v9.99.9-dev \
--devel \
--set plugins.repositories.botkube.url=https://storage.googleapis.com/botkube-plugins-latest/plugins-index.yaml \
botkube/botkube`

Expand Down Expand Up @@ -112,7 +113,7 @@ func TestBotkubeMigration(t *testing.T) {
cmd := fmt.Sprintf(helmCmdFmt, channel.ID(), appCfg.Discord.BotID, appCfg.DiscordBotToken, channel.Name())
params := helmx.InstallChartParams{
RepoName: "botkube",
RepoURL: "https://charts.botkube.io",
RepoURL: "https://storage.googleapis.com/botkube-latest-main-charts",
Name: "botkube",
Namespace: "botkube",
Command: cmd,
Expand Down

0 comments on commit 2b9f03c

Please sign in to comment.