-
Notifications
You must be signed in to change notification settings - Fork 483
Completed functionality for admin check command
#5348
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
Changes from 7 commits
c71cf4a
fe97ad6
fbfa1fc
7edd220
48b828a
815d246
9d77743
f695fe1
ed10610
9aa52a5
1af0ad3
666a8ca
8a0488c
9195889
ca914ea
fb77696
89e2185
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.apache.accumulo.server.util.checkCommand; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
|
|
||
| import org.apache.accumulo.core.conf.Property; | ||
| import org.apache.accumulo.server.ServerContext; | ||
| import org.apache.accumulo.server.cli.ServerUtilOpts; | ||
| import org.apache.accumulo.server.util.Admin; | ||
|
|
||
| public class ServerConfigCheckRunner implements CheckRunner { | ||
| private static final Admin.CheckCommand.Check check = Admin.CheckCommand.Check.SERVER_CONFIG; | ||
|
|
||
| @Override | ||
| public Admin.CheckCommand.CheckStatus runCheck(ServerContext context, ServerUtilOpts opts, | ||
| boolean fixFiles) throws Exception { | ||
| Admin.CheckCommand.CheckStatus status = Admin.CheckCommand.CheckStatus.OK; | ||
| printRunning(); | ||
|
|
||
| log.trace("********** Checking server configuration **********"); | ||
|
|
||
| log.trace("Checking that all configured properties are valid (valid key and value)"); | ||
| final Map<String,String> definedProps = new HashMap<>(); | ||
| final var config = context.getConfiguration(); | ||
| config.getProperties(definedProps, s -> true); | ||
| for (var entry : definedProps.entrySet()) { | ||
| var key = entry.getKey(); | ||
| var val = entry.getValue(); | ||
| if (!Property.isValidProperty(key, val)) { | ||
| log.warn("Invalid property (key={} val={}) found in the config", key, val); | ||
| status = Admin.CheckCommand.CheckStatus.FAILED; | ||
| } | ||
| } | ||
|
|
||
| log.trace("Checking that all required config properties are present"); | ||
| // there are many properties that should be set (default value or user set), identifying them | ||
| // all and checking them here is unrealistic. Some property that is not set but is expected | ||
| // will likely result in some sort of failure eventually anyway. We will just check a few | ||
| // obvious required properties here. | ||
| Set<Property> requiredProps = Set.of(Property.INSTANCE_ZK_HOST, Property.INSTANCE_ZK_TIMEOUT, | ||
| Property.INSTANCE_SECRET, Property.INSTANCE_VOLUMES, Property.GENERAL_THREADPOOL_SIZE, | ||
| Property.GENERAL_DELEGATION_TOKEN_LIFETIME, | ||
| Property.GENERAL_DELEGATION_TOKEN_UPDATE_INTERVAL, Property.GENERAL_IDLE_PROCESS_INTERVAL, | ||
| Property.GENERAL_LOW_MEM_DETECTOR_INTERVAL, Property.GENERAL_LOW_MEM_DETECTOR_THRESHOLD, | ||
| Property.RPC_PROCESS_BIND_ADDRESS, Property.GENERAL_SERVER_LOCK_VERIFICATION_INTERVAL, | ||
| Property.MANAGER_CLIENTPORT, Property.TSERV_CLIENTPORT, Property.GC_CYCLE_START, | ||
| Property.GC_CYCLE_DELAY, Property.GC_PORT, Property.MONITOR_PORT, Property.TABLE_MAJC_RATIO, | ||
| Property.TABLE_SPLIT_THRESHOLD); | ||
|
Comment on lines
+55
to
+67
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any other important ones I left out? Any I shouldn't have included?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a change for this PR, but wondering if this should be pushed to the validation code of each property. For example could we attempt to do something like the following in addition to the code that goes through the defined props above. Thinking if a props validation fails on null or empty string then its "required" and should be set. Looking at some of the important props, like for(var prop : Property.values()) {
var value = config.get(prop);
if (!Property.isValidProperty(prop.getKey(), value)) {
log.warn("Invalid property (key={} val={}) found in the config", prop, value);
}
}If the rest of the code worked like this, then would not need this list here.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As the code is currently written it loops over all the props the loop in the prev comment may not work well because the get method replaces w/ the default value when not present. In general it seems like it would be best to move the concept of a required property into the Property class in some form. Then the entire system could react appropriately when a required property is not present and is requested. For now a list in this class seems fine. I experimented w/ validating the volume prop in #5365 based on the exploration done as part of this.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This sounds like a good idea to me. There are a lot of In addition to this, can analyze all properties, determine if they are required or not, and change the validation:
Like you said, for this PR, can just push this list of required properties into
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Definitely want to avoid any scope creep in this PR. Identified some areas that need improvement based on this work, we can open follow on issues or PRs for those.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could leave the list as is in the PR. For follow on issues, do we need two issues? One for addressing the STRING types and another for somehow representing and documenting required props in the Property.java?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think either would be fine, but it might be easier as just one issue. There would be overlap in these changes so might be hard to split up/work on as two separate issues/PRs. For example, |
||
| for (var reqProp : requiredProps) { | ||
| var confPropVal = config.get(reqProp); | ||
| // already checked that all set properties are valid, just check that it is set then we know | ||
| // it's valid | ||
| if (confPropVal == null || confPropVal.isEmpty()) { | ||
| log.warn("Required property {} is not set!", reqProp); | ||
| status = Admin.CheckCommand.CheckStatus.FAILED; | ||
| } | ||
| } | ||
|
|
||
| printCompleted(status); | ||
| return status; | ||
| } | ||
|
|
||
| @Override | ||
| public Admin.CheckCommand.Check getCheck() { | ||
| return check; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.