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

Watcher query timeout Backport Microk8s 1.28 #163

Merged
merged 8 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
5 changes: 3 additions & 2 deletions .github/workflows/build-snap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
pull_request:
branches:
- master
- 1.28

jobs:
build:
Expand All @@ -22,7 +23,7 @@ jobs:
sudo usermod --append --groups lxd $USER
sg lxd -c 'lxc version'
- name: Install snapcraft
run: sudo snap install snapcraft --classic
run: sudo snap install snapcraft --classic --channel=7.x/stable
- name: Build snap
run: |
sg lxd -c 'snapcraft --use-lxd'
Expand All @@ -41,7 +42,7 @@ jobs:
run: |
set -x
sudo snap install k8s-dqlite.snap --classic --dangerous
sudo snap install go --channel 1.18/stable --classic
sudo snap install go --channel 1.21/stable --classic
sudo apt install git
git clone https://github.com/etcd-io/etcd.git
cd etcd
Expand Down
3 changes: 3 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var opts = options.Options{
ProfilingListen: "127.0.0.1:40000",
DiskMode: false,
ClientSessionCacheSize: 0,
WatchQueryTimeout: 20 * time.Second,
}

// liteCmd represents the base command when called without any subcommands
Expand Down Expand Up @@ -67,6 +68,7 @@ var dqliteCmd = &cobra.Command{
opts.EnableTLS,
opts.DiskMode,
opts.ClientSessionCacheSize,
opts.WatchQueryTimeout,
)
if err != nil {
log.Fatalf("Failed to start server: %s\n", err)
Expand Down Expand Up @@ -109,4 +111,5 @@ func init() {
dqliteCmd.Flags().StringVar(&opts.ProfilingListen, "profiling-listen", opts.ProfilingListen, "listen address for pprof endpoint")
dqliteCmd.Flags().BoolVar(&opts.DiskMode, "disk-mode", opts.DiskMode, "(experimental) run dqlite store in disk mode")
dqliteCmd.Flags().UintVar(&opts.ClientSessionCacheSize, "tls-client-session-cache-size", opts.ClientSessionCacheSize, "ClientCacheSession size for dial TLS config")
dqliteCmd.Flags().DurationVar(&opts.WatchQueryTimeout, "watch-query-timeout", opts.WatchQueryTimeout, "timeout for querying events in the watch poll loop. If timeout is reached, the poll loop will be re-triggered. The minimum value is 5 seconds.")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the timeout

}
3 changes: 3 additions & 0 deletions app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ limitations under the License.

package options

import "time"

// Options is the list of options for running k8s-dqlite.
type Options struct {
StorageDir string
Expand All @@ -26,4 +28,5 @@ type Options struct {
ProfilingListen string
DiskMode bool
ClientSessionCacheSize uint
WatchQueryTimeout time.Duration
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ require (
k8s.io/component-base v0.18.0
)

replace github.com/rancher/kine => github.com/canonical/kine v0.4.1-k8s-dqlite.10
replace github.com/rancher/kine => github.com/canonical/kine v0.4.1-k8s-dqlite.11
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqO
github.com/blang/semver v3.5.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/canonical/go-dqlite v1.11.8 h1:yRnVotjd7xUXdVvTW2RoVWeUlBM7oF+/ylQfQlu9bQ8=
github.com/canonical/go-dqlite v1.11.8/go.mod h1:Uvy943N8R4CFUAs59A1NVaziWY9nJ686lScY7ywurfg=
github.com/canonical/kine v0.4.1-k8s-dqlite.10 h1:4R7m9tGV9RW6zwWWOSlCQEzww/0W5GpIRyZ1xvlA198=
github.com/canonical/kine v0.4.1-k8s-dqlite.10/go.mod h1:0xLHwFfgn9loFiIQTch7KBo7e0D2FHdCEei+9Vq5F04=
github.com/canonical/kine v0.4.1-k8s-dqlite.11 h1:1bOhb9j/F0cogBjNIaOqzXQ9hsJDDEwDP4WSKU1KUPY=
github.com/canonical/kine v0.4.1-k8s-dqlite.11/go.mod h1:0xLHwFfgn9loFiIQTch7KBo7e0D2FHdCEei+9Vq5F04=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA=
github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054 h1:uH66TXeswKn5PW5zdZ39xEwfS9an067BirqA+P4QaLI=
Expand Down
4 changes: 3 additions & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var (
defaultKineEp = "tcp://127.0.0.1:12379"
)

func New(dir string, listen string, enableTLS bool, diskMode bool, clientSessionCacheSize uint) (*Server, error) {
func New(dir string, listen string, enableTLS bool, diskMode bool, clientSessionCacheSize uint, watchQueryTimeout time.Duration) (*Server, error) {
// Check if we're initializing a new node (i.e. there's an init.yaml).
// dir: the directory where data will be stored as well as where the init.yaml
// and certificates should be found
Expand Down Expand Up @@ -183,6 +183,8 @@ func New(dir string, listen string, enableTLS bool, diskMode bool, clientSession
if v := cfg.DqliteTuning.KinePollInterval; v != nil {
e = fmt.Sprintf("%s&poll-interval=%v", e, *v)
}
// Watch query timeout
e = fmt.Sprintf("%s&watch-query-timeout=%v", e, watchQueryTimeout)

log.Printf("Connecting to kine endpoint: %s", e)

Expand Down
Loading