forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
72394: build: build the docker image in teamcity r=jlinder a=ZhouXing19 This commit builds the docker image based on script from `build/deploy`, and saves the docker image in the artifacts directory. Note: the associated build configuration is at `Cockroach >> Scratch Project >> Build Docker Image` ([here](https://teamcity.cockroachdb.com/viewType.html?buildTypeId=Cockroach_ScratchProjectPutTcExperimentsInHere_JaneDockerImage&tab=buildTypeStatusDiv&branch_Cockroach_ScratchProjectPutTcExperimentsInHere=72394)). Once this PR is merged, we will move this config to `Cockroach > CI > Builds`. Please run this config upon this branch (cockroachdb#72394). Release note: None 73776: rpc: use system certificates when certs dir not specified or empty r=yecs1999 a=yecs1999 Previously, we always required either a certs dir path to be specified as an option or a root cert path in the connection url. This was incorrect because when sslmode was set to "require" or any other mode which did not require certificate checking, not specifying a certs dir would cause an error asking for one. Another problem was that in modes that did need certificate checking, like "verify-full" and "verify-ca", we did not first check the system trust store for any available certificates. To address this, this patch removes the requirement that certificate paths need to be checked for require or disable sslmodes. Also removed is the error when certificates were required, we now check the system trust store for the CA. This only applies to deployments which use certs ultimately signed by a public CA, such as CockroachCloud serverless (which uses LetsEncrypt) or when using a publicly rooted CA chain. It does not apply to certificates derived from a CA generated via "cockroach cert create-ca". This also allows us to reduce the number of steps required to connect to CockroachCloud serverless clusters by not having the user download a certificate they already have. Fixes cockroachdb#70946. Release note (cli change): Not finding the right certs in the certs dir or not specifying a certs dir or certificate path will now fall back on checking server CA using Go's TLS code to find the certificates in the OS trust store. If no matching certificate is found, then an x509 error will occur announcing that the certificate is signed by an unknown authority. Release note (bug fix): Setting sslmode=require would check for local certificates, so omitting a certs path would cause an error even though "require" does not verify server certificates. This has been fixed by bypassing certificate path checking for sslmode=require. This bug has been present since 21.2.0. Co-authored-by: Jane Xing <[email protected]> Co-authored-by: yecs1999 <[email protected]>
- Loading branch information
Showing
10 changed files
with
231 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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,50 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
dir="$(dirname $(dirname $(dirname $(dirname $(dirname "${0}")))))" | ||
source "$dir/teamcity-support.sh" # For $root | ||
|
||
# The artifacts dir should match up with that supplied by TC. | ||
artifacts=$PWD/artifacts | ||
mkdir -p "${artifacts}" | ||
chmod o+rwx "${artifacts}" | ||
|
||
tc_start_block "Copy cockroach binary and dependency files to build/deploy" | ||
|
||
# Get the cockroach binary from Build (Linux x86_64) | ||
# Artifacts rules: | ||
# bazel-bin/pkg/cmd/cockroach/cockroach_/cockroach=>upstream_artifacts | ||
# bazel-bin/c-deps/libgeos/lib/libgeos.so=>upstream_artifacts | ||
# bazel-bin/c-deps/libgeos/lib/libgeos_c.so=>upstream_artifacts | ||
cp upstream_artifacts/cockroach\ | ||
upstream_artifacts/libgeos.so \ | ||
upstream_artifacts/libgeos_c.so \ | ||
build/deploy | ||
|
||
cp -r licenses build/deploy/ | ||
|
||
chmod 755 build/deploy/cockroach | ||
|
||
tc_end_block "Copy cockroach binary and dependency files to build/deploy" | ||
|
||
tc_start_block "Build and save docker image to artifacts" | ||
|
||
docker_image_tar_name="cockroach-docker-image.tar" | ||
|
||
docker_tag="cockroachdb/cockroach-ci" | ||
|
||
docker build \ | ||
--no-cache \ | ||
--tag="$docker_tag" \ | ||
build/deploy | ||
|
||
docker save "$docker_tag" | gzip > "${artifacts}/${docker_image_tar_name}".gz | ||
|
||
cp upstream_artifacts/cockroach "${artifacts}"/cockroach | ||
|
||
docker_fsnotify_dir="$(dirname "${0}")/docker-fsnotify" | ||
cd $docker_fsnotify_dir && go build | ||
cp ./docker-fsnotify "${artifacts}"/docker-fsnotify | ||
|
||
tc_end_block "Build and save docker image to artifacts" | ||
|
15 changes: 15 additions & 0 deletions
15
build/teamcity/cockroach/ci/builds/docker-fsnotify/BUILD.bazel
This file contains 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,15 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") | ||
|
||
go_library( | ||
name = "docker-fsnotify_lib", | ||
srcs = ["ListenFileCreation.go"], | ||
importpath = "github.com/cockroachdb/cockroach/build/teamcity/cockroach/ci/builds/docker-fsnotify", | ||
visibility = ["//visibility:private"], | ||
deps = ["@com_github_fsnotify_fsnotify//:fsnotify"], | ||
) | ||
|
||
go_binary( | ||
name = "docker-fsnotify", | ||
embed = [":docker-fsnotify_lib"], | ||
visibility = ["//visibility:public"], | ||
) |
113 changes: 113 additions & 0 deletions
113
build/teamcity/cockroach/ci/builds/docker-fsnotify/ListenFileCreation.go
This file contains 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,113 @@ | ||
// Copyright 2021 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
// Usage: go run ./ListenFileChange.go parent_folder_path file_name [timeout_duration] | ||
|
||
package main | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"log" | ||
"os" | ||
"path/filepath" | ||
"strconv" | ||
"strings" | ||
"time" | ||
|
||
"github.com/fsnotify/fsnotify" | ||
) | ||
|
||
type result struct { | ||
finished bool | ||
err error | ||
} | ||
|
||
const defaultTimeout = 30 | ||
|
||
func main() { | ||
|
||
if len(os.Args) < 2 { | ||
panic(fmt.Errorf("must provide the folder to watch and the file to listen to")) | ||
} | ||
|
||
var err error | ||
|
||
folderPath := os.Args[1] | ||
wantedFileName := os.Args[2] | ||
|
||
timeout := defaultTimeout | ||
|
||
if len(os.Args) > 3 { | ||
timeoutArg := os.Args[3] | ||
timeout, err = strconv.Atoi(timeoutArg) | ||
if err != nil { | ||
panic(fmt.Errorf("timeout argument must be an integer: %v", err)) | ||
} | ||
} | ||
|
||
watcher, err := fsnotify.NewWatcher() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
defer watcher.Close() | ||
|
||
done := make(chan result) | ||
|
||
go func() { | ||
for { | ||
if _, err := os.Stat(filepath.Join(folderPath, wantedFileName)); errors.Is(err, os.ErrNotExist) { | ||
} else { | ||
done <- result{finished: true, err: nil} | ||
} | ||
time.Sleep(time.Second * 1) | ||
} | ||
}() | ||
|
||
go func() { | ||
for { | ||
select { | ||
case event, ok := <-watcher.Events: | ||
if !ok { | ||
return | ||
} | ||
fileName := event.Name[strings.LastIndex(event.Name, "/")+1:] | ||
if event.Op&fsnotify.Write == fsnotify.Write && fileName == wantedFileName { | ||
done <- result{finished: true, err: nil} | ||
} | ||
case err, ok := <-watcher.Errors: | ||
if !ok { | ||
return | ||
} | ||
done <- result{finished: false, err: err} | ||
} | ||
} | ||
}() | ||
|
||
err = watcher.Add(folderPath) | ||
if err != nil { | ||
fmt.Printf("error: %v", err) | ||
return | ||
} | ||
|
||
select { | ||
case res := <-done: | ||
if res.finished && res.err == nil { | ||
fmt.Println("finished") | ||
} else { | ||
fmt.Printf("error: %v", res.err) | ||
} | ||
|
||
case <-time.After(time.Duration(timeout) * time.Second): | ||
fmt.Printf("timeout for %d second", timeout) | ||
} | ||
|
||
return | ||
} |
This file contains 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 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 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 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 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 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 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