Skip to content

Commit

Permalink
Merge branch 'master' into fix/rule-get-edges-transform
Browse files Browse the repository at this point in the history
  • Loading branch information
Sophie-Xie authored Jun 17, 2022
2 parents 89db82f + 0ad5c38 commit ce28e81
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 10 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ jobs:
tags: |
vesoft/nebula-graphd:nightly
target: graphd
cache-to: type=local,dest=/tmp/buildx-cache,mode=max
push: true
- uses: docker/build-push-action@v2
with:
Expand All @@ -91,6 +92,7 @@ jobs:
tags: |
vesoft/nebula-storaged:nightly
target: storaged
cache-from: type=local,src=/tmp/buildx-cache
push: true
- uses: docker/build-push-action@v2
with:
Expand All @@ -100,6 +102,7 @@ jobs:
tags: |
vesoft/nebula-metad:nightly
target: metad
cache-from: type=local,src=/tmp/buildx-cache
push: true
- uses: docker/build-push-action@v2
with:
Expand All @@ -109,7 +112,11 @@ jobs:
tags: |
vesoft/nebula-tools:nightly
target: tools
cache-from: type=local,src=/tmp/buildx-cache
push: true
- name: delete the cache
run: |
rm -rf /tmp/buildx-cache
coverage:
name: coverage
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/rc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ jobs:
${{ secrets.HARBOR_REGISTRY }}/vesoft/nebula-graphd:${{ steps.tagname.outputs.majorver }}
${{ steps.docker.outputs.graphdTag }}
target: graphd
cache-to: type=local,dest=/tmp/buildx-cache,mode=max
push: true
build-args: |
BRANCH=${{ steps.tagname.outputs.tag }}
Expand All @@ -133,6 +134,7 @@ jobs:
${{ steps.docker.outputs.storagedTag }}
target: storaged
push: true
cache-from: type=local,src=/tmp/buildx-cache
build-args: |
BRANCH=${{ steps.tagname.outputs.tag }}
VERSION=${{ steps.tagname.outputs.tagnum }}
Expand All @@ -148,6 +150,7 @@ jobs:
${{ steps.docker.outputs.metadTag }}
target: metad
push: true
cache-from: type=local,src=/tmp/buildx-cache
build-args: |
BRANCH=${{ steps.tagname.outputs.tag }}
VERSION=${{ steps.tagname.outputs.tagnum }}
Expand All @@ -163,9 +166,13 @@ jobs:
${{ steps.docker.outputs.toolsTag }}
target: tools
push: true
cache-from: type=local,src=/tmp/buildx-cache
build-args: |
BRANCH=${{ steps.tagname.outputs.tag }}
VERSION=${{ steps.tagname.outputs.tagnum }}
- name: delete the cache
run: |
rm -rf /tmp/buildx-cache
test:
name: test
needs: package
Expand Down
15 changes: 10 additions & 5 deletions src/daemons/MetaDaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,16 @@ int main(int argc, char* argv[]) {
}
if (nebula::value(ret) == localhost) {
LOG(INFO) << "Check and init root user";
if (!nebula::meta::RootUserMan::isUserExists(gKVStore.get())) {
if (!nebula::meta::RootUserMan::initRootUser(gKVStore.get())) {
LOG(ERROR) << "Init root user failed";
return EXIT_FAILURE;
}
auto checkRet = nebula::meta::RootUserMan::isGodExists(gKVStore.get());
if (!nebula::ok(checkRet)) {
auto retCode = nebula::error(checkRet);
LOG(ERROR) << "Parser God Role error:" << apache::thrift::util::enumNameSafe(retCode);
return EXIT_FAILURE;
}
auto existGod = nebula::value(checkRet);
if (!existGod && !nebula::meta::RootUserMan::initRootUser(gKVStore.get())) {
LOG(ERROR) << "Init root user failed";
return EXIT_FAILURE;
}
}
}
Expand Down
15 changes: 10 additions & 5 deletions src/daemons/StandAloneDaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,16 @@ int main(int argc, char *argv[]) {
}
if (nebula::value(ret) == metaLocalhost) {
LOG(INFO) << "Check and init root user";
if (!nebula::meta::RootUserMan::isUserExists(gMetaKVStore.get())) {
if (!nebula::meta::RootUserMan::initRootUser(gMetaKVStore.get())) {
LOG(ERROR) << "Init root user failed";
return;
}
auto checkRet = nebula::meta::RootUserMan::isGodExists(gMetaKVStore.get());
if (!nebula::ok(checkRet)) {
auto retCode = nebula::error(checkRet);
LOG(ERROR) << "Parser God Role error:" << apache::thrift::util::enumNameSafe(retCode);
return;
}
auto existGod = nebula::value(checkRet);
if (!existGod && !nebula::meta::RootUserMan::initRootUser(gMetaKVStore.get())) {
LOG(ERROR) << "Init root user failed";
return;
}
}
}
Expand Down
20 changes: 20 additions & 0 deletions src/meta/RootUserMan.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,26 @@ namespace meta {
* */
class RootUserMan {
public:
static ErrorOr<nebula::cpp2::ErrorCode, bool> isGodExists(kvstore::KVStore* kv) {
auto rolePrefix = MetaKeyUtils::roleSpacePrefix(kDefaultSpaceId);
std::unique_ptr<kvstore::KVIterator> iter;
auto code = kv->prefix(kDefaultSpaceId, kDefaultPartId, rolePrefix, &iter, false);
if (code != nebula::cpp2::ErrorCode::SUCCEEDED) {
return code;
}
while (iter->valid()) {
auto val = iter->val();
auto type = *reinterpret_cast<const meta::cpp2::RoleType*>(val.begin());
if (type == meta::cpp2::RoleType::GOD) {
LOG(INFO) << "God user exists";
return true;
}
iter->next();
}
LOG(INFO) << "God user is not exists";
return false;
}

static bool isUserExists(kvstore::KVStore* kv) {
auto userKey = MetaKeyUtils::userKey("root");
std::string val;
Expand Down

0 comments on commit ce28e81

Please sign in to comment.