Skip to content

Commit

Permalink
add MastodonServer's name to selector
Browse files Browse the repository at this point in the history
  • Loading branch information
ushitora-anqou committed Sep 12, 2024
1 parent 3df96c2 commit 92d8b01
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
2 changes: 2 additions & 0 deletions charts/magout-mastodon-server/templates/gateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ spec:
app.kubernetes.io/name: nginx
app.kubernetes.io/component: gateway
app.kubernetes.io/part-of: mastodon
magout.anqou.net/mastodon-server: {{ include "magout-mastodon-server.fullname" . }}
template:
metadata:
labels:
app.kubernetes.io/name: nginx
app.kubernetes.io/component: gateway
app.kubernetes.io/part-of: mastodon
magout.anqou.net/mastodon-server: {{ include "magout-mastodon-server.fullname" . }}
spec:
initContainers:
- name: copy-assets
Expand Down
2 changes: 2 additions & 0 deletions charts/magout-mastodon-server/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ spec:
app.kubernetes.io/name: puma
app.kubernetes.io/component: web
app.kubernetes.io/part-of: mastodon
magout.anqou.net/mastodon-server: {{ include "magout-mastodon-server.fullname" . }}
---
apiVersion: v1
kind: Service
Expand All @@ -31,3 +32,4 @@ spec:
app.kubernetes.io/name: node
app.kubernetes.io/component: streaming
app.kubernetes.io/part-of: mastodon
magout.anqou.net/mastodon-server: {{ include "magout-mastodon-server.fullname" . }}
7 changes: 4 additions & 3 deletions internal/controller/mastodonserver_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,9 +605,10 @@ func (r *MastodonServerReconciler) createOrUpdateDeployment(
}

selector := map[string]string{
"app.kubernetes.io/name": appName,
"app.kubernetes.io/component": string(component),
"app.kubernetes.io/part-of": "mastodon",
"app.kubernetes.io/name": appName,
"app.kubernetes.io/component": string(component),
"app.kubernetes.io/part-of": "mastodon",
"magout.anqou.net/mastodon-server": server.GetName(),
}
deploy.Spec.Selector = &metav1.LabelSelector{
MatchLabels: selector,
Expand Down
15 changes: 8 additions & 7 deletions test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,10 @@ func checkDeployAnnotation(name, namespace, key, expectedValue string) error {
return nil
}

func checkPodAge(namespace, component string, smallerThan time.Duration) error {
stdout, _, err := kubectl(nil, "get", "pod", "-n", namespace,
"-l", "app.kubernetes.io/component="+component, "-o", "json")
func checkPodAge(mastodonServerName, namespace, component string, smallerThan time.Duration) error {
stdout, _, err := kubectl(nil, "get", "pod", "-n", namespace, "-l", "-o", "json",
fmt.Sprintf("app.kubernetes.io/component=%s,magout.anqou.net/mastodon-server=%s",
component, mastodonServerName))
if err != nil {
return err
}
Expand Down Expand Up @@ -319,16 +320,16 @@ var _ = Describe("controller", Ordered, func() {
Expect(err).NotTo(HaveOccurred())

Eventually(func() error {
return checkPodAge(namespace, "web", 30*time.Second)
return checkPodAge("mastodon0", namespace, "web", 30*time.Second)
}).Should(Succeed())
Consistently(func() error {
return checkPodAge(namespace, "web", 90*time.Second)
return checkPodAge("mastodon0", namespace, "web", 90*time.Second)
}, "100s", "1s").Should(Succeed())
Eventually(func() error {
return checkPodAge(namespace, "sidekiq", 30*time.Second)
return checkPodAge("mastodon0", namespace, "sidekiq", 30*time.Second)
}).Should(Succeed())
Consistently(func() error {
return checkPodAge(namespace, "sidekiq", 90*time.Second)
return checkPodAge("mastodon0", namespace, "sidekiq", 90*time.Second)
}, "100s", "1s").Should(Succeed())

_, _, err = kubectl(nil, "delete", "-n", namespace, "mastodonserver", "mastodon0")
Expand Down

0 comments on commit 92d8b01

Please sign in to comment.