-
Notifications
You must be signed in to change notification settings - Fork 3
Route backend jobs to use correct image #993
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
|
|
||
| namespace App\Jobs; | ||
|
|
||
| use App\Services\MediaWikiHostResolver; | ||
| use Illuminate\Bus\Queueable; | ||
| use Illuminate\Contracts\Queue\ShouldBeUnique; | ||
| use Illuminate\Contracts\Queue\ShouldQueue; | ||
|
|
@@ -27,14 +28,28 @@ public function uniqueId(): string { | |
| return $this->wikiDomain; | ||
| } | ||
|
|
||
| public function handle(Client $kubernetesClient): void { | ||
| public function handle(Client $kubernetesClient, MediaWikiHostResolver $resolver): void { | ||
| $domain = $resolver->getBackendHostForDomain($this->wikiDomain); | ||
| $serviceName = $domain; | ||
| $kubernetesClient->setNamespace('default'); | ||
| $backendService = $kubernetesClient->services()->setLabelSelector([ | ||
| 'name' => $serviceName, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if it will work like this, as the name of the service seems more like see
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, you're totally right. I just took the first bit. Apparently also the LabelSelector was wrong and I should have used the field one with |
||
| ])->first(); | ||
|
|
||
| if ($backendService === null) { | ||
| $this->fail( | ||
| new \RuntimeException( | ||
| 'Unable to find a matching MediaWiki backend service in the cluster' | ||
| ) | ||
| ); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| $MWPodSelector = $backendService->toArray()['spec']['selector']; | ||
| $mediawikiPod = $kubernetesClient->pods()->setFieldSelector([ | ||
| 'status.phase' => 'Running', | ||
| ])->setLabelSelector([ | ||
| 'app.kubernetes.io/name' => 'mediawiki', | ||
| 'app.kubernetes.io/component' => 'app-backend', | ||
| ])->first(); | ||
| ])->setLabelSelector($MWPodSelector)->first(); | ||
|
|
||
| if ($mediawikiPod === null) { | ||
| $this->fail( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while reading I confused this
$domainvar with a wiki domain, I'd suggest$mwBackendHostor somethingThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea; I picked a different name. I can see why you were confused for sure. I wanted to make it clear that this isn't a host like an ip but actually a domain for a service. Hopefully this makes sense now.