Commit 957f904f authored by Konstantinos Poulakakis's avatar Konstantinos Poulakakis
Browse files

refactor: Remove test exception. Add the correct exception to failure mechanism. Add kubernetes yml

parent 5d996788
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -20,8 +20,6 @@ public class GeneralExceptionHandler implements ExceptionHandlerProvider {
    public Throwable transform(Throwable t) {
        if (t instanceof ExternalServiceFailureException) {
            return new StatusRuntimeException(Status.INTERNAL.withDescription(t.getMessage()));
        } else if (t instanceof NewException) {
            return new StatusRuntimeException(Status.UNIMPLEMENTED.withDescription(t.getMessage()));
        } else {
            return ExceptionHandlerProvider.toStatusException(t, true);
        }
+0 −12
Original line number Diff line number Diff line
package org.etsi.tfs.policy.exception;

public class NewException extends RuntimeException {

    public NewException(String message, Exception e) {
        super(message, e);
    }

    public NewException(String message) {
        super(message);
    }
}
+2 −3
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ import jakarta.inject.Inject;
import java.util.List;
import org.etsi.tfs.policy.context.ContextService;
import org.etsi.tfs.policy.context.model.ServiceId;
import org.etsi.tfs.policy.exception.NewException;
import org.etsi.tfs.policy.exception.ExternalServiceFailureException;
import org.etsi.tfs.policy.monitoring.model.AlarmDescriptor;
import org.etsi.tfs.policy.policy.model.PolicyRule;
import org.etsi.tfs.policy.policy.model.PolicyRuleBasic;
@@ -21,7 +21,6 @@ import org.jboss.logging.Logger;

@ApplicationScoped
public class AddPolicyServiceImpl {
    private static final Logger LOGGER = Logger.getLogger(AddPolicyServiceImpl.class);

    @Inject private CommonPolicyServiceImpl commonPolicyService;
    @Inject private CommonAlarmService commonAlarmService;
@@ -65,7 +64,7 @@ public class AddPolicyServiceImpl {
        return contextService
                .setPolicyRule(policyRule)
                .onFailure()
                .transform(failure -> new NewException(failure.getMessage()))
                .transform(failure -> new ExternalServiceFailureException(failure.getMessage()))
                .onItem()
                .transform(
                        policyId -> {
+133 −0
Original line number Diff line number Diff line
---
apiVersion: v1
kind: Service
metadata:
  annotations:
    app.quarkus.io/commit-id: 5d9967880633c624761e6089a8592ec74959d299
    app.quarkus.io/build-timestamp: 2024-03-28 - 14:39:32 +0000
    prometheus.io/scrape: "true"
    prometheus.io/path: /q/metrics
    prometheus.io/port: "8080"
    prometheus.io/scheme: http
  labels:
    app.kubernetes.io/name: policyservice
    app.kubernetes.io/version: 0.1.0
    app: policyservice
    app.kubernetes.io/managed-by: quarkus
  name: policyservice
spec:
  ports:
    - name: https
      port: 443
      protocol: TCP
      targetPort: 8443
    - name: http
      port: 9192
      protocol: TCP
      targetPort: 8080
    - name: grpc
      port: 6060
      protocol: TCP
      targetPort: 6060
  selector:
    app.kubernetes.io/name: policyservice
  type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    app.quarkus.io/commit-id: 5d9967880633c624761e6089a8592ec74959d299
    app.quarkus.io/build-timestamp: 2024-03-28 - 14:39:32 +0000
    prometheus.io/scrape: "true"
    prometheus.io/path: /q/metrics
    prometheus.io/port: "8080"
    prometheus.io/scheme: http
  labels:
    app: policyservice
    app.kubernetes.io/managed-by: quarkus
    app.kubernetes.io/name: policyservice
    app.kubernetes.io/version: 0.1.0
  name: policyservice
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: policyservice
  template:
    metadata:
      annotations:
        app.quarkus.io/commit-id: 5d9967880633c624761e6089a8592ec74959d299
        app.quarkus.io/build-timestamp: 2024-03-28 - 14:39:32 +0000
        prometheus.io/scrape: "true"
        prometheus.io/path: /q/metrics
        prometheus.io/port: "8080"
        prometheus.io/scheme: http
      labels:
        app: policyservice
        app.kubernetes.io/managed-by: quarkus
        app.kubernetes.io/name: policyservice
        app.kubernetes.io/version: 0.1.0
    spec:
      containers:
        - env:
            - name: KUBERNETES_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: CONTEXT_SERVICE_HOST
              value: contextservice
            - name: MONITORING_SERVICE_HOST
              value: monitoringservice
            - name: SERVICE_SERVICE_HOST
              value: serviceservice
          image: labs.etsi.org:5050/tfs/controller/policy:0.1.0
          imagePullPolicy: Always
          livenessProbe:
            failureThreshold: 3
            httpGet:
              path: /q/health/live
              port: 8080
              scheme: HTTP
            initialDelaySeconds: 2
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 10
          name: policyservice
          ports:
            - containerPort: 8443
              name: https
              protocol: TCP
            - containerPort: 8080
              name: http
              protocol: TCP
            - containerPort: 6060
              name: grpc
              protocol: TCP
          readinessProbe:
            failureThreshold: 3
            httpGet:
              path: /q/health/ready
              port: 8080
              scheme: HTTP
            initialDelaySeconds: 2
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 10
          resources:
            limits:
              cpu: 500m
              memory: 2048Mi
            requests:
              cpu: 50m
              memory: 512Mi
          startupProbe:
            failureThreshold: 3
            httpGet:
              path: /q/health/started
              port: 8080
              scheme: HTTP
            initialDelaySeconds: 5
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 10