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

Block readiness on bad initial file settings #107775

Merged
Merged
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
Expand Up @@ -251,7 +251,6 @@ private void writeFileSettings(String json) throws Exception {
logger.info("--> New file settings: [{}]", Strings.format(json, version));
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/107744")
public void testNotReadyOnBadFileSettings() throws Exception {
internalCluster().setBootstrapMasterNodeIndex(0);
logger.info("--> start data node / non master node");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public record ReservedStateMetadata(
ReservedStateErrorMetadata errorMetadata
) implements SimpleDiffable<ReservedStateMetadata>, ToXContentFragment {

public static final Long NO_VERSION = Long.MIN_VALUE; // use min long as sentinel for uninitialized version

private static final ParseField VERSION = new ParseField("version");
private static final ParseField HANDLERS = new ParseField("handlers");
private static final ParseField ERRORS_METADATA = new ParseField("errors");
Expand Down Expand Up @@ -209,7 +211,7 @@ public static class Builder {
*/
public Builder(String namespace) {
this.namespace = namespace;
this.version = -1L;
this.version = NO_VERSION;
this.handlers = new HashMap<>();
this.errorMetadata = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public void clusterChanged(ClusterChangedEvent event) {
// protected to allow mock service to override
protected boolean areFileSettingsApplied(ClusterState clusterState) {
ReservedStateMetadata fileSettingsMetadata = clusterState.metadata().reservedStateMetadata().get(FileSettingsService.NAMESPACE);
return fileSettingsMetadata != null;
return fileSettingsMetadata != null && fileSettingsMetadata.version().equals(ReservedStateMetadata.NO_VERSION) == false;
}

private void setReady(boolean ready) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.Collections;
import java.util.List;

import static org.elasticsearch.cluster.metadata.ReservedStateMetadata.NO_VERSION;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;

Expand Down Expand Up @@ -78,7 +79,7 @@ public void testXContent() throws IOException {

public void testReservedStateVersionWithError() {
final ReservedStateMetadata meta = createRandom(false, true);
assertEquals(-1L, meta.version().longValue());
assertEquals(NO_VERSION.longValue(), meta.version().longValue());
}

private static ReservedStateMetadata createRandom(boolean addHandlers, boolean addErrors) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ public void testToXContentAPIReservedMetadata() throws IOException {
},
"reserved_state" : {
"namespace_one" : {
"version" : -1,
"version" : -9223372036854775808,
"handlers" : {
"one" : {
"keys" : [
Expand All @@ -801,7 +801,7 @@ public void testToXContentAPIReservedMetadata() throws IOException {
}
},
"namespace_two" : {
"version" : -1,
"version" : -9223372036854775808,
"handlers" : {
"three" : {
"keys" : [
Expand Down