Skip to content

Commit

Permalink
Remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
APErebus committed Dec 15, 2023
1 parent 3760e03 commit 6b7c444
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 57 deletions.
18 changes: 0 additions & 18 deletions source/Octopus.Tentacle/Kubernetes/KubernetesJobService.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
using System;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using k8s;
using k8s.Autorest;
using k8s.Models;
using Octopus.Tentacle.Contracts;

namespace Octopus.Tentacle.Kubernetes
{
public interface IKubernetesJobService
{
Task<V1Job?> TryGet(ScriptTicket scriptTicket, CancellationToken cancellationToken);
string BuildJobName(ScriptTicket scriptTicket);
Task CreateJob(V1Job job, CancellationToken cancellationToken);
Task Delete(ScriptTicket scriptTicket, CancellationToken cancellationToken);
Expand All @@ -26,21 +23,6 @@ public KubernetesJobService(IKubernetesClientConfigProvider configProvider)
{
}

public async Task<V1Job?> TryGet(ScriptTicket scriptTicket, CancellationToken cancellationToken)
{
var jobName = BuildJobName(scriptTicket);

try
{
return await Client.ReadNamespacedJobStatusAsync(jobName, KubernetesConfig.Namespace, cancellationToken: cancellationToken);
}
catch (HttpOperationException opException)
when (opException.Response.StatusCode == HttpStatusCode.NotFound)
{
return null;
}
}

public async Task SuspendJob(ScriptTicket scriptTicket, CancellationToken cancellationToken)
{
var jobName = BuildJobName(scriptTicket);
Expand Down
1 change: 0 additions & 1 deletion source/Octopus.Tentacle/Kubernetes/KubernetesModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<KubernetesJobService>().As<IKubernetesJobService>().SingleInstance();
builder.RegisterType<KubernetesClusterService>().As<IKubernetesClusterService>().SingleInstance();
builder.RegisterType<KubernetesPodService>().As<IKubernetesPodService>().SingleInstance();
builder.RegisterType<KubernetesJobContainerResolver>().As<IKubernetesJobContainerResolver>().SingleInstance();

#if DEBUG
Expand Down
31 changes: 0 additions & 31 deletions source/Octopus.Tentacle/Kubernetes/KubernetesPodService.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ namespace Octopus.Tentacle.Kubernetes.Scripts
public class KubernetesJobScriptExecutor : IScriptExecutor
{
readonly IKubernetesJobService jobService;
readonly IKubernetesPodService podService;
readonly IKubernetesJobContainerResolver containerResolver;
readonly IApplicationInstanceSelector appInstanceSelector;
readonly ISystemLog log;

public KubernetesJobScriptExecutor(IKubernetesJobService jobService, IKubernetesPodService podService, IKubernetesJobContainerResolver containerResolver, IApplicationInstanceSelector appInstanceSelector, ISystemLog log)
public KubernetesJobScriptExecutor(IKubernetesJobService jobService, IKubernetesJobContainerResolver containerResolver, IApplicationInstanceSelector appInstanceSelector, ISystemLog log)
{
this.jobService = jobService;
this.podService = podService;
this.containerResolver = containerResolver;
this.appInstanceSelector = appInstanceSelector;
this.log = log;
Expand All @@ -29,7 +27,7 @@ public KubernetesJobScriptExecutor(IKubernetesJobService jobService, IKubernetes

public IRunningScript ExecuteOnBackgroundThread(StartScriptCommandV3Alpha command, IScriptWorkspace workspace, ScriptStateStore scriptStateStore, CancellationToken cancellationToken)
{
var runningScript = new RunningKubernetesJob(workspace, workspace.CreateLog(), command.ScriptTicket, command.TaskId, log, scriptStateStore, jobService, podService, containerResolver, appInstanceSelector, cancellationToken);
var runningScript = new RunningKubernetesJob(workspace, workspace.CreateLog(), command.ScriptTicket, command.TaskId, log, scriptStateStore, jobService, containerResolver, appInstanceSelector, cancellationToken);

Task.Run(() => runningScript.Execute(), cancellationToken);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public class RunningKubernetesJob : IRunningScript
readonly ILog log;
readonly IScriptStateStore stateStore;
readonly IKubernetesJobService jobService;
readonly IKubernetesPodService podService;
readonly IKubernetesJobContainerResolver containerResolver;
CancellationToken scriptCancellationToken;
readonly string? instanceName;
Expand All @@ -51,7 +50,6 @@ public RunningKubernetesJob(
ILog log,
IScriptStateStore stateStore,
IKubernetesJobService jobService,
IKubernetesPodService podService,
IKubernetesJobContainerResolver containerResolver,
IApplicationInstanceSelector appInstanceSelector,
CancellationToken scriptCancellationToken)
Expand All @@ -62,7 +60,6 @@ public RunningKubernetesJob(
this.log = log;
this.stateStore = stateStore;
this.jobService = jobService;
this.podService = podService;
this.containerResolver = containerResolver;
this.scriptCancellationToken = scriptCancellationToken;
ScriptLog = scriptLog;
Expand Down

0 comments on commit 6b7c444

Please sign in to comment.