Skip to content

Commit f6f05da

Browse files
committed
[messagebus] Remove shovel config, and all non-local (or outdated) exchanges
1 parent 29c3a7d commit f6f05da

File tree

7 files changed

+9
-178
lines changed

7 files changed

+9
-178
lines changed

.werft/values.dev.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,6 @@ mysql:
218218
memory: 350Mi
219219

220220
rabbitmq:
221-
# ensure shovels are configured on boot
222-
shovels:
223-
- name: messagebus-0
224-
srcUri: "amqp://$USERNAME:$PASSWORD@messagebus-0"
225221
auth:
226222
username: override-me
227223
password: override-me

chart/values.yaml

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -573,9 +573,6 @@ mysql:
573573
rabbitmq:
574574
enabled: true
575575
fullnameOverride: "messagebus"
576-
# non-standard configuration
577-
# defined by gitpod.io
578-
shovels: []
579576
persistence:
580577
enabled: false
581578
replicaCount: 1
@@ -598,7 +595,7 @@ rabbitmq:
598595
enabled: true
599596
allowExternal: true
600597
plugins: "rabbitmq_management rabbitmq_peer_discovery_k8s"
601-
extraPlugins: "rabbitmq_shovel rabbitmq_shovel_management"
598+
extraPlugins: ""
602599
extraSecrets:
603600
load-definition:
604601
load_definition.json: |
@@ -611,7 +608,7 @@ rabbitmq:
611608
"vhosts": [{
612609
"name": "/"
613610
}],
614-
"parameters": {{ tpl (.Values.shovelsTemplate) . | fromYamlArray | toJson }},
611+
"parameters": [],
615612
"permissions": [{
616613
"user": {{ .Values.auth.username | quote }},
617614
"vhost": "/",
@@ -620,38 +617,19 @@ rabbitmq:
620617
"read": ".*"
621618
}],
622619
"exchanges": [{
623-
"name": "gitpod.ws",
624-
"vhost": "/",
625-
"type": "topic",
626-
"durable": true,
627-
"auto_delete": false
628-
}, {
629620
"name": "gitpod.ws.local",
630621
"vhost": "/",
631622
"type": "topic",
632623
"durable": true,
633624
"auto_delete": false
634-
}, {
635-
"name": "wsman",
636-
"vhost": "/",
637-
"type": "topic",
638-
"durable": false,
639-
"auto_delete": false
640625
}, {
641626
"name": "consensus-leader",
642627
"vhost": "/",
643628
"type": "fanout",
644629
"durable": false,
645630
"auto_delete": false
646631
}],
647-
"bindings": [{
648-
"source": "gitpod.ws.local",
649-
"vhost": "/",
650-
"destination": "gitpod.ws",
651-
"destination_type": "exchange",
652-
"routing_key": "#",
653-
"arguments": {}
654-
}],
632+
"bindings": [],
655633
"queues": [{
656634
"name": "consensus-peers",
657635
"vhost": "/",
@@ -687,25 +665,6 @@ rabbitmq:
687665
create: true
688666
minAvailable: 0
689667
maxUnavailable: 1
690-
shovelsTemplate: |
691-
{{ $auth := .Values.auth }}
692-
{{- range $index, $shovel := .Values.shovels }}
693-
- name: {{ $shovel.name | default (randAlphaNum 20) | quote }}
694-
vhost: "/"
695-
component: "shovel"
696-
value:
697-
ack-mode: "on-publish"
698-
src-delete-after: "never"
699-
src-exchange: {{ $shovel.srcExchange | default "gitpod.ws.local" | quote }}
700-
src-exchange-key: {{ $shovel.srcExchangeKey | default "#" | quote }}
701-
src-protocol: "amqp091"
702-
src-uri: {{ $shovel.srcUri | replace "$USERNAME" $auth.username | replace "$PASSWORD" $auth.password | quote }}
703-
dest-add-forward-headers: {{ $shovel.destAddForwardHeaders | default true }}
704-
dest-exchange: {{ $shovel.destExchange | default "gitpod.ws" | quote }}
705-
dest-protocol: "amqp091"
706-
dest-uri: {{ $shovel.destUri | default "amqp://" | quote }}
707-
reconnect-delay: {{ $shovel.reconnectDelay | default 5 }}
708-
{{- end }}
709668

710669
cert-manager:
711670
enabled: false

components/gitpod-messagebus/src/messagebus.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ const ASTERISK = "*";
7676

7777
@injectable()
7878
export class MessageBusHelperImpl implements MessageBusHelper {
79-
readonly workspaceExchange = MessageBusHelperImpl.WORKSPACE_EXCHANGE;
79+
readonly workspaceExchange = MessageBusHelperImpl.WORKSPACE_EXCHANGE_LOCAL;
8080

8181
/**
8282
* Ensures that the gitpod workspace exchange is present
@@ -155,7 +155,6 @@ export class MessageBusHelperImpl implements MessageBusHelper {
155155
}
156156

157157
export namespace MessageBusHelperImpl {
158-
export const WORKSPACE_EXCHANGE = "gitpod.ws";
159158
export const WORKSPACE_EXCHANGE_LOCAL = "gitpod.ws.local";
160159
export const PREBUILD_UPDATABLE_QUEUE = "pwsupdatable";
161160
}

components/server/src/workspace/messagebus-integration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export class MessageBusIntegration extends AbstractMessageBusIntegration {
176176
await this.messageBusHelper.assertWorkspaceExchange(this.channel);
177177

178178
// TODO(at) clarify on the exchange level
179-
await super.publish(MessageBusHelperImpl.WORKSPACE_EXCHANGE, topic, Buffer.from(JSON.stringify(prebuildInfo)));
179+
await super.publish(MessageBusHelperImpl.WORKSPACE_EXCHANGE_LOCAL, topic, Buffer.from(JSON.stringify(prebuildInfo)));
180180
}
181181

182182
async notifyOnInstanceUpdate(userId: string, instance: WorkspaceInstance) {

components/ws-manager-bridge/src/messagebus-integration.ts

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,14 @@
55
*/
66

77
import { injectable, inject } from 'inversify';
8-
import { MessageBusHelper, AbstractMessageBusIntegration, TopicListener, AbstractTopicListener, MessageBusHelperImpl } from "@gitpod/gitpod-messagebus/lib";
9-
import { Disposable, CancellationTokenSource } from 'vscode-jsonrpc';
10-
import { WorkspaceStatus } from '@gitpod/ws-manager/lib';
8+
import { MessageBusHelper, AbstractMessageBusIntegration, MessageBusHelperImpl } from "@gitpod/gitpod-messagebus/lib";
119
import { HeadlessWorkspaceEventType, WorkspaceInstance, HeadlessWorkspaceEvent, PrebuildWithStatus } from '@gitpod/gitpod-protocol';
1210
import { TraceContext } from '@gitpod/gitpod-protocol/lib/util/tracing';
1311

1412
@injectable()
1513
export class MessageBusIntegration extends AbstractMessageBusIntegration {
1614
@inject(MessageBusHelper) protected readonly messageBusHelper: MessageBusHelper;
1715

18-
async connect(): Promise<void> {
19-
await super.connect();
20-
if (!this.channel) {
21-
return
22-
}
23-
24-
await this.channel.assertExchange(MessageBusIntegration.WORKSPACE_EXCHANGE, 'topic', { 'durable': false });
25-
await this.channel.assertExchange(MessageBusIntegration.LOCAL_WORKSPACE_EXCHANGE, 'topic', { 'durable': false });
26-
27-
await this.channel.bindExchange(MessageBusHelperImpl.WORKSPACE_EXCHANGE, MessageBusHelperImpl.WORKSPACE_EXCHANGE_LOCAL, "#");
28-
}
29-
30-
listenForWorkspaceStatusUpdates(topic: string, callback: (ctx: TraceContext, status: WorkspaceStatus.AsObject) => void): Disposable {
31-
const listener = new WorkspaceStatusUpdateListener(callback, MessageBusIntegration.WORKSPACE_EXCHANGE, topic);
32-
const cancellationTokenSource = new CancellationTokenSource()
33-
this.listen(listener, cancellationTokenSource.token);
34-
return Disposable.create(() => cancellationTokenSource.cancel())
35-
}
36-
3716
async notifyOnPrebuildUpdate(prebuildInfo: PrebuildWithStatus) {
3817
if (!this.channel) {
3918
throw new Error("Not connected to message bus");
@@ -94,19 +73,3 @@ export class MessageBusIntegration extends AbstractMessageBusIntegration {
9473
}
9574

9675
}
97-
98-
export namespace MessageBusIntegration {
99-
export const WORKSPACE_EXCHANGE = "wsman";
100-
export const LOCAL_WORKSPACE_EXCHANGE = "wsman.local";
101-
}
102-
103-
class WorkspaceStatusUpdateListener extends AbstractTopicListener<WorkspaceStatus.AsObject> {
104-
105-
constructor(listener: TopicListener<WorkspaceStatus.AsObject>, workspaceExchange: string, protected readonly _topic: string) {
106-
super(MessageBusIntegration.WORKSPACE_EXCHANGE, listener);
107-
}
108-
109-
topic() {
110-
return this._topic;
111-
}
112-
}

installer/pkg/components/rabbitmq/helm.go

Lines changed: 2 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -108,76 +108,20 @@ type config struct {
108108
Policies []policy `json:"policies"`
109109
}
110110

111-
func generateParameters(username string, password string, input []parameter) ([]parameter, error) {
112-
// Ensures this defaults to [] not null when marshalled to JSON
113-
params := make([]parameter, 0)
114-
115-
for _, item := range input {
116-
// Sort out default values
117-
if item.Name == "" {
118-
name, err := common.RandomString(20)
119-
if err != nil {
120-
return nil, err
121-
}
122-
item.Name = name
123-
}
124-
if item.Values.SrcExchange == "" {
125-
item.Values.SrcExchange = "gitpod.ws.local"
126-
}
127-
if item.Values.SrcExchangeKey == "" {
128-
item.Values.SrcExchangeKey = "#"
129-
}
130-
if item.Values.DestExchange == "" {
131-
item.Values.DestExchange = "gitpod.ws"
132-
}
133-
if item.Values.DestUri == "" {
134-
item.Values.DestUri = "amqp://"
135-
}
136-
137-
srcUri := strings.Replace(item.Values.SrcUri, "$USERNAME", username, -1)
138-
srcUri = strings.Replace(srcUri, "$PASSWORD", password, -1)
139-
140-
params = append(params, parameter{
141-
Name: item.Name,
142-
Vhost: "/",
143-
Component: "shovel",
144-
Values: parameterValues{
145-
AckMode: "on-publish",
146-
SrcDeleteAfter: "never",
147-
SrcExchange: item.Values.SrcExchange,
148-
SrcExchangeKey: item.Values.SrcExchangeKey,
149-
SrcProtocol: "amqp091",
150-
SrcUri: srcUri,
151-
DestAddForwardHeaders: item.Values.DestAddForwardHeaders,
152-
DestExchange: item.Values.DestExchange,
153-
DestProtocol: "amqp091",
154-
DestUri: item.Values.DestUri,
155-
ReconnectDelay: item.Values.ReconnectDelay,
156-
},
157-
})
158-
}
159-
return params, nil
160-
}
161-
162111
var Helm = common.CompositeHelmFunc(
163112
helm.ImportTemplate(charts.RabbitMQ(), helm.TemplateConfig{}, func(cfg *common.RenderContext) (*common.HelmConfig, error) {
164113
username := "gitpod"
165114

166115
password := cfg.Values.MessageBusPassword
167116

168-
parameters, err := generateParameters(username, password, []parameter{})
169-
if err != nil {
170-
return nil, err
171-
}
172-
173117
loadDefinition, err := json.Marshal(config{
174118
Users: []user{{
175119
Name: username,
176120
Password: password,
177121
Tags: "administrator",
178122
}},
179123
Vhosts: []vhost{{Name: "/"}},
180-
Parameters: parameters,
124+
Parameters: []parameter{},
181125
Permissions: []permission{{
182126
User: username,
183127
Vhost: "/",
@@ -186,38 +130,19 @@ var Helm = common.CompositeHelmFunc(
186130
Read: ".*",
187131
}},
188132
Exchanges: []exchange{{
189-
Name: "gitpod.ws",
190-
Vhost: "/",
191-
Type: "topic",
192-
Durable: true,
193-
AutoDelete: false,
194-
}, {
195133
Name: "gitpod.ws.local",
196134
Vhost: "/",
197135
Type: "topic",
198136
Durable: true,
199137
AutoDelete: false,
200-
}, {
201-
Name: "wsman",
202-
Vhost: "/",
203-
Type: "topic",
204-
Durable: false,
205-
AutoDelete: false,
206138
}, {
207139
Name: "consensus-leader",
208140
Vhost: "/",
209141
Type: "fanout",
210142
Durable: false,
211143
AutoDelete: false,
212144
}},
213-
Bindings: []binding{{
214-
Source: "gitpod.ws.local",
215-
Vhost: "/",
216-
Destination: "gitpod.ws",
217-
DestinationType: "exchange",
218-
RoutingKey: "#",
219-
Arguments: arguments{},
220-
}},
145+
Bindings: []binding{},
221146
Queues: []queue{{
222147
Name: "consensus-peers",
223148
Vhost: "/",
@@ -251,16 +176,6 @@ var Helm = common.CompositeHelmFunc(
251176
return nil, err
252177
}
253178

254-
shovelsTemplate, err := yaml.Marshal(parameters)
255-
if err != nil {
256-
return nil, err
257-
}
258-
259-
shovelsTemplateFileName, err := helm.KeyFileValue("shovelsTemplate", shovelsTemplate)
260-
if err != nil {
261-
return nil, err
262-
}
263-
264179
affinity, err := helm.AffinityYaml(cluster.AffinityLabelMeta)
265180
if err != nil {
266181
return nil, err
@@ -293,7 +208,6 @@ var Helm = common.CompositeHelmFunc(
293208
FileValues: []string{
294209
affinityTemplate,
295210
loadDefinitionFilename,
296-
shovelsTemplateFileName,
297211
},
298212
},
299213
}, nil

installer/third_party/charts/rabbitmq/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ rabbitmq:
2626
enabled: true
2727
allowExternal: true
2828
plugins: "rabbitmq_management rabbitmq_peer_discovery_k8s"
29-
extraPlugins: "rabbitmq_shovel rabbitmq_shovel_management"
29+
extraPlugins: ""
3030
loadDefinition:
3131
enabled: true
3232
existingSecret: load-definition

0 commit comments

Comments
 (0)