Skip to content

Commit

Permalink
Use debug auditlog
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia committed Aug 16, 2024
1 parent 6d6f54a commit 9f46737
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,6 @@ protected EphemeralCluster(TConfiguration clusterConfiguration) : base(clusterCo

protected EphemeralClusterComposer<TConfiguration> Composer { get; }

protected override void ModifyNodeConfiguration(NodeConfiguration nodeConfiguration, int port)
{
base.ModifyNodeConfiguration(nodeConfiguration, port);

if (!ClusterConfiguration.EnableSsl) nodeConfiguration.Add("plugins.security.disabled", "true");
}

public virtual ICollection<Uri> NodesUris(string hostName = null)
{
hostName = hostName ?? (ClusterConfiguration.HttpFiddlerAware && Process.GetProcessesByName("fiddler").Any()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,74 +29,74 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using OpenSearch.OpenSearch.Ephemeral.Plugins;
using OpenSearch.OpenSearch.Ephemeral.Tasks;
using OpenSearch.OpenSearch.Managed.Configuration;
using OpenSearch.Stack.ArtifactsApi;
using OpenSearch.Stack.ArtifactsApi.Products;

namespace OpenSearch.OpenSearch.Ephemeral
namespace OpenSearch.OpenSearch.Ephemeral;

public class EphemeralClusterConfiguration : ClusterConfiguration<EphemeralFileSystem>
{
public class EphemeralClusterConfiguration : ClusterConfiguration<EphemeralFileSystem>
{
public EphemeralClusterConfiguration(OpenSearchVersion version, OpenSearchPlugins plugins = null,
int numberOfNodes = 1)
: this(version, ClusterFeatures.None, plugins, numberOfNodes)
{
}

public EphemeralClusterConfiguration(OpenSearchVersion version, ClusterFeatures features,
OpenSearchPlugins plugins = null, int numberOfNodes = 1)
: base(version, (v, s) => new EphemeralFileSystem(v, s), numberOfNodes, EphemeralClusterName)
{
Features = features;

var pluginsList = plugins?.ToList() ?? new List<OpenSearchPlugin>();
Plugins = new OpenSearchPlugins(pluginsList);
}

private static string UniqueishSuffix => Guid.NewGuid().ToString("N").Substring(0, 6);
private static string EphemeralClusterName => $"ephemeral-cluster-{UniqueishSuffix}";

/// <summary>
/// The features supported by the cluster
/// </summary>
public ClusterFeatures Features { get; }

/// <summary>
/// The collection of plugins to install
/// </summary>
public OpenSearchPlugins Plugins { get; }

/// <summary>
/// Validates that the plugins to install can be installed on the target OpenSearch version.
/// This can be useful to fail early when subsequent operations are relying on installation
/// succeeding.
/// </summary>
public bool ValidatePluginsToInstall { get; } = true;

public bool EnableSsl => Features.HasFlag(ClusterFeatures.SSL);

public IList<IClusterComposeTask> AdditionalBeforeNodeStartedTasks { get; } = new List<IClusterComposeTask>();

public IList<IClusterComposeTask> AdditionalAfterStartedTasks { get; } = new List<IClusterComposeTask>();

/// <summary>
/// Expert level setting, skips all built-in validation tasks for cases where you need to guarantee your call is the
/// first call into the cluster
/// </summary>
public bool SkipBuiltInAfterStartTasks { get; set; }

/// <summary> Bootstrapping HTTP calls should attempt to auto route traffic through fiddler if its running </summary>
public bool HttpFiddlerAware { get; set; }

protected virtual string NodePrefix => "ephemeral";

public override string CreateNodeName(int? node)
{
var suffix = Guid.NewGuid().ToString("N").Substring(0, 6);
return $"{NodePrefix}-node-{suffix}{node}";
}
}
public EphemeralClusterConfiguration(OpenSearchVersion version, OpenSearchPlugins plugins = null,
int numberOfNodes = 1)
: this(version, ClusterFeatures.None, plugins, numberOfNodes)
{
}

public EphemeralClusterConfiguration(OpenSearchVersion version, ClusterFeatures features,
OpenSearchPlugins plugins = null, int numberOfNodes = 1)
: base(version, (v, s) => new EphemeralFileSystem(v, s), numberOfNodes, EphemeralClusterName)
{
Features = features;

var pluginsList = plugins?.ToList() ?? [];
Plugins = new OpenSearchPlugins(pluginsList);

Add("plugins.security.disabled", (!EnableSsl).ToString());
if (EnableSsl) Add("plugins.security.audit.type", "debug");
}

private static string UniqueishSuffix => Guid.NewGuid().ToString("N").Substring(0, 6);
private static string EphemeralClusterName => $"ephemeral-cluster-{UniqueishSuffix}";

/// <summary>
/// The features supported by the cluster
/// </summary>
public ClusterFeatures Features { get; }

/// <summary>
/// The collection of plugins to install
/// </summary>
public OpenSearchPlugins Plugins { get; }

/// <summary>
/// Validates that the plugins to install can be installed on the target OpenSearch version.
/// This can be useful to fail early when subsequent operations are relying on installation
/// succeeding.
/// </summary>
public bool ValidatePluginsToInstall { get; } = true;

public bool EnableSsl => Features.HasFlag(ClusterFeatures.SSL);

public IList<IClusterComposeTask> AdditionalBeforeNodeStartedTasks { get; } = new List<IClusterComposeTask>();

public IList<IClusterComposeTask> AdditionalAfterStartedTasks { get; } = new List<IClusterComposeTask>();

/// <summary>
/// Expert level setting, skips all built-in validation tasks for cases where you need to guarantee your call is the
/// first call into the cluster
/// </summary>
public bool SkipBuiltInAfterStartTasks { get; set; }

/// <summary> Bootstrapping HTTP calls should attempt to auto route traffic through fiddler if its running </summary>
public bool HttpFiddlerAware { get; set; }

protected virtual string NodePrefix => "ephemeral";

public override string CreateNodeName(int? node)
{
var suffix = Guid.NewGuid().ToString("N").Substring(0, 6);
return $"{NodePrefix}-node-{suffix}{node}";
}
}

0 comments on commit 9f46737

Please sign in to comment.