Skip to content
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

89 check aliens + refactoring #97

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System;
using BobToolsCli.Exceptions;

namespace BobToolsCli.ConfigurationReading
{
Expand Down Expand Up @@ -27,7 +28,10 @@ public ConfigurationReadingResult<Y> Map<Y>(Func<T, Y> f)
return ConfigurationReadingResult<Y>.Ok(f(_data));
}

public T Unwrap() => IsOk(out var d, out var e) ? d : throw new ConfigurationException(e);

public static ConfigurationReadingResult<T> Ok(T data) => new(data, null);

public static ConfigurationReadingResult<T> Error(string error) => new(default, error);
}
}
}
34 changes: 32 additions & 2 deletions src/ClusterModifier/ClusterExpandArguments.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using BobApi.BobEntities;
using BobToolsCli;
using BobToolsCli.Exceptions;
using CommandLine;
Expand All @@ -15,6 +18,9 @@ public class ClusterExpandArguments : CommonWithSshArguments
[Option("dry-run", Required = false, HelpText = "Do not copy anything")]
public bool DryRun { get; set; } = false;

[Option("test-run", Required = false, HelpText = "Special testing run with no interactions with cluster")]
public bool TestRun { get; set; } = false;

[Option("remove-unused-replicas", Required = false, HelpText = "Remove files in unused replicas")]
public bool RemoveUnusedReplicas { get; set; } = false;

Expand All @@ -27,7 +33,31 @@ public class ClusterExpandArguments : CommonWithSshArguments
[Option("copy-parallel-degree", HelpText = "Number of simultaneous copy processes", Default = 1)]
public int CopyParallelDegree { get; set; }

public string FindRootDir(string node)
[Option("skip-alien-presence-check", HelpText = "Do not check for alien existence before cluster expansion", Default = false)]
public bool SkipAlienPresenceCheck { get; set; }

public async ValueTask<string> GetRootDir(
ClusterConfiguration.Node node,
CancellationToken cancellationToken = default
)
{
var rootDir = FindRootDirOverride(node.Name);
if (rootDir == null)
{
var client = GetBobApiClientProvider().GetClient(node);
var nodeConfigResult = await client.GetNodeConfiguration(cancellationToken);
if (nodeConfigResult.IsOk(out var conf, out var error))
rootDir = conf.RootDir;
else
throw new ClusterStateException(
$"Node {node.Name} configuration is unavailable: {error}, "
+ "and bob-root-dir does not contain enough information"
);
}
return rootDir;
}

private string FindRootDirOverride(string nodeName)
{
if (BobRootDirOverrides.Any())
{
Expand All @@ -37,7 +67,7 @@ public string FindRootDir(string node)
if (split.Length != 2)
throw new ConfigurationException("Malformed overrides argument");

if (split[0] == node || split[0] == "*")
if (split[0] == nodeName || split[0] == "*")
return split[1];
}
}
Expand Down
Loading
Loading