Skip to content

Commit

Permalink
fix: env vars for new ports - removed syncing state from workloads (#49)
Browse files Browse the repository at this point in the history
* fix: env vars for new ports - removed syncing state from workloads

* removed unneeded files
  • Loading branch information
avatxus authored Feb 12, 2024
1 parent 7686b23 commit a5e7207
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 93 deletions.
34 changes: 0 additions & 34 deletions bootstrap/test-workspace.yaml

This file was deleted.

27 changes: 0 additions & 27 deletions bootstrap/test.yaml

This file was deleted.

1 change: 0 additions & 1 deletion operator/src/backend-with-storage/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export default class BackendWithStorageOperator extends Operator {
console.log('UPDATING STATUS');
if ((!spec.enabled && RUNNING_STATUSES.includes(status.runningStatus)) || (spec.enabled && status.runningStatus === 'paused')) {
await this.patchResourceStatus(e.meta, {
runningStatus: 'syncing',
startTime: spec.enabled ? Date.now() : 0,
});
}
Expand Down
2 changes: 1 addition & 1 deletion operator/src/backend-with-storage/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export async function handleResource(
// await apps.replaceNamespacedStatefulSet(name, ns, sts(name, spec, owner, containerList, volumesList));
} catch (err: any) {
console.log(err?.body);
await core.createNamespacedConfigMap(ns, configmap(name, spec, owner));
await core.createNamespacedConfigMap(ns, configmap(name, spec, owner)).catch(err => console.log('configmap already exists'));
await apps.createNamespacedStatefulSet(ns, sts(name, spec, owner, containerList, volumesList));
}
}
Expand Down
4 changes: 2 additions & 2 deletions operator/src/backend/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Operator, { ResourceEventType, ResourceEvent } from '@dot-i/k8s-operator'
import { API_VERSION, API_GROUP, PLURAL } from './constants';
import { handleResource } from './handlers';

const RUNNING_STATUSES = ['running', 'provisioning', 'syncing', 'degraded', 'error']
const RUNNING_STATUSES = ['running', 'provisioning', 'syncing', 'degraded', 'error'];

export default class BackendOperator extends Operator {
constructor() {
Expand Down Expand Up @@ -56,9 +56,9 @@ export default class BackendOperator extends Operator {
const object = e.object as CustomResource<Backend.Spec, Backend.Status>;
const { metadata, status, spec } = object;
console.log('UPDATING STATUS');

if ((!spec.enabled && RUNNING_STATUSES.includes(status.runningStatus)) || (spec.enabled && status.runningStatus === 'paused')) {
await this.patchResourceStatus(e.meta, {
runningStatus: 'syncing',
startTime: spec.enabled ? Date.now() : 0,
});
}
Expand Down
2 changes: 1 addition & 1 deletion operator/src/backend/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export async function handleResource(
await updateResource(ns, name, spec, containerList, volumesList, owner);
} catch (err: any) {
console.log(err?.body);
await core.createNamespacedConfigMap(ns, configmap(name, spec, owner));
await core.createNamespacedConfigMap(ns, configmap(name, spec, owner)).catch(err => console.log('configmap already exists'));
await apps.createNamespacedDeployment(ns, deployment(name, spec, owner, containerList, volumesList));
}
}
Expand Down
1 change: 0 additions & 1 deletion operator/src/frontend/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export default class FrontendOperator extends Operator {
console.log('UPDATING STATUS');
if ((!spec.enabled && RUNNING_STATUSES.includes(status.runningStatus)) || (spec.enabled && status.runningStatus === 'paused')) {
await this.patchResourceStatus(e.meta, {
runningStatus: 'syncing',
startTime: spec.enabled ? Date.now() : 0,
});
}
Expand Down
2 changes: 1 addition & 1 deletion operator/src/frontend/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export async function handleResource(
await updateResource(ns, name, spec, containerList, volumesList);
} catch (err: any) {
console.log(err?.body);
await core.createNamespacedConfigMap(ns, configmap(name, spec, owner));
await core.createNamespacedConfigMap(ns, configmap(name, spec, owner)).catch(err => console.log('configmap already exists'));
await apps.createNamespacedDeployment(ns, deployment(name, spec, owner, containerList, volumesList));
}
}
Expand Down
48 changes: 24 additions & 24 deletions operator/src/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,42 @@ const nodesServiceV2 = nodesV2.SERVICE_PLUGIN;

/**
* Returns the metadata for a service given a service id
* @param id
* @returns
* @param id
* @returns
*/
export function getServiceMetadata(id: string): ServiceMetadata {
const service = getServicePlugin(id);
export function getServiceMetadata(id: string): ServiceMetadata | null {
const service = getServicePlugin(id);

if (!service) throw new Error(`Service with id: ${id} was not found`);
if (!service) return null;

return service.metadata;
return service.metadata;
}

/**
* Returns the reference to the service plugin given a service id
* @param id
* @returns
* @param id
* @returns
*/
export function getService(id: string): ServicePlugin {
const service = getServicePlugin(id);
if (!service) throw new Error(`Service with id: ${id} was not found`);
return service;
}
export function getService(id: string): ServicePlugin | null {
const service = getServicePlugin(id);

if (!service) return null;
return service;
}

/**
* The console has awareness of the service and is responsible of
* The console has awareness of the service and is responsible of
* registering the services available with access from its user interface
*/
export function registerServices() {
registerService(submitApiService);
registerService(nodesService);
registerService(ogmiosService);
registerService(kuberService);
registerService(kupoService);
registerService(blockfrostService);
registerService(dBSyncService);
registerService(marloweService);
registerService(dbSyncServiceV2);
registerService(nodesServiceV2);
registerService(submitApiService);
registerService(nodesService);
registerService(ogmiosService);
registerService(kuberService);
registerService(kupoService);
registerService(blockfrostService);
registerService(dBSyncService);
registerService(marloweService);
registerService(dbSyncServiceV2);
registerService(nodesServiceV2);
}
3 changes: 3 additions & 0 deletions operator/src/shared/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export async function getDependenciesForNetwork(project: ProjectSpec, network: N
export function isCardanoNodeEnabled(deps: DependencyResource[]): boolean {
for (const dep of deps) {
const service = getService(dep.spec.serviceId);
if (!service) continue;
if (service.metadata.kind === 'CardanoNode') {
return true;
}
Expand All @@ -23,6 +24,7 @@ export function isCardanoNodeEnabled(deps: DependencyResource[]): boolean {
export function cardanoNodeDep(deps: DependencyResource[]): { dependency: DependencyResource; service: ServicePlugin } | null {
for (const dep of deps) {
const service = getService(dep.spec.serviceId);
if (!service) continue;
if (service.metadata.kind === 'CardanoNode') {
return { dependency: dep, service };
}
Expand All @@ -35,6 +37,7 @@ export async function buildEnvVars(deps: DependencyResource[], network: Network)

for (const dep of deps) {
const service = getService(dep.spec.serviceId);
if (!service) continue;
if (service.metadata.kind === 'CardanoNode') {
const envVars = getCardanoNodeEnvVars(dep, service);
output.push(...envVars);
Expand Down
1 change: 0 additions & 1 deletion operator/src/workspaces/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export default class WorkspacesOperator extends Operator {
console.log('UPDATING STATUS');
if ((!spec.enabled && RUNNING_STATUSES.includes(status.runningStatus)) || (spec.enabled && status.runningStatus === 'paused')) {
await this.patchResourceStatus(e.meta, {
runningStatus: 'syncing',
startTime: spec.enabled ? Date.now() : 0,
});
}
Expand Down

0 comments on commit a5e7207

Please sign in to comment.