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

UI: add stores report page with CCL switching #26040

Merged
merged 1 commit into from
May 25, 2018
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
27 changes: 21 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,11 @@ GO_SOURCES := $(GO_PROTOS:%.proto=%.pb.go)
PBJS := $(NODE_RUN) $(UI_ROOT)/node_modules/.bin/pbjs
PBTS := $(NODE_RUN) $(UI_ROOT)/node_modules/.bin/pbts

JS_PROTOS_CCL := $(filter %/ccl/storageccl/engineccl/enginepbccl/key_registry.proto %/ccl/storageccl/engineccl/enginepbccl/stats.proto,$(GO_PROTOS))
UI_JS_CCL := $(UI_ROOT)/ccl/src/js/protos.js
UI_TS_CCL := $(UI_ROOT)/ccl/src/js/protos.d.ts
UI_PROTOS_CCL := $(UI_JS_CCL) $(UI_TS_CCL)

UI_JS := $(UI_ROOT)/src/js/protos.js
UI_TS := $(UI_ROOT)/src/js/protos.d.ts
UI_PROTOS := $(UI_JS) $(UI_TS)
Expand All @@ -1021,8 +1026,6 @@ CPP_PROTOS_CCL := $(filter %/ccl/baseccl/encryption_options.proto %/ccl/storagec
CPP_HEADERS_CCL := $(subst $(PKG_ROOT),$(CPP_PROTO_CCL_ROOT),$(CPP_PROTOS_CCL:%.proto=%.pb.h))
CPP_SOURCES_CCL := $(subst $(PKG_ROOT),$(CPP_PROTO_CCL_ROOT),$(CPP_PROTOS_CCL:%.proto=%.pb.cc))

UI_PROTOS := $(UI_JS) $(UI_TS)

$(GOGOPROTO_PROTO): $(SUBMODULES_TARGET)

$(GO_PROTOS_TARGET): $(PROTOC) $(GO_PROTOS) $(GOGOPROTO_PROTO) $(BOOTSTRAP_TARGET) bin/protoc-gen-gogoroach
Expand Down Expand Up @@ -1076,6 +1079,18 @@ $(UI_TS): $(UI_JS) $(YARN_INSTALLED_TARGET)
echo '// GENERATED FILE DO NOT EDIT' > $@
$(PBTS) $(UI_JS) >> $@

.SECONDARY: $(UI_JS_CCL)
$(UI_JS_CCL): $(JS_PROTOS_CCL) $(YARN_INSTALLED_TARGET)
# Add comment recognized by reviewable.
echo '// GENERATED FILE DO NOT EDIT' > $@
$(PBJS) -t static-module -w es6 --strict-long --keep-case --path $(PKG_ROOT) --path $(GOGO_PROTOBUF_PATH) --path $(COREOS_PATH) --path $(GRPC_GATEWAY_GOOGLEAPIS_PATH) $(GW_PROTOS) $(JS_PROTOS_CCL) >> $@

.SECONDARY: $(UI_TS_CCL)
$(UI_TS_CCL): $(UI_JS_CCL) $(YARN_INSTALLED_TARGET)
# Add comment recognized by reviewable.
echo '// GENERATED FILE DO NOT EDIT' > $@
$(PBTS) $(UI_JS_CCL) >> $@

STYLINT := ./node_modules/.bin/stylint
TSLINT := ./node_modules/.bin/tslint
KARMA := ./node_modules/.bin/karma
Expand All @@ -1087,7 +1102,7 @@ WEBPACK_DASHBOARD := ./opt/node_modules/.bin/webpack-dashboard
ui-generate: $(UI_ROOT)/distccl/bindata.go

.PHONY: ui-lint
ui-lint: $(YARN_INSTALLED_TARGET) $(UI_PROTOS)
ui-lint: $(YARN_INSTALLED_TARGET) $(UI_PROTOS) $(UI_PROTOS_CCL)
$(NODE_RUN) -C $(UI_ROOT) $(STYLINT) -c .stylintrc styl
$(NODE_RUN) -C $(UI_ROOT) $(TSLINT) -c tslint.json -p tsconfig.json
@# TODO(benesch): Invoke tslint just once when palantir/tslint#2827 is fixed.
Expand All @@ -1113,7 +1128,7 @@ UI_MANIFESTS := $(UI_ROOT)/protos-manifest.json $(UI_ROOT)/vendor-manifest.json
# [0]: https://stackoverflow.com/a/3077254/1122351
# [1]: http://savannah.gnu.org/bugs/?19108
.SECONDARY: $(UI_DLLS) $(UI_MANIFESTS)
$(UI_ROOT)/dist/%.dll.js $(UI_ROOT)/%-manifest.json: $(UI_ROOT)/webpack.%.js $(YARN_INSTALLED_TARGET) $(UI_PROTOS)
$(UI_ROOT)/dist/%.dll.js $(UI_ROOT)/%-manifest.json: $(UI_ROOT)/webpack.%.js $(YARN_INSTALLED_TARGET) $(UI_PROTOS) $(UI_PROTOS_CCL)
$(NODE_RUN) -C $(UI_ROOT) $(WEBPACK) -p --config webpack.$*.js

.PHONY: ui-test
Expand All @@ -1124,7 +1139,7 @@ ui-test: $(UI_DLLS) $(UI_MANIFESTS)
ui-test-watch: $(UI_DLLS) $(UI_MANIFESTS)
$(NODE_RUN) -C $(UI_ROOT) $(KARMA) start --no-single-run --auto-watch

$(UI_ROOT)/dist%/bindata.go: $(UI_ROOT)/webpack.%.js $(UI_DLLS) $(UI_JS) $(UI_MANIFESTS) $(shell find $(UI_ROOT)/ccl $(UI_ROOT)/src $(UI_ROOT)/styl -type f)
$(UI_ROOT)/dist%/bindata.go: $(UI_ROOT)/webpack.%.js $(UI_DLLS) $(UI_JS) $(UI_JS_CCL) $(UI_MANIFESTS) $(shell find $(UI_ROOT)/ccl $(UI_ROOT)/src $(UI_ROOT)/styl -type f)
@# TODO(benesch): remove references to embedded.go once sufficient time has passed.
rm -f $(UI_ROOT)/embedded.go
find $(UI_ROOT)/dist$* -mindepth 1 -not -name dist$*.go -delete
Expand Down Expand Up @@ -1310,7 +1325,7 @@ clean: clean-c-deps
.PHONY: maintainer-clean
maintainer-clean: ## Like clean, but also remove some auto-generated source code.
maintainer-clean: clean ui-maintainer-clean
rm -f $(SQLPARSER_TARGETS) $(OPTGEN_TARGETS) $(UI_PROTOS)
rm -f $(SQLPARSER_TARGETS) $(OPTGEN_TARGETS) $(UI_PROTOS) $(UI_PROTOS_CCL)

.PHONY: unsafe-clean
unsafe-clean: ## Like maintainer-clean, but also remove ALL untracked/ignored files.
Expand Down
4 changes: 4 additions & 0 deletions build/variables.mk
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ define VALID_VARS
ISDARWIN
JEMALLOC_DIR
JEMALLOC_SRC_DIR
JS_PROTOS_CCL
KARMA
LC_COLLATE
LIBROACH_DIR
Expand Down Expand Up @@ -135,10 +136,13 @@ define VALID_VARS
TYPE
UI_DLLS
UI_JS
UI_JS_CCL
UI_MANIFESTS
UI_PROTOS
UI_PROTOS_CCL
UI_ROOT
UI_TS
UI_TS_CCL
UNAME
WEBPACK
WEBPACK_DASHBOARD
Expand Down
2 changes: 2 additions & 0 deletions pkg/ui/ccl/src/js/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
protos.d.ts
protos.js
32 changes: 32 additions & 0 deletions pkg/ui/ccl/src/views/reports/containers/stores/encryption.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from "react";

import * as protos from "src/js/protos";

interface EncryptionStatusProps {
store: protos.cockroach.server.serverpb.StoreDetails$Properties;
}

export default class EncryptionStatus extends React.Component<EncryptionStatusProps, {}> {

renderSimpleRow(header: string, value: string) {
return (
<tr className="stores-table__row">
<th className="stores-table__cell stores-table__cell--header">{header}</th>
<td className="stores-table__cell" title={value}><pre>{value}</pre></td>
</tr>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should style this a bit to make it more readable. Add a file encryption.styl next to this tsx file, with contents like this: https://github.com/cockroachdb/cockroach/blob/07e2b77d390874e057ec99758c33167f410144c7/pkg/ui/src/views/cluster/containers/nodeOverview/nodeOverview.styl

Except.stores-table instead of just .table. Also make sure to import the styl file from this tsx file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, but with a fixed width for th as we end up with two different tables.
encryption

);
}

render(): React.ReactElement<any> {
const { store } = this.props;
const rawStatus = store.encryption_status;

try {
const decodedStatus = protos.cockroach.ccl.storageccl.engineccl.enginepbccl.EncryptionStatus.decode(rawStatus);
return this.renderSimpleRow("Encryption Status", JSON.stringify(decodedStatus.toJSON(), null, 2));
} catch (e) {
console.log("Error decoding protobuf: ", e);
return null;
}
}
}
3 changes: 3 additions & 0 deletions pkg/ui/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import Nodes from "src/views/reports/containers/nodes";
import ReduxDebug from "src/views/reports/containers/redux";
import Range from "src/views/reports/containers/range";
import Settings from "src/views/reports/containers/settings";
import Stores from "src/views/reports/containers/stores";

// NOTE: If you are adding a new path to the router, and that path contains any
// components that are personally identifying information, you MUST update the
Expand Down Expand Up @@ -143,6 +144,8 @@ ReactDOM.render(
<Route path={`certificates/:${nodeIDAttr}`} component={ Certificates } />
<Route path={`range/:${rangeIDAttr}`} component={ Range } />
<Route path={`range/:${rangeIDAttr}/cmdqueue`} component={ CommandQueue } />
<Route path={`stores/:${nodeIDAttr}`} component={ Stores } />

</Route>

{ /* old route redirects */ }
Expand Down
14 changes: 14 additions & 0 deletions pkg/ui/src/redux/apiReducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,18 @@ export const settingsReducerObj = new CachedDataReducer(
);
export const refreshSettings = settingsReducerObj.refresh;

export const storesRequestKey = (req: api.StoresRequestMessage): string =>
_.isEmpty(req.node_id) ? "none" : req.node_id;

const storesReducerObj = new KeyedCachedDataReducer(
api.getStores,
"stores",
storesRequestKey,
moment.duration(0),
moment.duration(1, "m"),
);
export const refreshStores = storesReducerObj.refresh;

export interface APIReducersState {
cluster: CachedDataReducerState<api.ClusterResponseMessage>;
events: CachedDataReducerState<api.EventsResponseMessage>;
Expand All @@ -252,6 +264,7 @@ export interface APIReducersState {
rangeLog: KeyedCachedDataReducerState<api.RangeLogResponseMessage>;
commandQueue: KeyedCachedDataReducerState<api.CommandQueueResponseMessage>;
settings: CachedDataReducerState<api.SettingsResponseMessage>;
stores: KeyedCachedDataReducerState<api.StoresResponseMessage>;
}

export const apiReducersReducer = combineReducers<APIReducersState>({
Expand All @@ -278,6 +291,7 @@ export const apiReducersReducer = combineReducers<APIReducersState>({
[rangeLogReducerObj.actionNamespace]: rangeLogReducerObj.reducer,
[commandQueueReducerObj.actionNamespace]: commandQueueReducerObj.reducer,
[settingsReducerObj.actionNamespace]: settingsReducerObj.reducer,
[storesReducerObj.actionNamespace]: storesReducerObj.reducer,
});

export { CachedDataReducerState, KeyedCachedDataReducerState };
2 changes: 1 addition & 1 deletion pkg/ui/src/util/api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ describe("rest api", function() {

return api.getHealth(new protos.cockroach.server.serverpb.HealthRequest()).then((result) => {
assert.lengthOf(fetchMock.calls(healthUrl), 1);
assert.deepEqual(result, new protos.cockroach.server.serverpb.HealthResponse());
assert.deepEqual(result.toJSON(), new protos.cockroach.server.serverpb.HealthResponse().toJSON());
});
});

Expand Down
8 changes: 8 additions & 0 deletions pkg/ui/src/util/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ export type SettingsResponseMessage = protos.cockroach.server.serverpb.SettingsR
export type UserLoginRequestMessage = protos.cockroach.server.serverpb.UserLoginRequest;
export type UserLoginResponseMessage = protos.cockroach.server.serverpb.UserLoginResponse;

export type StoresRequestMessage = protos.cockroach.server.serverpb.StoresRequest;
export type StoresResponseMessage = protos.cockroach.server.serverpb.StoresResponse;

// API constants

export const API_PREFIX = "_admin/v1";
Expand Down Expand Up @@ -318,4 +321,9 @@ export function userLogin(req: UserLoginRequestMessage, timeout?: moment.Duratio
return timeoutFetch(serverpb.UserLoginResponse, `${AUTH_PREFIX}/login`, req as any, timeout);
}

// getStores returns information about a node's stores.
export function getStores(req: StoresRequestMessage, timeout?: moment.Duration): Promise<StoresResponseMessage> {
return timeoutFetch(serverpb.StoresResponse, `${STATUS_PREFIX}/stores/${req.node_id}`, null, timeout);
}

// TODO(vilterp): logout
13 changes: 13 additions & 0 deletions pkg/ui/src/views/reports/containers/debug/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ export default function Debug() {
note="#/reports/nodes?locality=[regex]"
/>
</DebugTableRow>
<DebugTableRow title="Stores">
<DebugTableLink name="Stores on this node" url="#/reports/stores/local" />
<DebugTableLink
name="Stores on a specific node"
url="#/reports/stores/1"
note="#/reports/stores/[node_id]"
/>
</DebugTableRow>
<DebugTableRow title="Localities">
<DebugTableLink name="Locality Tree" url="#/reports/localities" />
</DebugTableRow>
Expand Down Expand Up @@ -174,6 +182,11 @@ export default function Debug() {
/>
</DebugTableRow>
<DebugTableRow title="Single Node Specific">
<DebugTableLink
name="Stores"
url="/_status/stores/local"
note="/_status/stores/[node_id]"
/>
<DebugTableLink
name="Gossip"
url="/_status/gossip/local"
Expand Down
14 changes: 14 additions & 0 deletions pkg/ui/src/views/reports/containers/stores/encryption.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from "react";

import * as protos from "src/js/protos";

interface EncryptionStatusProps {
store: protos.cockroach.server.serverpb.StoreDetails$Properties;
}

export default class EncryptionStatus extends React.Component<EncryptionStatusProps, {}> {

render(): React.ReactElement<any> {
return null;
}
}
Loading