Skip to content

Commit

Permalink
show version compatibility in migration list (#20483)
Browse files Browse the repository at this point in the history
  • Loading branch information
moesterheld authored Sep 19, 2024
1 parent 10e2006 commit a51d072
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.graylog2.notifications.Notification;
import org.graylog2.notifications.NotificationService;
import org.graylog2.plugin.GlobalMetricNames;
import org.graylog2.plugin.Version;
import org.graylog2.plugin.certificates.RenewalPolicy;
import org.graylog2.plugin.cluster.ClusterConfigService;
import org.graylog2.rest.resources.datanodes.DatanodeResolver;
Expand Down Expand Up @@ -77,7 +76,6 @@ public class MigrationActionsImpl implements MigrationActions {
private final ElasticsearchVersionProvider searchVersionProvider;
private final List<URI> elasticsearchHosts;

private final Version graylogVersion = Version.CURRENT_CLASSPATH;
private final NotificationService notificationService;

@Inject
Expand Down Expand Up @@ -177,8 +175,7 @@ public boolean caAndRenewalPolicyExist() {
public boolean compatibleDatanodesRunning() {
Map<String, DataNodeDto> nodes = nodeService.allActive();
return !nodes.isEmpty() && nodes.values().stream()
.allMatch(node -> node.getDatanodeVersion() != null &&
graylogVersion.compareTo(new Version(com.github.zafarkhaja.semver.Version.valueOf(node.getDatanodeVersion()))) == 0);
.allMatch(DataNodeDto::isCompatibleWithVersion);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.graylog.security.certutil.CertRenewalService;
import org.graylog2.cluster.preflight.DataNodeProvisioningConfig;
import org.graylog2.datanode.DataNodeLifecycleTrigger;
import org.graylog2.plugin.Version;

import java.time.Instant;
import java.time.LocalDateTime;
Expand Down Expand Up @@ -60,14 +61,19 @@ public abstract class DataNodeDto extends NodeDto {
@JsonProperty("action_queue")
public abstract DataNodeLifecycleTrigger getActionQueue();

@jakarta.annotation.Nullable
@Nullable
@JsonProperty(FIELD_CERT_VALID_UNTIL)
public abstract Date getCertValidUntil();

@jakarta.annotation.Nullable
@Nullable
@JsonProperty(FIELD_DATANODE_VERSION)
public abstract String getDatanodeVersion();

@JsonProperty("version_compatible")
public boolean isCompatibleWithVersion() {
return getDatanodeVersion() != null &&
Version.CURRENT_CLASSPATH.compareTo(new Version(com.github.zafarkhaja.semver.Version.valueOf(getDatanodeVersion()))) == 0;
}

@Nullable
@JsonUnwrapped
Expand Down
1 change: 1 addition & 0 deletions graylog2-web-interface/src/components/datanode/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export type DataNode = {
cert_valid_until: string | null,
error_msg?: string,
datanode_version: string,
version_compatible: boolean,
}

export type DataNodes = Array<DataNode>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ const MigrationDatanodeList = ({ showProvisioningState }: Props) => {
) : (
<>
<h4>Data Nodes found: {dataNodes?.list.length}</h4>
{dataNodes.list.find((datanode) => !datanode.version_compatible) && (
<Alert bsStyle="warning" title="Incompatible Data Nodes found">
There are Data Nodes running with versions incompatible to your current Graylog version.
Please make sure to use the same version for both Graylog and Data Node.
</Alert>
)}
<br />
<Table bordered condensed striped hover>
<thead>
Expand All @@ -58,6 +64,7 @@ const MigrationDatanodeList = ({ showProvisioningState }: Props) => {
<th>Transport address</th>
<th>Status</th>
<th>Certificate valid until</th>
<th>Version</th>
</tr>
</thead>
<tbody>
Expand All @@ -67,6 +74,13 @@ const MigrationDatanodeList = ({ showProvisioningState }: Props) => {
<td>{datanode.transport_address}</td>
<td>{showProvisioningState ? datanode.status : datanode.data_node_status}</td>
<td>{datanode.cert_valid_until ? <RelativeTime dateTime={datanode.cert_valid_until} /> : 'No certificate'}</td>
<td>
{!datanode.version_compatible && (
<Icon name="warning"
title="This version is incompatible with your current Graylog version." />
)}
{datanode.datanode_version}
</td>
</tr>
))}
</tbody>
Expand Down

0 comments on commit a51d072

Please sign in to comment.