-
Notifications
You must be signed in to change notification settings - Fork 472
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
Open
kevinrr888
wants to merge
5
commits into
apache:main
Choose a base branch
from
kevinrr888:3.1-feature-4892-part2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c71cf4a
New checks for `admin check` command
kevinrr888 fe97ad6
simplified checks for compactors ZK locks and scan servers ZK locks
kevinrr888 fbfa1fc
Merge remote-tracking branch 'upstream/main' into 3.1-feature-4892-part2
kevinrr888 7edd220
Merge branch 'main' into 3.1-feature-4892-part2
kevinrr888 48b828a
Merge branch 'main' into 3.1-feature-4892-part2
kevinrr888 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 0 additions & 51 deletions
51
server/base/src/main/java/org/apache/accumulo/server/conf/CheckServerConfig.java
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
...e/src/main/java/org/apache/accumulo/server/util/checkCommand/ServerConfigCheckRunner.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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.GENERAL_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); | ||
| 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; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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
instance.volumestheir types would need change from something besides STRING that is more specific, which would be a good general change to make (would be good to have specific type to do validation for instance volumes and that could include not accepting empty string).If the rest of the code worked like this, then would not need this list here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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
PropertyType.STRINGwhen a String isn't really what the property is.PropertyTypeexists to check that the property is valid; setting thePropertyTypetoSTRINGis just a way to ignore this validation. I wonder if it would be best for a 1 to 1 mappingPropertytoPropertyType. This would probably be overkill though, another idea could be to analyze thePropertyTypes that are always valid. From briefly looking,PropertyType.PATH,PropertyType.STRING,PropertyType.URIare always valid. I don't think any properties should always be valid. Those that arePropertyType.STRINGcould probably be given a more appropriate existingPropertyTypeor a new one.PATHandURIcould have validation.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
Property. Maybe for now/in this PR this list of required props is only accessed/checked in thisadmin check. Might be a bit of a scope creep to start checking this list elsewhere in the code. Could do it in follow on.There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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,
instance.volumeswould need to be a required property (which would be tied to validation in it'sPropertyType) and would need to be moved away fromPropertyType.STRING