├── .dockerignore ├── .github ├── config │ └── values.yaml ├── dependabot.yml └── workflows │ ├── e2e-ci.yaml │ └── images-ci.yaml ├── .gitignore ├── CHANGELOG.md ├── CHANGELOG └── README.md ├── CONTRIBUTING.md ├── LICENSE ├── LICENSES └── vendor │ ├── github.com │ ├── aliyun │ │ └── aliyun-oss-go-sdk │ │ │ └── LICENSE │ ├── beorn7 │ │ └── perks │ │ │ └── LICENSE │ ├── davecgh │ │ └── go-spew │ │ │ └── LICENSE │ ├── dghubble │ │ └── trie │ │ │ └── LICENSE │ ├── distribution │ │ └── distribution │ │ │ └── LICENSE │ ├── docker │ │ └── distribution │ │ │ └── LICENSE │ ├── dustin │ │ └── go-humanize │ │ │ └── LICENSE │ ├── evanphx │ │ └── json-patch │ │ │ └── LICENSE │ ├── fsnotify │ │ └── fsnotify │ │ │ └── LICENSE │ ├── go-kit │ │ ├── kit │ │ │ └── LICENSE │ │ └── log │ │ │ └── LICENSE │ ├── go-logfmt │ │ └── logfmt │ │ │ └── LICENSE │ ├── go-logr │ │ ├── logr │ │ │ └── LICENSE │ │ └── zapr │ │ │ └── LICENSE │ ├── go-ole │ │ └── go-ole │ │ │ └── LICENSE │ ├── go-sql-driver │ │ └── mysql │ │ │ └── LICENSE │ ├── gofrs │ │ └── flock │ │ │ └── LICENSE │ ├── gogo │ │ └── protobuf │ │ │ └── LICENSE │ ├── golang │ │ ├── groupcache │ │ │ └── LICENSE │ │ └── protobuf │ │ │ └── LICENSE │ ├── google │ │ ├── go-cmp │ │ │ └── LICENSE │ │ ├── gofuzz │ │ │ └── LICENSE │ │ └── uuid │ │ │ └── LICENSE │ ├── googleapis │ │ └── gnostic │ │ │ └── LICENSE │ ├── hashicorp │ │ └── golang-lru │ │ │ └── LICENSE │ ├── imdario │ │ └── mergo │ │ │ └── LICENSE │ ├── jbenet │ │ └── go-context │ │ │ └── LICENSE │ ├── jlaffaye │ │ └── ftp │ │ │ └── LICENSE │ ├── json-iterator │ │ └── go │ │ │ └── LICENSE │ ├── kballard │ │ └── go-shellquote │ │ │ └── LICENSE │ ├── kr │ │ └── fs │ │ │ └── LICENSE │ ├── lufia │ │ └── plan9stats │ │ │ └── LICENSE │ ├── mattn │ │ └── go-isatty │ │ │ └── LICENSE │ ├── matttproud │ │ └── golang_protobuf_extensions │ │ │ └── LICENSE │ ├── minio │ │ └── minio │ │ │ └── LICENSE │ ├── moby │ │ └── spdystream │ │ │ └── LICENSE │ ├── modern-go │ │ ├── concurrent │ │ │ └── LICENSE │ │ └── reflect2 │ │ │ └── LICENSE │ ├── montanaflynn │ │ └── stats │ │ │ └── LICENSE │ ├── nxadm │ │ └── tail │ │ │ └── LICENSE │ ├── onsi │ │ ├── ginkgo │ │ │ ├── LICENSE │ │ │ └── reporters │ │ │ │ └── stenographer │ │ │ │ └── support │ │ │ │ ├── go-colorable │ │ │ │ └── LICENSE │ │ │ │ └── go-isatty │ │ │ │ └── LICENSE │ │ └── gomega │ │ │ └── LICENSE │ ├── opencontainers │ │ └── go-digest │ │ │ └── LICENSE │ ├── pkg │ │ ├── errors │ │ │ └── LICENSE │ │ └── sftp │ │ │ └── LICENSE │ ├── power-devops │ │ └── perfstat │ │ │ └── LICENSE │ ├── prometheus-operator │ │ └── prometheus-operator │ │ │ └── pkg │ │ │ └── apis │ │ │ └── monitoring │ │ │ └── LICENSE │ ├── prometheus │ │ ├── client_golang │ │ │ └── LICENSE │ │ ├── client_model │ │ │ └── LICENSE │ │ ├── common │ │ │ └── LICENSE │ │ └── procfs │ │ │ └── LICENSE │ ├── remyoudompheng │ │ └── bigfft │ │ │ └── LICENSE │ ├── shirou │ │ └── gopsutil │ │ │ └── v3 │ │ │ └── LICENSE │ ├── spf13 │ │ └── pflag │ │ │ └── LICENSE │ ├── tklauser │ │ ├── go-sysconf │ │ │ └── LICENSE │ │ └── numcpus │ │ │ └── LICENSE │ └── yusufpapurcu │ │ └── wmi │ │ └── LICENSE │ ├── golang.org │ └── x │ │ ├── crypto │ │ └── LICENSE │ │ ├── mod │ │ └── LICENSE │ │ ├── net │ │ └── LICENSE │ │ ├── oauth2 │ │ └── LICENSE │ │ ├── sys │ │ └── LICENSE │ │ ├── term │ │ └── LICENSE │ │ ├── text │ │ └── LICENSE │ │ ├── time │ │ └── LICENSE │ │ ├── tools │ │ └── LICENSE │ │ └── xerrors │ │ └── LICENSE │ ├── gomodules.xyz │ └── jsonpatch │ │ └── v2 │ │ └── LICENSE │ ├── google.golang.org │ ├── appengine │ │ └── LICENSE │ ├── genproto │ │ └── LICENSE │ ├── grpc │ │ └── LICENSE │ └── protobuf │ │ └── LICENSE │ ├── gopkg.in │ ├── inf.v0 │ │ └── LICENSE │ ├── ini.v1 │ │ └── LICENSE │ ├── tomb.v1 │ │ └── LICENSE │ ├── yaml.v2 │ │ └── LICENSE │ └── yaml.v3 │ │ └── LICENSE │ ├── k8s.io │ ├── api │ │ └── LICENSE │ ├── apiextensions-apiserver │ │ └── LICENSE │ ├── apimachinery │ │ └── LICENSE │ ├── client-go │ │ └── LICENSE │ ├── component-base │ │ └── LICENSE │ ├── klog │ │ └── v2 │ │ │ └── LICENSE │ ├── kube-openapi │ │ └── LICENSE │ └── utils │ │ └── LICENSE │ ├── lukechampine.com │ └── uint128 │ │ └── LICENSE │ ├── modernc.org │ ├── cc │ │ └── v3 │ │ │ └── LICENSE │ ├── ccgo │ │ └── v3 │ │ │ └── LICENSE │ ├── libc │ │ ├── LICENSE │ │ └── honnef.co │ │ │ └── go │ │ │ └── netdb │ │ │ └── LICENSE │ ├── mathutil │ │ └── LICENSE │ ├── memory │ │ └── LICENSE │ ├── opt │ │ └── LICENSE │ ├── sqlite │ │ └── LICENSE │ ├── strutil │ │ └── LICENSE │ └── token │ │ └── LICENSE │ └── sigs.k8s.io │ ├── controller-runtime │ └── LICENSE │ ├── structured-merge-diff │ └── v4 │ │ └── LICENSE │ └── yaml │ └── LICENSE ├── Makefile ├── NOTICE.md ├── README.md ├── api └── v1 │ ├── common │ ├── extended_resources.go │ ├── generate.go │ ├── object_meta.go │ ├── value.go │ ├── version.go │ └── zz_generated.deepcopy.go │ ├── groupversion_info.go │ ├── polardbx │ ├── backup.go │ ├── config.go │ ├── file_storage.go │ ├── generate.go │ ├── parameter.go │ ├── privilege.go │ ├── readonly.go │ ├── restore.go │ ├── security.go │ ├── snapshot.go │ ├── status.go │ ├── tde.go │ ├── topology.go │ ├── upgrade_strategy.go │ └── zz_generated.deepcopy.go │ ├── polardbxbackup_types.go │ ├── polardbxbackupbinlog_types.go │ ├── polardbxbackupschedule_types.go │ ├── polardbxcluster_knobs.go │ ├── polardbxcluster_types.go │ ├── polardbxlogcollector_types.go │ ├── polardbxmonitor_types.go │ ├── polardbxparameter_types.go │ ├── polardbxparametertemplate_types.go │ ├── system_task_types.go │ ├── systemtask │ ├── balance_resource.go │ ├── consts.go │ ├── generate.go │ └── zz_generated.deepcopy.go │ ├── xstore │ ├── condition.go │ ├── config.go │ ├── follower.go │ ├── generate.go │ ├── node_role.go │ ├── parameter.go │ ├── phase.go │ ├── port.go │ ├── privilege.go │ ├── topology.go │ ├── upgrade_strategy.go │ ├── volume.go │ └── zz_generated.deepcopy.go │ ├── xstore_follower_types.go │ ├── xstore_types.go │ ├── xstorebackup_types.go │ ├── xstorebackupbinlog_types.go │ └── zz_generated.deepcopy.go ├── build ├── images │ ├── backupset-importer │ │ └── Dockerfile │ ├── polardbx-clinic │ │ ├── Dockerfile │ │ ├── diagnose │ │ ├── diagnose.sh │ │ └── install_tool.sh │ ├── polardbx-exporter │ │ └── Dockerfile │ ├── polardbx-hpfs │ │ └── Dockerfile │ ├── polardbx-init │ │ └── Dockerfile │ ├── polardbx-job │ │ └── Dockerfile │ ├── polardbx-logstash │ │ └── Dockerfile │ ├── polardbx-operator │ │ ├── Dockerfile │ │ └── certs │ │ │ ├── tls.crt │ │ │ └── tls.key │ ├── probe-proxy │ │ └── Dockerfile │ └── xstore-tools │ │ └── Dockerfile └── root │ └── Makefile ├── charts ├── polardbx-logcollector │ ├── Chart.yaml │ ├── LICENSE │ ├── templates │ │ ├── NOTES.txt │ │ ├── configmap │ │ │ ├── filebeat-configmap.yaml │ │ │ ├── logstash-config-configmap.yaml │ │ │ └── logstash-pipeline-configmap.yaml │ │ ├── log-collector-daemonset.yaml │ │ ├── log-collector-serviceaccount.yaml │ │ ├── logstash-deployment.yaml │ │ ├── polardbx-log-collector.yaml │ │ └── secret │ │ │ └── elastic-secret.yaml │ └── values.yaml ├── polardbx-monitor │ ├── Chart.yaml │ ├── config │ │ └── grafana.ini │ ├── crds │ │ ├── prometheus-operator-0alertmanagerConfigCustomResourceDefinition.yaml │ │ ├── prometheus-operator-0alertmanagerCustomResourceDefinition.yaml │ │ ├── prometheus-operator-0podmonitorCustomResourceDefinition.yaml │ │ ├── prometheus-operator-0probeCustomResourceDefinition.yaml │ │ ├── prometheus-operator-0prometheusCustomResourceDefinition.yaml │ │ ├── prometheus-operator-0prometheusruleCustomResourceDefinition.yaml │ │ ├── prometheus-operator-0servicemonitorCustomResourceDefinition.yaml │ │ └── prometheus-operator-0thanosrulerCustomResourceDefinition.yaml │ ├── dashboard │ │ ├── apiserver.json │ │ ├── cluster-total.json │ │ ├── controller-manager.json │ │ ├── k8s-resources-cluster.json │ │ ├── k8s-resources-namespace.json │ │ ├── k8s-resources-node.json │ │ ├── k8s-resources-pod.json │ │ ├── k8s-resources-workload.json │ │ ├── k8s-resources-workloads-namespace.json │ │ ├── kubelet.json │ │ ├── namespace-by-pod.json │ │ ├── namespace-by-workload.json │ │ ├── node-cluster-rsrc-use.json │ │ ├── node-rsrc-use.json │ │ ├── nodes.json │ │ ├── persistentvolumesusage.json │ │ ├── pod-total.json │ │ ├── polardbx-overview.json │ │ ├── prometheus-remote-write.json │ │ ├── prometheus.json │ │ ├── proxy.json │ │ ├── scheduler.json │ │ ├── statefulset.json │ │ ├── workload-total.json │ │ └── xstore-overview.json │ ├── templates │ │ ├── NOTES.txt │ │ ├── alertmanager-alertmanager.yaml │ │ ├── alertmanager-secret.yaml │ │ ├── alertmanager-service.yaml │ │ ├── alertmanager-serviceAccount.yaml │ │ ├── alertmanager-serviceMonitor.yaml │ │ ├── grafana-config.yaml │ │ ├── grafana-dashboard-polardbx-overview-configmap.yaml │ │ ├── grafana-dashboard-xstore-overview-configmap.yaml │ │ ├── grafana-dashboardDatasources.yaml │ │ ├── grafana-dashboardDefinitions.yaml │ │ ├── grafana-dashboardSources.yaml │ │ ├── grafana-deployment.yaml │ │ ├── grafana-service.yaml │ │ ├── grafana-serviceAccount.yaml │ │ ├── grafana-serviceMonitor.yaml │ │ ├── kube-state-metrics-clusterRole.yaml │ │ ├── kube-state-metrics-clusterRoleBinding.yaml │ │ ├── kube-state-metrics-deployment.yaml │ │ ├── kube-state-metrics-service.yaml │ │ ├── kube-state-metrics-serviceAccount.yaml │ │ ├── kube-state-metrics-serviceMonitor.yaml │ │ ├── node-exporter-clusterRole.yaml │ │ ├── node-exporter-clusterRoleBinding.yaml │ │ ├── node-exporter-daemonset.yaml │ │ ├── node-exporter-service.yaml │ │ ├── node-exporter-serviceAccount.yaml │ │ ├── node-exporter-serviceMonitor.yaml │ │ ├── polardbx-alert-rules.yaml │ │ ├── prometheus-adapter-apiService.yaml │ │ ├── prometheus-adapter-clusterRole.yaml │ │ ├── prometheus-adapter-clusterRoleAggregatedMetricsReader.yaml │ │ ├── prometheus-adapter-clusterRoleBinding.yaml │ │ ├── prometheus-adapter-clusterRoleBindingDelegator.yaml │ │ ├── prometheus-adapter-clusterRoleServerResources.yaml │ │ ├── prometheus-adapter-configMap.yaml │ │ ├── prometheus-adapter-deployment.yaml │ │ ├── prometheus-adapter-roleBindingAuthReader.yaml │ │ ├── prometheus-adapter-service.yaml │ │ ├── prometheus-adapter-serviceAccount.yaml │ │ ├── prometheus-adapter-serviceMonitor.yaml │ │ ├── prometheus-clusterRole.yaml │ │ ├── prometheus-clusterRoleBinding.yaml │ │ ├── prometheus-operator-clusterRole.yaml │ │ ├── prometheus-operator-clusterRoleBinding.yaml │ │ ├── prometheus-operator-deployment.yaml │ │ ├── prometheus-operator-service.yaml │ │ ├── prometheus-operator-serviceAccount.yaml │ │ ├── prometheus-operator-serviceMonitor.yaml │ │ ├── prometheus-polardbx-rules.yaml │ │ ├── prometheus-prometheus.yaml │ │ ├── prometheus-roleBindingConfig.yaml │ │ ├── prometheus-roleBindingSpecificNamespaces.yaml │ │ ├── prometheus-roleConfig.yaml │ │ ├── prometheus-roleSpecificNamespaces.yaml │ │ ├── prometheus-service.yaml │ │ ├── prometheus-serviceAccount.yaml │ │ ├── prometheus-serviceMonitor.yaml │ │ ├── prometheus-serviceMonitorApiserver.yaml │ │ ├── prometheus-serviceMonitorCoreDNS.yaml │ │ ├── prometheus-serviceMonitorKubeControllerManager.yaml │ │ ├── prometheus-serviceMonitorKubeScheduler.yaml │ │ └── prometheus-serviceMonitorKubelet.yaml │ └── values.yaml └── polardbx-operator │ ├── Chart.yaml │ ├── LICENSE │ ├── crds │ ├── polardbx.aliyun.com_polardbxbackupbinlogs.yaml │ ├── polardbx.aliyun.com_polardbxbackups.yaml │ ├── polardbx.aliyun.com_polardbxbackupschedules.yaml │ ├── polardbx.aliyun.com_polardbxclusterknobs.yaml │ ├── polardbx.aliyun.com_polardbxclusters.yaml │ ├── polardbx.aliyun.com_polardbxlogcollectors.yaml │ ├── polardbx.aliyun.com_polardbxmonitors.yaml │ ├── polardbx.aliyun.com_polardbxparameters.yaml │ ├── polardbx.aliyun.com_polardbxparametertemplates.yaml │ ├── polardbx.aliyun.com_systemtasks.yaml │ ├── polardbx.aliyun.com_xstorebackupbinlogs.yaml │ ├── polardbx.aliyun.com_xstorebackups.yaml │ ├── polardbx.aliyun.com_xstorefollowers.yaml │ └── polardbx.aliyun.com_xstores.yaml │ ├── templates │ ├── NOTES.txt │ ├── _helpers.tpl │ ├── clinic-deployment.yaml │ ├── controller-config-configmap.yaml │ ├── controller-manager-deployment.yaml │ ├── controller-manager-rbac.yaml │ ├── host-path-file-configmap.yaml │ ├── host-path-file-service-daemonset.yaml │ ├── host-path-file-service-service.yaml │ ├── parameter-template-product-57.yaml │ ├── parameter-template-product-80.yaml │ ├── parameter-template-product-8032.yaml │ ├── tools-updater-daemonset.yaml │ └── webhook │ │ ├── admission-webhook-apiservice.yaml │ │ ├── admission-webhook-configuration.yaml │ │ └── admission-webhook-service.yaml │ └── values.yaml ├── cmd ├── backupset-importer │ └── main.go ├── polardbx-binlog │ └── main.go ├── polardbx-exporter │ └── main.go ├── polardbx-filestream-cli │ └── main.go ├── polardbx-hpfs │ └── main.go ├── polardbx-init │ └── main.go ├── polardbx-job │ └── main.go ├── polardbx-operator │ └── main.go └── probe-proxy │ └── main.go ├── go.mod ├── go.sum ├── hack ├── boilerplates │ ├── boilerplate.go.txt │ ├── boilerplate.py.txt │ └── boilerplate.sh.txt ├── copy_image.sh ├── make-rules │ ├── build-images.py │ ├── build.py │ ├── generate-notice.py │ ├── lib │ │ ├── __init__.py │ │ ├── build_env.py │ │ └── golang.py │ ├── update-vendor-licenses.py │ └── verify-boilerplates.py └── manifest.sh ├── pkg ├── binlogtool │ ├── algo │ │ ├── locate_heartbeat.go │ │ ├── locate_heartbeat_test.go │ │ └── seek_consistent_point.go │ ├── binlog │ │ ├── async.go │ │ ├── cache.go │ │ ├── errs │ │ │ └── error.go │ │ ├── event │ │ │ ├── anonymous_gtid_event.go │ │ │ ├── append_block_event.go │ │ │ ├── begin_load_query_event.go │ │ │ ├── consensus_cluster_info_event.go │ │ │ ├── consensus_empty_event.go │ │ │ ├── consensus_event.go │ │ │ ├── create_file_event.go │ │ │ ├── delete_file_event.go │ │ │ ├── event.go │ │ │ ├── event_test.go │ │ │ ├── exec_load_event.go │ │ │ ├── execute_load_query_event.go │ │ │ ├── format_description_event.go │ │ │ ├── gcn_event.go │ │ │ ├── gtid_event.go │ │ │ ├── header.go │ │ │ ├── heartbeat_event.go │ │ │ ├── heartbeat_event_v2.go │ │ │ ├── incident_event.go │ │ │ ├── intvar_event.go │ │ │ ├── layout_view.go │ │ │ ├── load_event.go │ │ │ ├── new_load_event.go │ │ │ ├── previous_consensus_index_event.go │ │ │ ├── previous_gtids_event.go │ │ │ ├── previous_prepared_xids_event.go │ │ │ ├── query_event.go │ │ │ ├── rand_event.go │ │ │ ├── raw_event.go │ │ │ ├── rotate_event.go │ │ │ ├── rows_event.go │ │ │ ├── rows_query_event.go │ │ │ ├── sequence_event.go │ │ │ ├── slave_event.go │ │ │ ├── start_event.go │ │ │ ├── stop_event.go │ │ │ ├── table_map_event.go │ │ │ ├── transaction_context_event.go │ │ │ ├── transaction_payload_event.go │ │ │ ├── user_var_event.go │ │ │ ├── view_change_event.go │ │ │ ├── xa_prepare_event.go │ │ │ └── xid_event.go │ │ ├── layout │ │ │ ├── field.go │ │ │ ├── field_test.go │ │ │ ├── layout.go │ │ │ └── layout_test.go │ │ ├── meta │ │ │ ├── constraint_test.go │ │ │ ├── constraints.go │ │ │ └── file.go │ │ ├── multi_scan.go │ │ ├── parse.go │ │ ├── rows │ │ │ ├── blob.go │ │ │ ├── column.go │ │ │ ├── decimal.go │ │ │ ├── decimal_test.go │ │ │ ├── number.go │ │ │ ├── rows.go │ │ │ ├── string.go │ │ │ └── time.go │ │ ├── scan.go │ │ ├── scan_test.go │ │ ├── scanutils.go │ │ ├── spec │ │ │ ├── const.go │ │ │ └── extend.go │ │ ├── str │ │ │ ├── blob.go │ │ │ └── str.go │ │ └── write.go │ ├── bitmap │ │ └── bitmap.go │ ├── cmd │ │ ├── cpshow.go │ │ ├── flashback.go │ │ ├── recover.go │ │ ├── root.go │ │ ├── root_test.go │ │ ├── seekcp.go │ │ ├── seekhb.go │ │ ├── show.go │ │ ├── truncate.go │ │ ├── txdump.go │ │ ├── txshow.go │ │ └── version.go │ ├── system │ │ └── system.go │ ├── tx │ │ ├── binary.go │ │ ├── event.go │ │ ├── parser.go │ │ ├── parser_test.go │ │ └── xa.go │ ├── utils │ │ ├── binary.go │ │ ├── binary_big.go │ │ ├── binary_little.go │ │ ├── binary_others.go │ │ ├── binary_test.go │ │ ├── bufio.go │ │ ├── error.go │ │ ├── json.go │ │ ├── map.go │ │ ├── print.go │ │ ├── slice.go │ │ └── timestamp.go │ └── version │ │ └── const.go ├── debug │ └── debug.go ├── exporter │ ├── cdc │ │ ├── adaptor.go │ │ ├── adaptor_test.go │ │ ├── metrics.go │ │ ├── service.go │ │ └── testdata │ │ │ └── sample.txt │ ├── extensions │ │ └── jvm │ │ │ ├── hotspot_jvmstat.go │ │ │ ├── hotspot_jvmstat_exporter.go │ │ │ ├── hotspot_jvmstat_exporter_test.go │ │ │ └── testdata │ │ │ ├── 11 │ │ │ └── 211 │ │ │ └── 181 │ ├── metric │ │ └── metric.go │ ├── polardbx │ │ ├── exporter.go │ │ ├── metrics.go │ │ └── service.go │ └── process │ │ └── java.go ├── featuregate │ ├── featuregates.go │ └── featuregates_test.go ├── hpfs │ ├── backupbinlog │ │ ├── action.go │ │ ├── dao.go │ │ ├── heartbeat.go │ │ ├── meta.go │ │ ├── purge.go │ │ ├── purge_test.go │ │ ├── start.go │ │ ├── watcher.go │ │ └── watcher_test.go │ ├── common │ │ ├── common.go │ │ └── common_test.go │ ├── config │ │ ├── config.go │ │ └── config_test.go │ ├── cpusetbind │ │ ├── convention │ │ │ ├── convention.go │ │ │ └── convention_test.go │ │ ├── cri │ │ │ ├── client.go │ │ │ ├── object.go │ │ │ └── runtime.go │ │ ├── manager.go │ │ ├── pool │ │ │ ├── normal.go │ │ │ ├── normal_test.go │ │ │ ├── numa.go │ │ │ ├── numa_test.go │ │ │ └── service.go │ │ └── system │ │ │ ├── cgoup.go │ │ │ ├── cgroup_test.go │ │ │ ├── cpuinfo.go │ │ │ ├── cpuinfo_test.go │ │ │ ├── io.go │ │ │ ├── numa.go │ │ │ ├── numa_test.go │ │ │ ├── podcheck.go │ │ │ ├── podcheck_test.go │ │ │ ├── proc.go │ │ │ ├── proc_test.go │ │ │ └── testfiles │ │ │ ├── cpu │ │ │ └── cpuinfo │ │ │ ├── node │ │ │ ├── node0 │ │ │ │ └── cpulist │ │ │ ├── node1 │ │ │ │ └── cpulist │ │ │ └── online │ │ │ ├── nodeonline0 │ │ │ ├── nodeonline1 │ │ │ ├── nodeonline2 │ │ │ └── nodeonline3 │ ├── discovery │ │ ├── debug.go │ │ ├── discovery.go │ │ └── k8s.go │ ├── filestream │ │ ├── client.go │ │ ├── common.go │ │ ├── fallocate_darwin.go │ │ ├── fallocate_linux.go │ │ ├── filesercli_test.go │ │ ├── flowcontrol.go │ │ ├── flowcontrol_test.go │ │ ├── local.go │ │ ├── request.go │ │ ├── server.go │ │ ├── xbstream_chunk.go │ │ └── xbstream_chunk_test.go │ ├── generate.go │ ├── hpfs_grpc.go │ ├── hpfs_grpc_test.go │ ├── hpfs_proxy.go │ ├── local │ │ ├── local.go │ │ └── local_test.go │ ├── proto │ │ ├── hpfs.pb.go │ │ └── hpfs.proto │ ├── remote │ │ ├── aliyun_oss.go │ │ ├── aliyun_oss_test.go │ │ ├── ftp.go │ │ ├── hdfs.go │ │ ├── minio.go │ │ ├── remote.go │ │ └── sftp.go │ └── task │ │ ├── engine.go │ │ ├── task.go │ │ └── task_test.go ├── init │ └── init.go ├── k8s │ ├── cache │ │ └── cache.go │ ├── client │ │ └── client.go │ ├── control │ │ ├── branch.go │ │ ├── common.go │ │ ├── context.go │ │ ├── executor.go │ │ ├── flow.go │ │ ├── step.go │ │ └── trace.go │ ├── helper │ │ ├── affinity.go │ │ ├── common.go │ │ ├── common_test.go │ │ ├── configmap.go │ │ ├── const.go │ │ ├── container.go │ │ ├── deployment.go │ │ ├── dnpod.go │ │ ├── env.go │ │ ├── finalizer.go │ │ ├── job.go │ │ ├── name.go │ │ ├── object.go │ │ ├── objectmeta.go │ │ ├── pod.go │ │ ├── pointer.go │ │ ├── remotecommand.go │ │ ├── resource.go │ │ ├── secret.go │ │ ├── selector │ │ │ ├── node.go │ │ │ └── node_test.go │ │ ├── service.go │ │ └── volumes.go │ └── prometheus │ │ └── TBD ├── meta │ └── core │ │ ├── gms │ │ ├── dynamic_configs.go │ │ ├── manager.go │ │ ├── manager_impl.go │ │ └── security │ │ │ ├── encrypt.go │ │ │ ├── encrypt_test.go │ │ │ ├── hash.go │ │ │ ├── hash_test.go │ │ │ └── padding.go │ │ └── group │ │ ├── group_manager.go │ │ ├── plan_generator.go │ │ └── plan_generator_test.go ├── operator │ ├── hint │ │ ├── hint.go │ │ └── pause.go │ └── v1 │ │ ├── config │ │ ├── config.go │ │ ├── interface.go │ │ └── loader.go │ │ ├── operator.go │ │ ├── polardbx │ │ ├── controllers │ │ │ ├── polardbxbackup_controller.go │ │ │ ├── polardbxbackupbinlog_controller.go │ │ │ ├── polardbxbackupschedule_controller.go │ │ │ ├── polardbxcluster_controller.go │ │ │ ├── polardbxclusterknobs_controller.go │ │ │ ├── polardbxlogcollector_controller.go │ │ │ ├── polardbxmonitor_controller.go │ │ │ └── polardbxparameter_controller.go │ │ ├── convention │ │ │ └── convention.go │ │ ├── factory │ │ │ ├── backup.go │ │ │ ├── configmap.go │ │ │ ├── deployment.go │ │ │ ├── deployment_test.go │ │ │ ├── env_factory.go │ │ │ ├── env_factory_test.go │ │ │ ├── object_factory.go │ │ │ ├── ports_factory.go │ │ │ ├── probe_configure.go │ │ │ ├── readonly.go │ │ │ ├── secret.go │ │ │ ├── service.go │ │ │ ├── servicemonitor.go │ │ │ ├── storage.go │ │ │ └── volume_factory.go │ │ ├── guide │ │ │ ├── config.go │ │ │ ├── handler.go │ │ │ ├── topology_mode.go │ │ │ ├── topology_mode_test.go │ │ │ ├── topology_rule.go │ │ │ └── topology_rule_test.go │ │ ├── helper │ │ │ ├── annotation.go │ │ │ ├── controller.go │ │ │ ├── spec.go │ │ │ └── status.go │ │ ├── meta │ │ │ ├── annotation.go │ │ │ ├── finalizer.go │ │ │ └── label.go │ │ ├── reconcile │ │ │ ├── adaptor.go │ │ │ └── context.go │ │ ├── steps │ │ │ ├── backup │ │ │ │ ├── common │ │ │ │ │ ├── cleanup.go │ │ │ │ │ ├── finalizer.go │ │ │ │ │ ├── object.go │ │ │ │ │ ├── seekcp_job.go │ │ │ │ │ └── status.go │ │ │ │ └── schedule │ │ │ │ │ └── schedule.go │ │ │ ├── backupbinlog │ │ │ │ ├── expire_file.go │ │ │ │ ├── finalizer.go │ │ │ │ ├── heartbeat.go │ │ │ │ ├── pxc.go │ │ │ │ ├── status.go │ │ │ │ └── sync_info.go │ │ │ ├── instance │ │ │ │ ├── annotation.go │ │ │ │ ├── check │ │ │ │ │ └── topology.go │ │ │ │ ├── common │ │ │ │ │ ├── object.go │ │ │ │ │ └── status.go │ │ │ │ ├── finalizer │ │ │ │ │ ├── guard.go │ │ │ │ │ └── handler.go │ │ │ │ ├── gms │ │ │ │ │ └── gms.go │ │ │ │ ├── guide │ │ │ │ │ └── handler.go │ │ │ │ ├── object.go │ │ │ │ ├── pitr │ │ │ │ │ ├── job.go │ │ │ │ │ └── pitr.go │ │ │ │ ├── rebalance │ │ │ │ │ └── rebalance.go │ │ │ │ ├── restart │ │ │ │ │ └── restart.go │ │ │ │ └── tde │ │ │ │ │ └── tde.go │ │ │ ├── monitor │ │ │ │ └── monitor.go │ │ │ └── parameter │ │ │ │ └── parameter.go │ │ └── task │ │ │ └── reader.go │ │ ├── systemtask │ │ ├── common │ │ │ ├── adaptor.go │ │ │ ├── base_reconciler.go │ │ │ ├── common.go │ │ │ ├── context.go │ │ │ └── label.go │ │ ├── controllers │ │ │ └── systemtask_controller.go │ │ ├── reconcile │ │ │ └── resource_balance_reconciler.go │ │ └── steps │ │ │ ├── balance_resource.go │ │ │ └── status.go │ │ └── xstore │ │ ├── change │ │ └── driver │ │ │ ├── context │ │ │ └── context.go │ │ │ ├── exec │ │ │ ├── bump_gen_executor.go │ │ │ ├── create_executor.go │ │ │ ├── delete_executor.go │ │ │ ├── executor.go │ │ │ ├── replace_executor.go │ │ │ ├── snapshot_executor.go │ │ │ └── update_executor.go │ │ │ ├── model │ │ │ └── node.go │ │ │ ├── plan │ │ │ ├── check.go │ │ │ └── plan.go │ │ │ ├── planner │ │ │ └── planner.go │ │ │ ├── reconcile │ │ │ └── bind.go │ │ │ └── util │ │ │ └── utils.go │ │ ├── command │ │ ├── commands.go │ │ └── common.go │ │ ├── controllers │ │ ├── xstore_backup_controller.go │ │ ├── xstore_backupbinlog_controller.go │ │ ├── xstore_controller.go │ │ └── xstore_follower_controller.go │ │ ├── convention │ │ └── convention.go │ │ ├── factory │ │ ├── configmap.go │ │ ├── env.go │ │ ├── pod.go │ │ ├── pod_extra.go │ │ ├── secret.go │ │ ├── service.go │ │ └── volumes.go │ │ ├── meta │ │ ├── annotations.go │ │ ├── consensus.go │ │ ├── finalizer.go │ │ ├── job_labels.go │ │ ├── labels.go │ │ └── rebuild_config.go │ │ ├── plugin │ │ ├── adaptor.go │ │ ├── backup_reconciler.go │ │ ├── backupbinlog_reconciler.go │ │ ├── common │ │ │ ├── channel │ │ │ │ └── shared_channel.go │ │ │ ├── factory │ │ │ │ └── configmap.go │ │ │ └── steps │ │ │ │ └── common.go │ │ ├── engines │ │ │ └── plugin.generated.go │ │ ├── galaxy │ │ │ ├── engine.go │ │ │ ├── factory │ │ │ │ ├── configmap.go │ │ │ │ ├── pod.go │ │ │ │ └── service.go │ │ │ ├── galaxy │ │ │ │ └── engine.go │ │ │ ├── reconcilers │ │ │ │ ├── galaxy_backup_reconciler.go │ │ │ │ ├── galaxy_backupbinlog_reconciler.go │ │ │ │ └── galaxy_reconciler.go │ │ │ └── steps │ │ │ │ └── instance │ │ │ │ ├── configmap.go │ │ │ │ ├── consensus.go │ │ │ │ ├── lock.go │ │ │ │ ├── log.go │ │ │ │ ├── pod.go │ │ │ │ ├── service.go │ │ │ │ └── topology.go │ │ ├── generate.go │ │ ├── generate.sh │ │ └── reconcilers.go │ │ ├── reconcile │ │ ├── adaptor.go │ │ ├── backup_context.go │ │ ├── backupbinlog_context.go │ │ ├── context.go │ │ ├── follower_context.go │ │ └── reconciler.go │ │ └── steps │ │ ├── backup │ │ ├── backup_job.go │ │ ├── binlogbackup_job.go │ │ ├── cleanup.go │ │ ├── collect_job.go │ │ ├── finalizer.go │ │ ├── status.go │ │ └── step_binder.go │ │ ├── backupbinlog │ │ ├── status.go │ │ ├── step_binder.go │ │ └── sync_info.go │ │ ├── follower │ │ ├── check.go │ │ ├── error.go │ │ ├── finalizer.go │ │ ├── job.go │ │ ├── meta.go │ │ ├── node.go │ │ ├── pod.go │ │ ├── status.go │ │ ├── step_binder.go │ │ └── storage.go │ │ └── instance │ │ ├── async_task.go │ │ ├── cgroup_blkio.go │ │ ├── change.go │ │ ├── common.go │ │ ├── consensus.go │ │ ├── dynamic_config.go │ │ ├── engine_config.go │ │ ├── lock.go │ │ ├── objects.go │ │ ├── pitr.go │ │ ├── pitrjob.go │ │ ├── privileges.go │ │ ├── rebuild.go │ │ ├── recoverjob.go │ │ ├── recreate.go │ │ ├── restore.go │ │ ├── restorejob.go │ │ ├── status.go │ │ ├── support_legacy.go │ │ ├── tde_config.go │ │ ├── topology.go │ │ └── volumes.go ├── pitr │ ├── context.go │ ├── driver.go │ ├── dto.go │ ├── importbackupset │ │ ├── backupset.go │ │ ├── binlog.go │ │ ├── param.go │ │ ├── upload.go │ │ └── util.go │ ├── prepare_xstore_binlog.go │ ├── restore_binlog.go │ ├── restore_binlog_test.go │ ├── workflow.go │ └── workflow_test.go ├── probe │ ├── print.go │ ├── prober.go │ ├── proxy.go │ └── xstore_ext │ │ ├── plugin │ │ ├── xstore_ext_base.go │ │ └── xstore_galaxy.go │ │ └── xstore_ext.go ├── util │ ├── bool │ │ └── ptr.go │ ├── config │ │ ├── bundle │ │ │ ├── bundle.go │ │ │ ├── file.go │ │ │ ├── k8s.go │ │ │ ├── kv.go │ │ │ └── util.go │ │ ├── driver.go │ │ ├── loader │ │ │ ├── file.go │ │ │ ├── k8s.go │ │ │ └── loader.go │ │ └── store │ │ │ └── store.go │ ├── copy │ │ └── copy.go │ ├── database │ │ ├── ds.go │ │ └── scan.go │ ├── defaults │ │ ├── map.go │ │ └── string.go │ ├── dict │ │ ├── keys.go │ │ └── keys_test.go │ ├── error │ │ ├── error.go │ │ └── exec.go │ ├── formula │ │ └── fomula.go │ ├── gms │ │ └── gmsparamlist.go │ ├── ini │ │ ├── ini.go │ │ └── ini_test.go │ ├── io │ │ ├── copy.go │ │ ├── reader.go │ │ └── writer.go │ ├── json │ │ ├── field.go │ │ └── string.go │ ├── map │ │ ├── map.go │ │ └── map_test.go │ ├── math │ │ └── minmax.go │ ├── name │ │ └── name.go │ ├── network │ │ ├── ip.go │ │ └── tcp.go │ ├── path │ │ └── path.go │ ├── slice │ │ └── slice.go │ ├── ssl │ │ ├── ssl.go │ │ └── ssl_test.go │ ├── tso.go │ └── unit │ │ └── bytes.go └── webhook │ ├── extension │ ├── defaulter.go │ ├── mutator.go │ ├── utils.go │ └── validator.go │ ├── knobs │ ├── sync.go │ ├── validator.go │ └── webhook.go │ ├── parameter │ ├── utils.go │ ├── validator.go │ ├── validator_test.go │ └── webhook.go │ ├── polardbxbackup │ ├── binlog │ │ └── webhook.go │ ├── validator.go │ └── webhook.go │ ├── polardbxcluster │ ├── configs.go │ ├── defaulter.go │ ├── validator.go │ ├── validator_test.go │ └── webhook.go │ └── webhooks.go ├── test ├── e2e │ ├── e2e_test.go │ ├── polardbxcluster │ │ ├── configuration │ │ │ ├── cn_dynamic.go │ │ │ ├── cn_static.go │ │ │ └── dn_mycnf.go │ │ ├── ha │ │ │ ├── drift.go │ │ │ ├── host.go │ │ │ └── process.go │ │ ├── imports.go │ │ ├── lifecycle │ │ │ ├── common.go │ │ │ ├── creation.go │ │ │ ├── deletion.go │ │ │ ├── maintain.go │ │ │ └── upgrade.go │ │ ├── rebalance │ │ │ ├── scale_in.go │ │ │ └── scale_out.go │ │ └── sql │ │ │ ├── basic │ │ │ ├── crud.go │ │ │ └── ddl.go │ │ │ ├── functionality │ │ │ └── select_version.go │ │ │ ├── performance │ │ │ ├── sysbench.go │ │ │ └── tpcc.go │ │ │ └── transaction │ │ │ └── transfer.go │ ├── polardbxmonitor │ │ ├── imports.go │ │ └── lifecycle │ │ │ ├── common.go │ │ │ ├── creation.go │ │ │ ├── deletion.go │ │ │ └── updation.go │ ├── polardbxparameter │ │ ├── common.go │ │ └── modify.go │ └── xstore │ │ ├── ha │ │ ├── host.go │ │ ├── process.go │ │ └── storage.go │ │ ├── imports.go │ │ └── lifecycle │ │ ├── creation.go │ │ ├── deletion.go │ │ └── maintain.go └── framework │ ├── common │ ├── expect.go │ ├── kubectl.go │ ├── list.go │ ├── wait.go │ └── wait_test.go │ ├── context.go │ ├── expect.go │ ├── fail.go │ ├── framework.go │ ├── local │ └── port.go │ ├── log.go │ ├── log │ └── log.go │ ├── object │ ├── expect.go │ └── wait.go │ ├── polardbxcluster │ ├── expect.go │ ├── factory.go │ ├── owned.go │ ├── rule.go │ └── wait.go │ ├── polardbxmonitor │ ├── factory.go │ └── wait.go │ ├── polardbxparameter │ ├── factory.go │ └── wait.go │ └── xstore │ └── wait.go ├── third-party └── hsperfdata │ ├── LICENSE │ ├── ORIGIN │ ├── README.md │ ├── cmd │ └── cli.go │ ├── hsperfdata.go │ ├── hsperfdata_test.go │ └── test-data │ ├── 2036 │ ├── 2956 │ ├── 13223 │ ├── 13984 │ ├── 15192 │ └── 21916 └── tools ├── __init__.py ├── logstash-filter-polardbx ├── .gitignore ├── Gemfile ├── LICENSE ├── NOTICE.TXT ├── README.md ├── Rakefile ├── logstash-filter-polardbx.gemspec └── spec │ ├── filters │ └── polardbx_spec.rb │ └── spec_helper.rb └── xstore ├── .dockerignore ├── audit_controller.py ├── cli.py ├── cli ├── __init__.py ├── account.py ├── backup.py ├── binlogbackup.py ├── collect.py ├── common.py ├── consensus.py ├── engine.py ├── log.py ├── myconfig.py ├── process.py ├── recover.py ├── restore.py ├── root.py ├── seekcp.py ├── utils │ ├── __init__.py │ └── timer.py └── variables.py ├── core ├── __init__.py ├── backup_restore │ ├── __init__.py │ ├── storage │ │ ├── __init__.py │ │ └── filestream_client.py │ ├── utils.py │ └── xstore_binlog.py ├── channel │ ├── __init__.py │ └── channel.py ├── config │ ├── __init__.py │ └── mysql.py ├── consensus │ ├── __init__.py │ ├── manager.py │ └── manager_impl.py ├── context │ ├── __init__.py │ ├── context.py │ ├── k8s.py │ └── mycnf_renderer.py ├── convention.py ├── engine │ ├── __init__.py │ ├── dynamic.py │ ├── engine.py │ ├── galaxy │ │ ├── __init__.py │ │ ├── engine.py │ │ └── templates │ │ │ └── my.cnf │ ├── store.py │ └── util │ │ ├── __init__.py │ │ └── config_util.py ├── log │ ├── __init__.py │ └── logger.py └── manager.py ├── entrypoint.py ├── hack └── update.sh ├── healthy.py └── requirements.txt /.dockerignore: -------------------------------------------------------------------------------- 1 | vendor 2 | target 3 | tools/xstore/venv 4 | hack 5 | helm 6 | CHANGELOG 7 | *.md 8 | Makefile 9 | config 10 | LICENSES 11 | test 12 | .exportignore 13 | .gitignore 14 | LICENSE 15 | .git 16 | docs -------------------------------------------------------------------------------- /.github/config/values.yaml: -------------------------------------------------------------------------------- 1 | clusterDefaults: 2 | version: latest 3 | images: 4 | galaxysql: pxc-registry.cn-shanghai.cr.aliyuncs.com/polardbx/polardbx-sql 5 | galaxyengine: pxc-registry.cn-shanghai.cr.aliyuncs.com/polardbx/polardbx-engine-2.0 6 | galaxycdc: pxc-registry.cn-shanghai.cr.aliyuncs.com/polardbx/polardbx-cdc 7 | 8 | imagePullSecrets: 9 | - name: github-ci -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: github-actions 9 | directory: / 10 | schedule: 11 | interval: weekly 12 | - package-ecosystem: gomod 13 | directory: / 14 | schedule: 15 | interval: daily 16 | -------------------------------------------------------------------------------- /.github/workflows/images-ci.yaml: -------------------------------------------------------------------------------- 1 | name: CI for build images 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - main 7 | 8 | # Environment variables available to all jobs and steps in this workflow. 9 | env: 10 | REGISTRY: registry.cn-zhangjiakou.aliyuncs.com 11 | NAMESPACE: polardbx-ci 12 | TAG: ${{ github.sha }} 13 | 14 | jobs: 15 | build: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - name: Checkout 19 | uses: actions/checkout@v3 20 | 21 | # 1 Setup go environment 22 | - name: Setup go environment 23 | uses: actions/setup-go@v3 24 | with: 25 | go-version: '1.21' 26 | 27 | # 2 Build images 28 | - name: Build images 29 | run: |- 30 | make build REPO=$REGISTRY/$NAMESPACE TAG=$TAG 31 | 32 | # 3 Generate helm chart 33 | - name: Generate helm chart 34 | run: |- 35 | make helm-package 36 | 37 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | CHANGELOG/README.md -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polardb/polardbx-operator/ae33ef90e8c5a36c0c749dc5e492fd6ac23d3ef3/CONTRIBUTING.md -------------------------------------------------------------------------------- /LICENSES/vendor/github.com/aliyun/aliyun-oss-go-sdk/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 aliyun.com 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 4 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 5 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 6 | permit persons to whom the Software is furnished to do so, subject to the following conditions: 7 | 8 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 9 | Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 12 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 13 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 14 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /LICENSES/vendor/github.com/beorn7/perks/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2013 Blake Mizerany 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /LICENSES/vendor/github.com/davecgh/go-spew/LICENSE: -------------------------------------------------------------------------------- 1 | ISC License 2 | 3 | Copyright (c) 2012-2016 Dave Collins 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | -------------------------------------------------------------------------------- /LICENSES/vendor/github.com/dghubble/trie/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Dalton Hubble 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /LICENSES/vendor/github.com/go-kit/kit/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Peter Bourgon 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /LICENSES/vendor/github.com/go-kit/log/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Go kit 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LICENSES/vendor/github.com/jlaffaye/ftp/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2013, Julien Laffaye 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | -------------------------------------------------------------------------------- /LICENSES/vendor/github.com/json-iterator/go/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 json-iterator 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LICENSES/vendor/github.com/kballard/go-shellquote/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2014 Kevin Ballard 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the "Software"), 5 | to deal in the Software without restriction, including without limitation 6 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | and/or sell copies of the Software, and to permit persons to whom the 8 | Software is furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included 11 | in all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 14 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 15 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 18 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 19 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /LICENSES/vendor/github.com/mattn/go-isatty/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) Yasuhiro MATSUMOTO 2 | 3 | MIT License (Expat) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /LICENSES/vendor/github.com/onsi/ginkgo/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-2014 Onsi Fakhouri 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /LICENSES/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) Yasuhiro MATSUMOTO 2 | 3 | MIT License (Expat) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /LICENSES/vendor/github.com/onsi/gomega/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-2014 Onsi Fakhouri 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /LICENSES/vendor/github.com/yusufpapurcu/wmi/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Stack Exchange 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /LICENSES/vendor/lukechampine.com/uint128/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2019 Luke Champine 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /LICENSES/vendor/modernc.org/libc/honnef.co/go/netdb/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Dominik Honnef 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | build/root/Makefile -------------------------------------------------------------------------------- /api/v1/common/generate.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +kubebuilder:object:generate=true 18 | 19 | package common 20 | -------------------------------------------------------------------------------- /api/v1/common/version.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | const ( 4 | AnnotationOperatorCreateVersion = "polardbx-operator/create-version" 5 | ) 6 | 7 | func NeedCheckPodClusterIp(version string) bool { 8 | return version == "" 9 | } 10 | -------------------------------------------------------------------------------- /api/v1/polardbx/generate.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +kubebuilder:object:generate=true 18 | 19 | package polardbx 20 | -------------------------------------------------------------------------------- /api/v1/polardbx/parameter.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package polardbx 18 | 19 | const ( 20 | RolingRestart = "rollingRestart" 21 | Restart = "restart" 22 | ) 23 | 24 | type ParameterTemplate struct { 25 | // parameter template 26 | // +optional 27 | Namespace string `json:"namespace,omitempty"` 28 | // +optional 29 | Name string `json:"name,omitempty"` 30 | } 31 | 32 | type RestartingPods struct { 33 | LastDeletedPod string `json:"lastDeletedPod,omitempty"` 34 | ToDeletePod []string `json:"toDeletePod,omitempty"` 35 | } 36 | -------------------------------------------------------------------------------- /api/v1/polardbx/readonly.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package polardbx 18 | 19 | import "k8s.io/apimachinery/pkg/util/intstr" 20 | 21 | type ReadonlyParam struct { 22 | CnReplicas int `json:"cnReplicas,omitempty"` 23 | Name string `json:"name,omitempty"` 24 | ExtraParams map[string]intstr.IntOrString `json:"extraParams,omitempty"` 25 | } 26 | -------------------------------------------------------------------------------- /api/v1/polardbx/snapshot.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package polardbx 18 | 19 | // SpecSnapshot represents a snapshot of aspects of the spec. 20 | type SpecSnapshot struct { 21 | Topology Topology `json:"topology,omitempty"` 22 | Config Config `json:"config,omitempty"` 23 | } 24 | -------------------------------------------------------------------------------- /api/v1/polardbx/tde.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package polardbx 18 | 19 | type TDE struct { 20 | // Enable represents whether tde is enabled 21 | // +kubebuilder:default=false 22 | // +optional 23 | Enable bool `json:"enable,omitempty"` 24 | 25 | // KeyringPath represents the keyring path 26 | // +kubebuilder:default=/data/mysql/mysql-keyring/keyring 27 | // +optional 28 | KeyringPath string `json:"keyringPath,omitempty"` 29 | } 30 | -------------------------------------------------------------------------------- /api/v1/polardbx/upgrade_strategy.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package polardbx 18 | 19 | type UpgradeStrategyType string 20 | 21 | // Valid upgrade strategies. 22 | const ( 23 | RecreateUpgradeStrategy UpgradeStrategyType = "Recreate" 24 | RollingUpgradeStrategy UpgradeStrategyType = "RollingUpgrade" 25 | ) 26 | -------------------------------------------------------------------------------- /api/v1/systemtask/balance_resource.go: -------------------------------------------------------------------------------- 1 | package systemtask 2 | 3 | type StBalanceResourceStatus struct { 4 | RebuildTaskName string `json:"rebuildTaskName,omitempty"` 5 | RebuildFinish bool `json:"rebuildFinish,omitempty"` 6 | BalanceLeaderFinish bool `json:"balanceLeaderFinish,omitempty"` 7 | } 8 | -------------------------------------------------------------------------------- /api/v1/systemtask/consts.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package systemtask 18 | 19 | type Type string 20 | 21 | const ( 22 | BalanceResource Type = "BalanceResource" 23 | ) 24 | 25 | type Phase string 26 | 27 | // balance 28 | const ( 29 | InitPhase Phase = "" 30 | RebuildTaskPhase Phase = "RebuildTaskPhase" 31 | BalanceRolePhase Phase = "BalanceRolePhase" 32 | SuccessPhase Phase = "Success" 33 | ) 34 | -------------------------------------------------------------------------------- /api/v1/systemtask/generate.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +kubebuilder:object:generate=true 18 | 19 | package systemtask 20 | -------------------------------------------------------------------------------- /api/v1/xstore/generate.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +kubebuilder:object:generate=true 18 | 19 | package xstore 20 | -------------------------------------------------------------------------------- /api/v1/xstore/parameter.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package xstore 18 | 19 | type ParameterTemplate struct { 20 | // Parameter template 21 | // +optional 22 | Namespace string `json:"namespace,omitempty"` 23 | // +optional 24 | Name string `json:"name,omitempty"` 25 | } 26 | 27 | type RestartingPods struct { 28 | LastDeletedPod string `json:"lastDeletedPod,omitempty"` 29 | ToDeletePod []string `json:"toDeletePod,omitempty"` 30 | } 31 | -------------------------------------------------------------------------------- /api/v1/xstore/port.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package xstore 18 | 19 | type PodPorts map[string]int32 20 | 21 | func (ports PodPorts) ToMap() map[string]int { 22 | if ports == nil { 23 | return nil 24 | } 25 | r := make(map[string]int) 26 | for k, v := range ports { 27 | r[k] = int(v) 28 | } 29 | return r 30 | } 31 | -------------------------------------------------------------------------------- /api/v1/xstore/privilege.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package xstore 18 | 19 | type Privilege struct { 20 | // Username is the username of account. 21 | Username string `json:"username,omitempty"` 22 | 23 | // Password is the password of account. If empty, the controller should 24 | // generate a random password. 25 | // +optional 26 | Password string `json:"password,omitempty"` 27 | 28 | // +kubebuilder:default="%" 29 | 30 | // Host is the host of account. Default is '%' which represents any host. 31 | // +optional 32 | Host string `json:"host,omitempty"` 33 | } 34 | -------------------------------------------------------------------------------- /api/v1/xstore/upgrade_strategy.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package xstore 18 | 19 | type UpgradeStrategy string 20 | 21 | // Valid upgrade strategies. 22 | const ( 23 | UpgradeStrategyForce UpgradeStrategy = "Force" 24 | UpgradeStrategyBestEffort UpgradeStrategy = "BestEffort" 25 | ) 26 | -------------------------------------------------------------------------------- /build/images/polardbx-clinic/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Alibaba Group Holding Limited. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | 14 | # Build the manager binary 15 | ARG IMAGE_SOURCE 16 | FROM ${IMAGE_SOURCE}${IMAGE_SOURCE:+"/"}centos:7 17 | 18 | WORKDIR /root 19 | USER root 20 | COPY build/images/polardbx-clinic/diagnose.sh /root/diagnose.sh 21 | COPY build/images/polardbx-clinic/install_tool.sh /root/install_tool.sh 22 | COPY build/images/polardbx-clinic/diagnose /usr/bin/diagnose 23 | RUN sh install_tool.sh 24 | RUN chmod +x /usr/bin/diagnose 25 | 26 | -------------------------------------------------------------------------------- /build/images/polardbx-clinic/diagnose: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | namespace=default 5 | if [ -n "$1" ];then 6 | namespace=$1 7 | fi 8 | 9 | echo "namespace:$namespace" 10 | 11 | rm -fR /root/workspace/* 12 | 13 | sh /root/diagnose.sh -w workspace -n "$namespace" >/root/workspace/diagnose.log 2>&1 & 14 | 15 | echo "Begin to diagnose." 16 | echo "You can exit this terminal, and wait the pod to be ready." 17 | echo "Then run the following command to download the diagnose files." 18 | echo "kubectl -n polardbx-operator-system cp /root/workspace/polardbx-diagnose.tar.gz polardbx-diagnose.tar.gz" 19 | -------------------------------------------------------------------------------- /build/images/polardbx-logstash/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE_SOURCE 2 | FROM ${IMAGE_SOURCE}${IMAGE_SOURCE:+"/"}jruby:9.3.8.0-jdk8 as builder 3 | 4 | WORKDIR /workspace 5 | ADD tools/logstash-filter-polardbx . 6 | RUN gem install bundler:2.3.10 7 | RUN bundle update 8 | RUN bundle install 9 | RUN gem build logstash-filter-polardbx.gemspec 10 | 11 | FROM ${IMAGE_SOURCE}${IMAGE_SOURCE:+"/"}logstash:8.1.2 12 | WORKDIR /usr/share/logstash/ 13 | USER root 14 | COPY --from=builder /workspace/logstash-filter-polardbx-1.0.0.gem /usr/share/logstash/ 15 | RUN /usr/share/logstash/bin/logstash-plugin install /usr/share/logstash/logstash-filter-polardbx-1.0.0.gem 16 | RUN echo "Asia/Shanghai" > /etc/timezone 17 | 18 | LABEL POLARX_BUSINESS=loghub -------------------------------------------------------------------------------- /charts/polardbx-logcollector/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | name: polardbx-logcollector 3 | description: Helm chart of polardbx-operator logcollector plugin 4 | type: application 5 | version: 1.7.0 6 | appVersion: v1.7.0 7 | keywords: 8 | - polardb-x 9 | - operator 10 | - logcollector 11 | home: https://www.aliyun.com/product/drds 12 | sources: 13 | - https://github.com/ApsaraDB/galaxykube -------------------------------------------------------------------------------- /charts/polardbx-logcollector/templates/NOTES.txt: -------------------------------------------------------------------------------- 1 | polardbx-operator logcollector plugin is installed. Please check the status of components: 2 | 3 | kubectl get pods --namespace {{ .Release.Namespace }} 4 | 5 | Now start to collect logs of your polardbx cluster. 6 | -------------------------------------------------------------------------------- /charts/polardbx-logcollector/templates/log-collector-serviceaccount.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | name: {{ .Values.filebeat.serviceAccount.name }} 5 | namespace: {{ .Release.Namespace }} 6 | 7 | --- 8 | 9 | apiVersion: rbac.authorization.k8s.io/v1 10 | kind: ClusterRole 11 | metadata: 12 | name: nodes-pods-clusterrole 13 | rules: 14 | - apiGroups: [""] 15 | resources: ["nodes","pods","namespaces"] 16 | verbs: ["get", "watch", "list"] 17 | - apiGroups: ["apps"] 18 | resources: ["replicasets", "daemonsets"] 19 | verbs: ["get", "watch", "list"] 20 | - apiGroups: ["batch"] 21 | resources: ["jobs"] 22 | verbs: ["get", "watch", "list"] 23 | --- 24 | 25 | apiVersion: rbac.authorization.k8s.io/v1 26 | kind: ClusterRoleBinding 27 | metadata: 28 | name: read-nodes-pods-global 29 | subjects: 30 | - kind: ServiceAccount 31 | name: {{ .Values.filebeat.name }} 32 | namespace: {{ .Release.Namespace }} 33 | roleRef: 34 | kind: ClusterRole 35 | name: nodes-pods-clusterrole 36 | apiGroup: rbac.authorization.k8s.io -------------------------------------------------------------------------------- /charts/polardbx-logcollector/templates/polardbx-log-collector.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: polardbx.aliyun.com/v1 2 | kind: PolarDBXLogCollector 3 | metadata: 4 | name: {{ .Values.logCollector.name }} 5 | namespace: {{ .Release.Namespace }} 6 | labels: 7 | app: {{ .Values.logCollector.name }} 8 | spec: 9 | fileBeatName: {{ .Values.filebeat.name }} 10 | logStashName: {{ .Values.logstash.name }} 11 | -------------------------------------------------------------------------------- /charts/polardbx-logcollector/templates/secret/elastic-secret.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Secret 3 | metadata: 4 | name: {{ .Values.logstash.elastic.certsSecretName }} 5 | namespace: {{ .Release.Namespace }} 6 | data: 7 | ca.crt: {{ b64enc "testval" }} 8 | type: Opaque 9 | 10 | -------------------------------------------------------------------------------- /charts/polardbx-monitor/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | name: polardbx-monitor 3 | description: Helm chart of polardbx-operator monitor plugin 4 | type: application 5 | version: 1.7.0 6 | appVersion: v1.7.0 7 | keywords: 8 | - polardb-x 9 | - operator 10 | - monitor 11 | home: https://www.aliyun.com/product/drds 12 | sources: 13 | - https://github.com/ApsaraDB/galaxykube -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/NOTES.txt: -------------------------------------------------------------------------------- 1 | polardbx-operator monitor plugin is installed. Please check the status of components: 2 | 3 | kubectl get pods --namespace {{ .Release.Namespace }} 4 | 5 | Now start to monitor your polardbx cluster. 6 | 7 | Here's the manifest for quick start: 8 | 9 | ```yaml 10 | apiVersion: polardbx.aliyun.com/v1 11 | kind: PolarDBXMonitor 12 | metadata: 13 | name: quick-start-monitor 14 | spec: 15 | clusterName: quick-start 16 | monitorInterval: 30s 17 | scrapeTimeout: 10s 18 | ``` 19 | 20 | * spec.clusterName: The PolarDB-X cluster name you want to monitor 21 | * spec.monitorInterval: monitor interval, default 30s 22 | * spec.scrapeTimeout: monitor data scrabe timeout, default 10s 23 | -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/alertmanager-alertmanager.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: monitoring.coreos.com/v1 2 | kind: Alertmanager 3 | metadata: 4 | labels: 5 | alertmanager: main 6 | app.kubernetes.io/instance: {{ .Release.Name }} 7 | app.kubernetes.io/managed-by: {{ .Release.Service }} 8 | name: main 9 | namespace: {{ .Release.Namespace }} 10 | spec: 11 | image: {{ .Values.monitors.alertManager.repo }}{{ "/" }}{{ .Values.monitors.alertManager.image }}:{{ .Values.monitors.alertManager.version }} 12 | {{- with .Values.monitors.alertManager.nodeSelector }} 13 | nodeSelector: 14 | {{ toYaml . | nindent 4 }} 15 | {{- end }} 16 | replicas: {{ .Values.monitors.alertManager.replicas }} 17 | securityContext: 18 | fsGroup: 2000 19 | runAsNonRoot: true 20 | runAsUser: 1000 21 | serviceAccountName: alertmanager-main 22 | version: {{ .Values.monitors.alertManager.version }} 23 | resources: 24 | {{ toYaml .Values.monitors.alertManager.resources | indent 4 }} 25 | 26 | -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/alertmanager-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | alertmanager: main 6 | app.kubernetes.io/instance: {{ .Release.Name }} 7 | app.kubernetes.io/managed-by: {{ .Release.Service }} 8 | name: alertmanager-main 9 | namespace: {{ .Release.Namespace }} 10 | spec: 11 | ports: 12 | - name: web 13 | port: {{ .Values.monitors.alertManager.port }} 14 | targetPort: web 15 | selector: 16 | alertmanager: main 17 | app: alertmanager 18 | sessionAffinity: ClientIP 19 | type: {{ .Values.monitors.alertManager.serviceType }} 20 | 21 | -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/alertmanager-serviceAccount.yaml: -------------------------------------------------------------------------------- 1 | {{/* 2 | Create the service account of alert manager to use 3 | */}} 4 | {{- if .Values.monitors.alertManager.serviceAccount.create -}} 5 | apiVersion: v1 6 | kind: ServiceAccount 7 | metadata: 8 | name: alertmanager-main 9 | namespace: {{ .Release.Namespace }} 10 | labels: 11 | app.kubernetes.io/instance: {{ .Release.Name }} 12 | app.kubernetes.io/managed-by: {{ .Release.Service }} 13 | {{- end -}} 14 | 15 | -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/alertmanager-serviceMonitor.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: monitoring.coreos.com/v1 2 | kind: ServiceMonitor 3 | metadata: 4 | labels: 5 | k8s-app: alertmanager 6 | app.kubernetes.io/instance: {{ .Release.Name }} 7 | app.kubernetes.io/managed-by: {{ .Release.Service }} 8 | name: alertmanager 9 | namespace: {{ .Release.Namespace }} 10 | spec: 11 | endpoints: 12 | - interval: 30s 13 | port: web 14 | selector: 15 | matchLabels: 16 | alertmanager: main 17 | 18 | -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/grafana-config.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: grafana-ini 5 | namespace: {{ .Release.Namespace }} 6 | labels: 7 | app.kubernetes.io/instance: {{ .Release.Name }} 8 | app.kubernetes.io/managed-by: {{ .Release.Service }} 9 | data: 10 | {{ (.Files.Glob "config/grafana.ini").AsConfig | indent 2 }} -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/grafana-dashboard-polardbx-overview-configmap.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: grafana-dashboard-polardbx-overview 5 | namespace: {{ .Release.Namespace }} 6 | labels: 7 | app.kubernetes.io/instance: {{ .Release.Name }} 8 | app.kubernetes.io/managed-by: {{ .Release.Service }} 9 | data: 10 | {{ (.Files.Glob "dashboard/polardbx-overview.json").AsConfig | indent 2 }} 11 | -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/grafana-dashboard-xstore-overview-configmap.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: grafana-dashboard-xstore-overview 5 | namespace: {{ .Release.Namespace }} 6 | labels: 7 | app.kubernetes.io/instance: {{ .Release.Name }} 8 | app.kubernetes.io/managed-by: {{ .Release.Service }} 9 | data: 10 | {{ (.Files.Glob "dashboard/xstore-overview.json").AsConfig | indent 2 }} 11 | -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/grafana-dashboardSources.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | data: 3 | dashboards.yaml: |- 4 | { 5 | "apiVersion": 1, 6 | "providers": [ 7 | { 8 | "folder": "Default", 9 | "name": "0", 10 | "options": { 11 | "path": "/grafana-dashboard-definitions/0" 12 | }, 13 | "orgId": 1, 14 | "type": "file" 15 | }, 16 | { 17 | "folder": "PolarDB-X", 18 | "name": "1", 19 | "options": { 20 | "path": "/grafana-dashboard-definitions/1" 21 | }, 22 | "orgId": 1, 23 | "type": "file" 24 | } 25 | ] 26 | } 27 | kind: ConfigMap 28 | metadata: 29 | name: grafana-dashboards 30 | namespace: {{ .Release.Namespace }} 31 | labels: 32 | app.kubernetes.io/instance: {{ .Release.Name }} 33 | app.kubernetes.io/managed-by: {{ .Release.Service }} 34 | 35 | -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/grafana-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | app: grafana 6 | app.kubernetes.io/instance: {{ .Release.Name }} 7 | app.kubernetes.io/managed-by: {{ .Release.Service }} 8 | name: grafana 9 | namespace: {{ .Release.Namespace }} 10 | spec: 11 | ports: 12 | - name: http 13 | port: {{ .Values.monitors.grafana.port }} 14 | targetPort: http 15 | selector: 16 | app: grafana 17 | type: {{ .Values.monitors.grafana.serviceType }} 18 | 19 | -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/grafana-serviceAccount.yaml: -------------------------------------------------------------------------------- 1 | {{/* 2 | Create the service account of alert manager to use 3 | */}} 4 | {{- if .Values.monitors.grafana.serviceAccount.create -}} 5 | apiVersion: v1 6 | kind: ServiceAccount 7 | metadata: 8 | name: grafana 9 | namespace: {{ .Release.Namespace }} 10 | labels: 11 | app.kubernetes.io/instance: {{ .Release.Name }} 12 | app.kubernetes.io/managed-by: {{ .Release.Service }} 13 | {{- end -}} -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/grafana-serviceMonitor.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: monitoring.coreos.com/v1 2 | kind: ServiceMonitor 3 | metadata: 4 | name: grafana 5 | namespace: {{ .Release.Namespace }} 6 | labels: 7 | app.kubernetes.io/instance: {{ .Release.Name }} 8 | app.kubernetes.io/managed-by: {{ .Release.Service }} 9 | spec: 10 | endpoints: 11 | - interval: 15s 12 | port: http 13 | selector: 14 | matchLabels: 15 | app: grafana 16 | 17 | -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/kube-state-metrics-clusterRoleBinding.yaml: -------------------------------------------------------------------------------- 1 | {{/* 2 | Create the service account of alert manager to use 3 | */}} 4 | {{- if .Values.monitors.kubeStateMetrics.rbac.create -}} 5 | apiVersion: rbac.authorization.k8s.io/v1 6 | kind: ClusterRoleBinding 7 | metadata: 8 | labels: 9 | app.kubernetes.io/name: polardbx-kube-state-metrics 10 | app.kubernetes.io/version: v1.9.7 11 | app.kubernetes.io/instance: {{ .Release.Name }} 12 | app.kubernetes.io/managed-by: {{ .Release.Service }} 13 | name: polardbx-kube-state-metrics 14 | roleRef: 15 | apiGroup: rbac.authorization.k8s.io 16 | kind: ClusterRole 17 | name: polardbx-kube-state-metrics 18 | subjects: 19 | - kind: ServiceAccount 20 | name: kube-state-metrics 21 | namespace: {{ .Release.Namespace }} 22 | {{- end -}} -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/kube-state-metrics-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | app.kubernetes.io/name: kube-state-metrics 6 | app.kubernetes.io/version: v1.9.7 7 | app.kubernetes.io/instance: {{ .Release.Name }} 8 | app.kubernetes.io/managed-by: {{ .Release.Service }} 9 | name: kube-state-metrics 10 | namespace: {{ .Release.Namespace }} 11 | spec: 12 | clusterIP: None 13 | ports: 14 | - name: https-main 15 | port: 8443 16 | targetPort: https-main 17 | - name: https-self 18 | port: 9443 19 | targetPort: https-self 20 | selector: 21 | app.kubernetes.io/name: kube-state-metrics 22 | 23 | -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/kube-state-metrics-serviceAccount.yaml: -------------------------------------------------------------------------------- 1 | {{/* 2 | Create the service account of kubestatemetrics to use 3 | */}} 4 | {{- if .Values.monitors.kubeStateMetrics.serviceAccount.create -}} 5 | apiVersion: v1 6 | kind: ServiceAccount 7 | metadata: 8 | labels: 9 | app.kubernetes.io/name: kube-state-metrics 10 | app.kubernetes.io/version: {{ .Values.monitors.kubeStateMetrics.version }} 11 | app.kubernetes.io/instance: {{ .Release.Name }} 12 | app.kubernetes.io/managed-by: {{ .Release.Service }} 13 | name: kube-state-metrics 14 | namespace: {{ .Release.Namespace }} 15 | {{- end -}} 16 | 17 | 18 | -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/kube-state-metrics-serviceMonitor.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: monitoring.coreos.com/v1 2 | kind: ServiceMonitor 3 | metadata: 4 | labels: 5 | app.kubernetes.io/name: kube-state-metrics 6 | app.kubernetes.io/version: {{ .Values.monitors.kubeStateMetrics.version }} 7 | app.kubernetes.io/instance: {{ .Release.Name }} 8 | app.kubernetes.io/managed-by: {{ .Release.Service }} 9 | name: kube-state-metrics 10 | namespace: {{ .Release.Namespace }} 11 | spec: 12 | endpoints: 13 | - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token 14 | honorLabels: true 15 | interval: 30s 16 | port: https-main 17 | relabelings: 18 | - action: labeldrop 19 | regex: (pod|service|endpoint|namespace) 20 | scheme: https 21 | scrapeTimeout: 30s 22 | tlsConfig: 23 | insecureSkipVerify: true 24 | - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token 25 | interval: 30s 26 | port: https-self 27 | scheme: https 28 | tlsConfig: 29 | insecureSkipVerify: true 30 | jobLabel: app.kubernetes.io/name 31 | selector: 32 | matchLabels: 33 | app.kubernetes.io/name: kube-state-metrics 34 | 35 | -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/node-exporter-clusterRole.yaml: -------------------------------------------------------------------------------- 1 | {{/* 2 | Create the cluster role of node exporter to use 3 | */}} 4 | {{- if .Values.monitors.nodeExporter.rbac.create -}} 5 | apiVersion: rbac.authorization.k8s.io/v1 6 | kind: ClusterRole 7 | metadata: 8 | name: polardbx-node-exporter 9 | labels: 10 | app.kubernetes.io/instance: {{ .Release.Name }} 11 | app.kubernetes.io/managed-by: {{ .Release.Service }} 12 | rules: 13 | - apiGroups: 14 | - authentication.k8s.io 15 | resources: 16 | - tokenreviews 17 | verbs: 18 | - create 19 | - apiGroups: 20 | - authorization.k8s.io 21 | resources: 22 | - subjectaccessreviews 23 | verbs: 24 | - create 25 | {{- end -}} -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/node-exporter-clusterRoleBinding.yaml: -------------------------------------------------------------------------------- 1 | {{/* 2 | Create the cluster role of node exporter to use 3 | */}} 4 | {{- if .Values.monitors.nodeExporter.rbac.create -}} 5 | apiVersion: rbac.authorization.k8s.io/v1 6 | kind: ClusterRoleBinding 7 | metadata: 8 | name: polardbx-node-exporter 9 | labels: 10 | app.kubernetes.io/instance: {{ .Release.Name }} 11 | app.kubernetes.io/managed-by: {{ .Release.Service }} 12 | roleRef: 13 | apiGroup: rbac.authorization.k8s.io 14 | kind: ClusterRole 15 | name: polardbx-node-exporter 16 | subjects: 17 | - kind: ServiceAccount 18 | name: node-exporter 19 | namespace: {{ .Release.Namespace }} 20 | {{- end -}} -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/node-exporter-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | app.kubernetes.io/name: node-exporter 6 | app.kubernetes.io/version: {{ .Values.monitors.nodeExporter.version}} 7 | app.kubernetes.io/instance: {{ .Release.Name }} 8 | app.kubernetes.io/managed-by: {{ .Release.Service }} 9 | name: node-exporter 10 | namespace: {{ .Release.Namespace }} 11 | spec: 12 | clusterIP: None 13 | ports: 14 | - name: https 15 | port: {{ .Values.monitors.nodeExporter.port }} 16 | targetPort: https 17 | selector: 18 | app.kubernetes.io/name: node-exporter 19 | 20 | -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/node-exporter-serviceAccount.yaml: -------------------------------------------------------------------------------- 1 | {{/* 2 | Create the service account of node exporter to use 3 | */}} 4 | {{- if .Values.monitors.nodeExporter.serviceAccount.create -}} 5 | apiVersion: v1 6 | kind: ServiceAccount 7 | metadata: 8 | name: node-exporter 9 | namespace: {{ .Release.Namespace }} 10 | labels: 11 | app.kubernetes.io/instance: {{ .Release.Name }} 12 | app.kubernetes.io/managed-by: {{ .Release.Service }} 13 | {{- end -}} -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/node-exporter-serviceMonitor.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: monitoring.coreos.com/v1 2 | kind: ServiceMonitor 3 | metadata: 4 | labels: 5 | app.kubernetes.io/name: node-exporter 6 | app.kubernetes.io/version: {{ .Values.monitors.nodeExporter.version}} 7 | app.kubernetes.io/instance: {{ .Release.Name }} 8 | app.kubernetes.io/managed-by: {{ .Release.Service }} 9 | name: node-exporter 10 | namespace: {{ .Release.Namespace }} 11 | spec: 12 | endpoints: 13 | - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token 14 | interval: 15s 15 | port: https 16 | relabelings: 17 | - action: replace 18 | regex: (.*) 19 | replacement: $1 20 | sourceLabels: 21 | - __meta_kubernetes_pod_node_name 22 | targetLabel: instance 23 | scheme: https 24 | tlsConfig: 25 | insecureSkipVerify: true 26 | jobLabel: app.kubernetes.io/name 27 | selector: 28 | matchLabels: 29 | app.kubernetes.io/name: node-exporter 30 | 31 | -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/prometheus-adapter-apiService.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apiregistration.k8s.io/v1 2 | kind: APIService 3 | metadata: 4 | name: v1beta1.metrics.k8s.io 5 | spec: 6 | group: metrics.k8s.io 7 | groupPriorityMinimum: 100 8 | insecureSkipTLSVerify: true 9 | service: 10 | name: prometheus-adapter 11 | namespace: {{ .Release.Namespace }} 12 | version: v1beta1 13 | versionPriority: 100 14 | 15 | -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/prometheus-adapter-clusterRole.yaml: -------------------------------------------------------------------------------- 1 | {{/* 2 | Create the cluster role of prometheus adaptor to use 3 | */}} 4 | {{- if .Values.monitors.prometheusAdapter.rbac.create -}} 5 | apiVersion: rbac.authorization.k8s.io/v1 6 | kind: ClusterRole 7 | metadata: 8 | name: polardbx-prometheus-adapter 9 | labels: 10 | app.kubernetes.io/instance: {{ .Release.Name }} 11 | app.kubernetes.io/managed-by: {{ .Release.Service }} 12 | rules: 13 | - apiGroups: 14 | - "" 15 | resources: 16 | - nodes 17 | - namespaces 18 | - pods 19 | - services 20 | verbs: 21 | - get 22 | - list 23 | - watch 24 | {{- end -}} -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/prometheus-adapter-clusterRoleAggregatedMetricsReader.yaml: -------------------------------------------------------------------------------- 1 | {{/* 2 | Create the cluster role of prometheus adaptor to use 3 | */}} 4 | {{- if .Values.monitors.prometheusAdapter.rbac.create -}} 5 | apiVersion: rbac.authorization.k8s.io/v1 6 | kind: ClusterRole 7 | metadata: 8 | labels: 9 | rbac.authorization.k8s.io/aggregate-to-admin: "true" 10 | rbac.authorization.k8s.io/aggregate-to-edit: "true" 11 | rbac.authorization.k8s.io/aggregate-to-view: "true" 12 | app.kubernetes.io/instance: {{ .Release.Name }} 13 | app.kubernetes.io/managed-by: {{ .Release.Service }} 14 | name: polardbx-system:aggregated-metrics-reader 15 | rules: 16 | - apiGroups: 17 | - metrics.k8s.io 18 | resources: 19 | - pods 20 | - nodes 21 | verbs: 22 | - get 23 | - list 24 | - watch 25 | {{- end -}} -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/prometheus-adapter-clusterRoleBinding.yaml: -------------------------------------------------------------------------------- 1 | {{/* 2 | Create the cluster role of prometheus adaptor to use 3 | */}} 4 | {{- if .Values.monitors.prometheusAdapter.rbac.create -}} 5 | apiVersion: rbac.authorization.k8s.io/v1 6 | kind: ClusterRoleBinding 7 | metadata: 8 | name: polardbx-prometheus-adapter 9 | labels: 10 | app.kubernetes.io/instance: {{ .Release.Name }} 11 | app.kubernetes.io/managed-by: {{ .Release.Service }} 12 | roleRef: 13 | apiGroup: rbac.authorization.k8s.io 14 | kind: ClusterRole 15 | name: polardbx-prometheus-adapter 16 | subjects: 17 | - kind: ServiceAccount 18 | name: prometheus-adapter 19 | namespace: {{ .Release.Namespace }} 20 | {{- end -}} -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/prometheus-adapter-clusterRoleBindingDelegator.yaml: -------------------------------------------------------------------------------- 1 | {{/* 2 | Create the cluster role of prometheus adaptor to use 3 | */}} 4 | {{- if .Values.monitors.prometheusAdapter.rbac.create -}} 5 | apiVersion: rbac.authorization.k8s.io/v1 6 | kind: ClusterRoleBinding 7 | metadata: 8 | name: resource-metrics:system:auth-delegator 9 | roleRef: 10 | apiGroup: rbac.authorization.k8s.io 11 | kind: ClusterRole 12 | name: system:auth-delegator 13 | subjects: 14 | - kind: ServiceAccount 15 | name: prometheus-adapter 16 | namespace: {{ .Release.Namespace }} 17 | {{- end -}} -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/prometheus-adapter-clusterRoleServerResources.yaml: -------------------------------------------------------------------------------- 1 | {{/* 2 | Create the cluster role of prometheus adaptor to use 3 | */}} 4 | {{- if .Values.monitors.prometheusAdapter.rbac.create -}} 5 | apiVersion: rbac.authorization.k8s.io/v1 6 | kind: ClusterRole 7 | metadata: 8 | name: resource-metrics-server-resources 9 | rules: 10 | - apiGroups: 11 | - metrics.k8s.io 12 | resources: 13 | - '*' 14 | verbs: 15 | - '*' 16 | {{- end -}} -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/prometheus-adapter-roleBindingAuthReader.yaml: -------------------------------------------------------------------------------- 1 | {{/* 2 | Create the cluster role of prometheus adaptor to use 3 | */}} 4 | {{- if .Values.monitors.prometheusAdapter.rbac.create -}} 5 | apiVersion: rbac.authorization.k8s.io/v1 6 | kind: RoleBinding 7 | metadata: 8 | name: polardbx-resource-metrics-auth-reader 9 | namespace: kube-system 10 | labels: 11 | app.kubernetes.io/instance: {{ .Release.Name }} 12 | app.kubernetes.io/managed-by: {{ .Release.Service }} 13 | roleRef: 14 | apiGroup: rbac.authorization.k8s.io 15 | kind: Role 16 | name: extension-apiserver-authentication-reader 17 | subjects: 18 | - kind: ServiceAccount 19 | name: prometheus-adapter 20 | namespace: {{ .Release.Namespace }} 21 | {{- end -}} -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/prometheus-adapter-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | name: prometheus-adapter 6 | app.kubernetes.io/instance: {{ .Release.Name }} 7 | app.kubernetes.io/managed-by: {{ .Release.Service }} 8 | name: prometheus-adapter 9 | namespace: {{ .Release.Namespace }} 10 | spec: 11 | ports: 12 | - name: https 13 | port: 443 14 | targetPort: 6443 15 | selector: 16 | name: prometheus-adapter 17 | 18 | -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/prometheus-adapter-serviceAccount.yaml: -------------------------------------------------------------------------------- 1 | {{/* 2 | Create the service account of prometheus adaptor to use 3 | */}} 4 | {{- if .Values.monitors.prometheusAdapter.serviceAccount.create -}} 5 | apiVersion: v1 6 | kind: ServiceAccount 7 | metadata: 8 | name: prometheus-adapter 9 | namespace: {{ .Release.Namespace }} 10 | labels: 11 | app.kubernetes.io/instance: {{ .Release.Name }} 12 | app.kubernetes.io/managed-by: {{ .Release.Service }} 13 | {{- end -}} -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/prometheus-adapter-serviceMonitor.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: monitoring.coreos.com/v1 2 | kind: ServiceMonitor 3 | metadata: 4 | labels: 5 | name: prometheus-adapter 6 | app.kubernetes.io/instance: {{ .Release.Name }} 7 | app.kubernetes.io/managed-by: {{ .Release.Service }} 8 | name: prometheus-adapter 9 | namespace: {{ .Release.Namespace }} 10 | spec: 11 | endpoints: 12 | - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token 13 | interval: 30s 14 | port: https 15 | scheme: https 16 | tlsConfig: 17 | insecureSkipVerify: true 18 | selector: 19 | matchLabels: 20 | name: prometheus-adapter 21 | 22 | -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/prometheus-clusterRole.yaml: -------------------------------------------------------------------------------- 1 | {{/* 2 | Create the cluster role of prometheus to use 3 | */}} 4 | {{- if .Values.monitors.prometheus.rbac.create -}} 5 | apiVersion: rbac.authorization.k8s.io/v1 6 | kind: ClusterRole 7 | metadata: 8 | name: polardbx-prometheus-k8s 9 | rules: 10 | - apiGroups: 11 | - "" 12 | resources: 13 | - nodes/metrics 14 | verbs: 15 | - get 16 | - nonResourceURLs: 17 | - /metrics 18 | verbs: 19 | - get 20 | - apiGroups: 21 | - "" 22 | resources: 23 | - services 24 | - pods 25 | - endpoints 26 | verbs: 27 | - get 28 | - list 29 | - watch 30 | {{- end -}} -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/prometheus-clusterRoleBinding.yaml: -------------------------------------------------------------------------------- 1 | {{/* 2 | Create the cluster role of prometheus to use 3 | */}} 4 | {{- if .Values.monitors.prometheus.rbac.create -}} 5 | apiVersion: rbac.authorization.k8s.io/v1 6 | kind: ClusterRoleBinding 7 | metadata: 8 | name: polardbx-prometheus-k8s 9 | roleRef: 10 | apiGroup: rbac.authorization.k8s.io 11 | kind: ClusterRole 12 | name: polardbx-prometheus-k8s 13 | subjects: 14 | - kind: ServiceAccount 15 | name: prometheus-k8s 16 | namespace: {{ .Release.Namespace }} 17 | {{- end -}} -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/prometheus-operator-clusterRoleBinding.yaml: -------------------------------------------------------------------------------- 1 | {{/* 2 | Create the cluster role of prometheus operator to use 3 | */}} 4 | {{- if .Values.monitors.prometheusOperator.rbac.create -}} 5 | apiVersion: rbac.authorization.k8s.io/v1 6 | kind: ClusterRoleBinding 7 | metadata: 8 | labels: 9 | app.kubernetes.io/component: controller 10 | app.kubernetes.io/name: prometheus-operator 11 | app.kubernetes.io/version: v0.44.1 12 | app.kubernetes.io/instance: {{ .Release.Name }} 13 | app.kubernetes.io/managed-by: {{ .Release.Service }} 14 | name: polardbx-prometheus-operator 15 | roleRef: 16 | apiGroup: rbac.authorization.k8s.io 17 | kind: ClusterRole 18 | name: polardbx-prometheus-operator 19 | subjects: 20 | - kind: ServiceAccount 21 | name: prometheus-operator 22 | namespace: {{ .Release.Namespace }} 23 | {{- end -}} -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/prometheus-operator-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | app.kubernetes.io/component: controller 6 | app.kubernetes.io/name: prometheus-operator 7 | app.kubernetes.io/version: {{ .Values.monitors.prometheusOperator.version }} 8 | app.kubernetes.io/instance: {{ .Release.Name }} 9 | app.kubernetes.io/managed-by: {{ .Release.Service }} 10 | name: prometheus-operator 11 | namespace: {{ .Release.Namespace }} 12 | spec: 13 | clusterIP: None 14 | ports: 15 | - name: https 16 | port: 8443 17 | targetPort: https 18 | selector: 19 | app.kubernetes.io/component: controller 20 | app.kubernetes.io/name: prometheus-operator 21 | -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/prometheus-operator-serviceAccount.yaml: -------------------------------------------------------------------------------- 1 | {{/* 2 | Create the cluster role of prometheus operator to use 3 | */}} 4 | {{- if .Values.monitors.prometheusOperator.serviceAccount.create -}} 5 | apiVersion: v1 6 | kind: ServiceAccount 7 | metadata: 8 | labels: 9 | app.kubernetes.io/component: controller 10 | app.kubernetes.io/name: prometheus-operator 11 | app.kubernetes.io/version: v0.44.1 12 | app.kubernetes.io/instance: {{ .Release.Name }} 13 | app.kubernetes.io/managed-by: {{ .Release.Service }} 14 | name: prometheus-operator 15 | namespace: {{ .Release.Namespace }} 16 | {{- end -}} -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/prometheus-operator-serviceMonitor.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: monitoring.coreos.com/v1 2 | kind: ServiceMonitor 3 | metadata: 4 | labels: 5 | app.kubernetes.io/component: controller 6 | app.kubernetes.io/name: prometheus-operator 7 | app.kubernetes.io/version: {{ .Values.monitors.prometheusOperator.version }} 8 | app.kubernetes.io/instance: {{ .Release.Name }} 9 | app.kubernetes.io/managed-by: {{ .Release.Service }} 10 | name: prometheus-operator 11 | namespace: {{ .Release.Namespace }} 12 | spec: 13 | endpoints: 14 | - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token 15 | honorLabels: true 16 | port: https 17 | scheme: https 18 | tlsConfig: 19 | insecureSkipVerify: true 20 | selector: 21 | matchLabels: 22 | app.kubernetes.io/component: controller 23 | app.kubernetes.io/name: prometheus-operator 24 | app.kubernetes.io/version: {{ .Values.monitors.prometheusOperator.version }} 25 | 26 | -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/prometheus-roleBindingConfig.yaml: -------------------------------------------------------------------------------- 1 | {{/* 2 | Create the role of prometheus to use 3 | */}} 4 | {{- if .Values.monitors.prometheus.rbac.create -}} 5 | apiVersion: rbac.authorization.k8s.io/v1 6 | kind: RoleBinding 7 | metadata: 8 | name: polardbx-prometheus-k8s-config 9 | namespace: {{ .Release.Namespace }} 10 | roleRef: 11 | apiGroup: rbac.authorization.k8s.io 12 | kind: Role 13 | name: polardbx-prometheus-k8s-config 14 | subjects: 15 | - kind: ServiceAccount 16 | name: prometheus-k8s 17 | namespace: {{ .Release.Namespace }} 18 | {{- end -}} -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/prometheus-roleConfig.yaml: -------------------------------------------------------------------------------- 1 | {{/* 2 | Create the role of prometheus to use 3 | */}} 4 | {{- if .Values.monitors.prometheus.rbac.create -}} 5 | apiVersion: rbac.authorization.k8s.io/v1 6 | kind: Role 7 | metadata: 8 | name: polardbx-prometheus-k8s-config 9 | namespace: {{ .Release.Namespace }} 10 | rules: 11 | - apiGroups: 12 | - "" 13 | resources: 14 | - configmaps 15 | verbs: 16 | - get 17 | {{- end -}} -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/prometheus-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | prometheus: k8s 6 | app.kubernetes.io/instance: {{ .Release.Name }} 7 | app.kubernetes.io/managed-by: {{ .Release.Service }} 8 | name: prometheus-k8s 9 | namespace: {{ .Release.Namespace }} 10 | spec: 11 | ports: 12 | - name: web 13 | port: 9090 14 | targetPort: web 15 | selector: 16 | app: prometheus 17 | prometheus: k8s 18 | sessionAffinity: ClientIP 19 | type: {{ .Values.monitors.prometheus.serviceType }} 20 | 21 | -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/prometheus-serviceAccount.yaml: -------------------------------------------------------------------------------- 1 | {{/* 2 | Create the role of prometheus to use 3 | */}} 4 | {{- if .Values.monitors.prometheus.serviceAccount.create -}} 5 | apiVersion: v1 6 | kind: ServiceAccount 7 | metadata: 8 | name: prometheus-k8s 9 | namespace: {{ .Release.Namespace }} 10 | labels: 11 | app.kubernetes.io/instance: {{ .Release.Name }} 12 | app.kubernetes.io/managed-by: {{ .Release.Service }} 13 | {{- end -}} -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/prometheus-serviceMonitor.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: monitoring.coreos.com/v1 2 | kind: ServiceMonitor 3 | metadata: 4 | labels: 5 | k8s-app: prometheus 6 | app.kubernetes.io/instance: {{ .Release.Name }} 7 | app.kubernetes.io/managed-by: {{ .Release.Service }} 8 | name: prometheus 9 | namespace: {{ .Release.Namespace }} 10 | spec: 11 | endpoints: 12 | - interval: 30s 13 | port: web 14 | selector: 15 | matchLabels: 16 | prometheus: k8s 17 | 18 | -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/prometheus-serviceMonitorCoreDNS.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: monitoring.coreos.com/v1 2 | kind: ServiceMonitor 3 | metadata: 4 | labels: 5 | k8s-app: coredns 6 | app.kubernetes.io/instance: {{ .Release.Name }} 7 | app.kubernetes.io/managed-by: {{ .Release.Service }} 8 | name: coredns 9 | namespace: {{ .Release.Namespace }} 10 | spec: 11 | endpoints: 12 | - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token 13 | interval: 15s 14 | port: metrics 15 | jobLabel: k8s-app 16 | namespaceSelector: 17 | matchNames: 18 | - kube-system 19 | selector: 20 | matchLabels: 21 | k8s-app: kube-dns 22 | 23 | -------------------------------------------------------------------------------- /charts/polardbx-monitor/templates/prometheus-serviceMonitorKubeScheduler.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: monitoring.coreos.com/v1 2 | kind: ServiceMonitor 3 | metadata: 4 | labels: 5 | k8s-app: kube-scheduler 6 | app.kubernetes.io/instance: {{ .Release.Name }} 7 | app.kubernetes.io/managed-by: {{ .Release.Service }} 8 | name: kube-scheduler 9 | namespace: {{ .Release.Namespace }} 10 | spec: 11 | endpoints: 12 | - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token 13 | interval: 30s 14 | port: https-metrics 15 | scheme: https 16 | tlsConfig: 17 | insecureSkipVerify: true 18 | jobLabel: k8s-app 19 | namespaceSelector: 20 | matchNames: 21 | - kube-system 22 | selector: 23 | matchLabels: 24 | k8s-app: kube-scheduler 25 | 26 | -------------------------------------------------------------------------------- /charts/polardbx-operator/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | name: polardbx-operator 3 | description: Helm chart of polardbx-operator 4 | type: application 5 | version: 1.7.0 6 | appVersion: v1.7.0 7 | keywords: 8 | - polardb-x 9 | - operator 10 | home: https://www.aliyun.com/product/drds 11 | sources: 12 | - https://github.com/ApsaraDB/galaxykube -------------------------------------------------------------------------------- /charts/polardbx-operator/templates/NOTES.txt: -------------------------------------------------------------------------------- 1 | polardbx-operator is installed. Please check the status of components: 2 | 3 | kubectl get pods --namespace {{ .Release.Namespace }} 4 | 5 | Now have fun with your first PolarDB-X cluster. 6 | 7 | Here's the manifest for quick start: 8 | 9 | ```yaml 10 | apiVersion: polardbx.aliyun.com/v1 11 | kind: PolarDBXCluster 12 | metadata: 13 | name: quick-start 14 | annotations: 15 | polardbx/topology-mode-guide: quick-start 16 | ``` -------------------------------------------------------------------------------- /charts/polardbx-operator/templates/_helpers.tpl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polardb/polardbx-operator/ae33ef90e8c5a36c0c749dc5e492fd6ac23d3ef3/charts/polardbx-operator/templates/_helpers.tpl -------------------------------------------------------------------------------- /charts/polardbx-operator/templates/host-path-file-configmap.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: {{ .Values.hostPathFileService.name}}-config 5 | namespace: {{ .Release.Namespace }} 6 | data: 7 | config.yaml: |- 8 | sinks: 9 | {{ toYaml .Values.hostPathFileService.sinks | indent 7 }} 10 | backupBinlogConfig: 11 | rootDirectories: 12 | - {{ .Values.node.volumes.data }}/xstore 13 | - {{ .Values.node.volumes.log }}/xstore 14 | cGroupControlConfig: 15 | cpu_set_strategy: {{ .Values.hostPathFileService.cpuBind.strategy }} 16 | 17 | 18 | -------------------------------------------------------------------------------- /charts/polardbx-operator/templates/host-path-file-service-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ .Values.hostPathFileService.name }} 5 | namespace: {{ .Release.Namespace }} 6 | labels: 7 | app.kubernetes.io/name: {{ .Chart.Name }} 8 | app.kubernetes.io/managed-by: {{ .Release.Service }} 9 | app.kubernetes.io/instance: {{ .Release.Name }} 10 | app.kubernetes.io/component: polardbx-hpfs 11 | spec: 12 | selector: 13 | app.kubernetes.io/name: {{ .Chart.Name }} 14 | app.kubernetes.io/instance: {{ .Release.Name }} 15 | app.kubernetes.io/component: polardbx-hpfs 16 | ports: 17 | - name: hpfs 18 | port: {{ .Values.hostPathFileService.port }} 19 | targetPort: hpfs 20 | - name: filestream 21 | port: {{ .Values.hostPathFileService.fsPort }} 22 | targetPort: filestream -------------------------------------------------------------------------------- /charts/polardbx-operator/templates/webhook/admission-webhook-apiservice.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apiregistration.k8s.io/v1 2 | kind: APIService 3 | metadata: 4 | name: v1.admission.polardbx.aliyun.com 5 | namespace: {{ .Release.Namespace }} 6 | spec: 7 | insecureSkipTLSVerify: true 8 | group: admission.polardbx.aliyun.com 9 | groupPriorityMinimum: 1000 10 | versionPriority: 15 11 | service: 12 | name: {{ .Values.webhook.serviceName }} 13 | namespace: {{ .Release.Namespace }} 14 | version: v1 15 | -------------------------------------------------------------------------------- /charts/polardbx-operator/templates/webhook/admission-webhook-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ .Values.webhook.serviceName }} 5 | namespace: {{ .Release.Namespace }} 6 | labels: 7 | app.kubernetes.io/name: {{ .Chart.Name }} 8 | app.kubernetes.io/managed-by: {{ .Release.Service }} 9 | app.kubernetes.io/component: admission-webhook 10 | spec: 11 | selector: 12 | app.kubernetes.io/name: {{ .Chart.Name }} 13 | app.kubernetes.io/instance: {{ .Release.Name }} 14 | app.kubernetes.io/component: controller-manager 15 | ports: 16 | - port: 443 17 | protocol: TCP 18 | targetPort: "webhook" -------------------------------------------------------------------------------- /cmd/polardbx-binlog/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package main 18 | 19 | import ( 20 | "github.com/alibaba/polardbx-operator/pkg/binlogtool/cmd" 21 | ) 22 | 23 | func main() { 24 | cmd.Run() 25 | } 26 | -------------------------------------------------------------------------------- /cmd/polardbx-init/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package main 18 | 19 | import ( 20 | initp "github.com/alibaba/polardbx-operator/pkg/init" 21 | ) 22 | 23 | func main() { 24 | initp.Do() 25 | } 26 | -------------------------------------------------------------------------------- /hack/boilerplates/boilerplate.go.txt: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright YEAR Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ -------------------------------------------------------------------------------- /hack/boilerplates/boilerplate.py.txt: -------------------------------------------------------------------------------- 1 | # Copyright YEAR Alibaba Group Holding Limited. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. -------------------------------------------------------------------------------- /hack/boilerplates/boilerplate.sh.txt: -------------------------------------------------------------------------------- 1 | # Copyright YEAR Alibaba Group Holding Limited. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. -------------------------------------------------------------------------------- /hack/make-rules/lib/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Alibaba Group Holding Limited. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from . import golang 16 | from .build_env import * 17 | -------------------------------------------------------------------------------- /hack/make-rules/lib/golang.py: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Alibaba Group Holding Limited. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import subprocess 16 | 17 | from .build_env import BuildEnv 18 | 19 | 20 | def run_mod_tidy(build_env: BuildEnv): 21 | subprocess.check_call('go mod tidy', shell=True, cwd=build_env.root_dir) 22 | 23 | 24 | def run_mod_vendor(build_env: BuildEnv): 25 | subprocess.check_call('go mod vendor', shell=True, cwd=build_env.root_dir) 26 | -------------------------------------------------------------------------------- /pkg/binlogtool/binlog/errs/error.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package errs 18 | 19 | import "errors" 20 | 21 | var ( 22 | ErrInvalidEvent = errors.New("invalid event") 23 | ErrUnrecognizedVersion = errors.New("unrecognized version") 24 | ) 25 | -------------------------------------------------------------------------------- /pkg/binlogtool/binlog/event/anonymous_gtid_event.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package event 18 | 19 | type AnonymousGTIDEvent struct { 20 | GTIDLogEvent `json:",inline"` 21 | } 22 | -------------------------------------------------------------------------------- /pkg/binlogtool/binlog/event/consensus_cluster_info_event.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package event 18 | 19 | import ( 20 | "github.com/alibaba/polardbx-operator/pkg/binlogtool/binlog/layout" 21 | "github.com/alibaba/polardbx-operator/pkg/binlogtool/binlog/str" 22 | ) 23 | 24 | type ConsensusClusterInfoEvent struct { 25 | Info str.Str `json:"info,omitempty"` 26 | } 27 | 28 | func (e *ConsensusClusterInfoEvent) Layout(version uint32, code byte, fde *FormatDescriptionEvent) *layout.Layout { 29 | return layout.Decl(layout.Bytes(layout.Infinite(), &e.Info)) 30 | } 31 | -------------------------------------------------------------------------------- /pkg/binlogtool/binlog/event/consensus_empty_event.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package event 18 | 19 | import ( 20 | "github.com/alibaba/polardbx-operator/pkg/binlogtool/binlog/layout" 21 | ) 22 | 23 | type ConsensusEmptyEvent struct { 24 | } 25 | 26 | func (e *ConsensusEmptyEvent) Layout(version uint32, code byte, fde *FormatDescriptionEvent) *layout.Layout { 27 | return layout.Decl() 28 | } 29 | -------------------------------------------------------------------------------- /pkg/binlogtool/binlog/event/delete_file_event.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package event 18 | 19 | import ( 20 | "github.com/alibaba/polardbx-operator/pkg/binlogtool/binlog/layout" 21 | ) 22 | 23 | type DeleteFileEvent struct { 24 | FileID uint32 `json:"file_id,omitempty"` 25 | } 26 | 27 | func (e *DeleteFileEvent) Layout(version uint32, code byte, fde *FormatDescriptionEvent) *layout.Layout { 28 | return layout.Decl(layout.Number(&e.FileID)) 29 | } 30 | -------------------------------------------------------------------------------- /pkg/binlogtool/binlog/event/exec_load_event.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package event 18 | 19 | import ( 20 | "github.com/alibaba/polardbx-operator/pkg/binlogtool/binlog/layout" 21 | ) 22 | 23 | type ExecLoadEvent struct { 24 | FileID uint32 `json:"file_id,omitempty"` 25 | } 26 | 27 | func (e *ExecLoadEvent) Layout(version uint32, code byte, fde *FormatDescriptionEvent) *layout.Layout { 28 | return layout.Decl(layout.Number(&e.FileID)) 29 | } 30 | -------------------------------------------------------------------------------- /pkg/binlogtool/binlog/event/gcn_event.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package event 18 | 19 | import ( 20 | "github.com/alibaba/polardbx-operator/pkg/binlogtool/binlog/layout" 21 | ) 22 | 23 | type GCNEvent struct { 24 | GCN uint64 `json:"gcn,omitempty"` 25 | } 26 | 27 | func (e *GCNEvent) Layout(version uint32, code byte, fde *FormatDescriptionEvent) *layout.Layout { 28 | var flag uint8 29 | return layout.Decl( 30 | layout.Number(&flag), 31 | layout.Number(&e.GCN), 32 | ) 33 | } 34 | -------------------------------------------------------------------------------- /pkg/binlogtool/binlog/event/heartbeat_event.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package event 18 | 19 | import ( 20 | "github.com/alibaba/polardbx-operator/pkg/binlogtool/binlog/layout" 21 | ) 22 | 23 | type HeartbeatEvent struct { 24 | } 25 | 26 | func (e *HeartbeatEvent) Layout(version uint32, code byte, fde *FormatDescriptionEvent) *layout.Layout { 27 | return nil 28 | } 29 | -------------------------------------------------------------------------------- /pkg/binlogtool/binlog/event/heartbeat_event_v2.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package event 18 | 19 | import ( 20 | "github.com/alibaba/polardbx-operator/pkg/binlogtool/binlog/layout" 21 | ) 22 | 23 | type HeartbeatEventV2 struct { 24 | } 25 | 26 | func (e *HeartbeatEventV2) Layout(version uint32, code byte, fde *FormatDescriptionEvent) *layout.Layout { 27 | return nil 28 | } 29 | -------------------------------------------------------------------------------- /pkg/binlogtool/binlog/event/layout_view.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package event 18 | 19 | import "github.com/alibaba/polardbx-operator/pkg/binlogtool/binlog/layout" 20 | 21 | type LayoutView interface { 22 | Layout(version uint32, code byte, fde *FormatDescriptionEvent) *layout.Layout 23 | } 24 | -------------------------------------------------------------------------------- /pkg/binlogtool/binlog/event/previous_consensus_index_event.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package event 18 | 19 | import ( 20 | "github.com/alibaba/polardbx-operator/pkg/binlogtool/binlog/layout" 21 | ) 22 | 23 | type PreviousConsensusIndexEvent struct { 24 | Index uint64 `json:"index,omitempty"` 25 | } 26 | 27 | func (e *PreviousConsensusIndexEvent) Layout(version uint32, code byte, fde *FormatDescriptionEvent) *layout.Layout { 28 | return layout.Decl( 29 | layout.Number(&e.Index)) 30 | } 31 | -------------------------------------------------------------------------------- /pkg/binlogtool/binlog/event/rand_event.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package event 18 | 19 | import ( 20 | "github.com/alibaba/polardbx-operator/pkg/binlogtool/binlog/layout" 21 | ) 22 | 23 | type RandEvent struct { 24 | FirstSeed uint64 `json:"first_seed,omitempty"` 25 | SecondSeed uint64 `json:"second_seed,omitempty"` 26 | } 27 | 28 | func (e *RandEvent) Layout(version uint32, code byte, fde *FormatDescriptionEvent) *layout.Layout { 29 | return layout.Decl( 30 | layout.Number(&e.FirstSeed), 31 | layout.Number(&e.SecondSeed), 32 | ) 33 | } 34 | -------------------------------------------------------------------------------- /pkg/binlogtool/binlog/event/raw_event.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package event 18 | 19 | type RawLogEventData []byte 20 | 21 | type RawLogEventV1 struct { 22 | Header LogEventHeaderV1 `json:"header,omitempty"` 23 | Data RawLogEventData `json:"data,omitempty"` 24 | } 25 | 26 | type RawLogEventV3 struct { 27 | Header LogEventHeaderV3 `json:"header,omitempty"` 28 | Data RawLogEventData `json:"data,omitempty"` 29 | } 30 | 31 | type RawLogEventV4 struct { 32 | Header LogEventHeaderV4 `json:"header,omitempty"` 33 | Data RawLogEventData `json:"data,omitempty"` 34 | } 35 | -------------------------------------------------------------------------------- /pkg/binlogtool/binlog/event/sequence_event.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package event 18 | 19 | import ( 20 | "github.com/alibaba/polardbx-operator/pkg/binlogtool/binlog/layout" 21 | ) 22 | 23 | type SequenceEvent struct { 24 | SequenceType uint8 `json:"sequence_type,omitempty"` 25 | SequenceNum uint64 `json:"sequence_num,omitempty"` 26 | } 27 | 28 | func (e *SequenceEvent) Layout(version uint32, code byte, fde *FormatDescriptionEvent) *layout.Layout { 29 | return layout.Decl( 30 | layout.Number(&e.SequenceType), 31 | layout.Number(&e.SequenceNum), 32 | ) 33 | } 34 | -------------------------------------------------------------------------------- /pkg/binlogtool/binlog/event/slave_event.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package event 18 | 19 | import ( 20 | "github.com/alibaba/polardbx-operator/pkg/binlogtool/binlog/layout" 21 | ) 22 | 23 | type SlaveEvent struct{} 24 | 25 | func (e *SlaveEvent) Layout(version uint32, code byte, fde *FormatDescriptionEvent) *layout.Layout { 26 | return layout.Decl() 27 | } 28 | -------------------------------------------------------------------------------- /pkg/binlogtool/binlog/event/stop_event.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package event 18 | 19 | import "github.com/alibaba/polardbx-operator/pkg/binlogtool/binlog/layout" 20 | 21 | type StopEvent struct { 22 | } 23 | 24 | func (s *StopEvent) Layout(version uint32, code byte, fde *FormatDescriptionEvent) *layout.Layout { 25 | return layout.Decl() 26 | } 27 | -------------------------------------------------------------------------------- /pkg/binlogtool/binlog/event/transaction_context_event.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package event 18 | 19 | import ( 20 | "github.com/alibaba/polardbx-operator/pkg/binlogtool/binlog/layout" 21 | ) 22 | 23 | type TransactionContextEvent struct { 24 | } 25 | 26 | func (e *TransactionContextEvent) Layout(version uint32, code byte, fde *FormatDescriptionEvent) *layout.Layout { 27 | return nil 28 | } 29 | -------------------------------------------------------------------------------- /pkg/binlogtool/binlog/event/transaction_payload_event.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package event 18 | 19 | import "github.com/alibaba/polardbx-operator/pkg/binlogtool/binlog/layout" 20 | 21 | type TransactionPayloadEvent struct { 22 | } 23 | 24 | func (e *TransactionPayloadEvent) Layout(version uint32, code byte, fde *FormatDescriptionEvent) *layout.Layout { 25 | return nil 26 | } 27 | -------------------------------------------------------------------------------- /pkg/binlogtool/binlog/event/view_change_event.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package event 18 | 19 | import ( 20 | "github.com/alibaba/polardbx-operator/pkg/binlogtool/binlog/layout" 21 | ) 22 | 23 | type ViewChangeEvent struct { 24 | } 25 | 26 | func (e *ViewChangeEvent) Layout(version uint32, code byte, fde *FormatDescriptionEvent) *layout.Layout { 27 | return nil 28 | } 29 | -------------------------------------------------------------------------------- /pkg/binlogtool/binlog/event/xid_event.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package event 18 | 19 | import ( 20 | "github.com/alibaba/polardbx-operator/pkg/binlogtool/binlog/layout" 21 | ) 22 | 23 | type XIDEvent struct { 24 | // Not always little endian. 25 | XID uint64 `json:"xid,omitempty"` 26 | } 27 | 28 | func (e *XIDEvent) Layout(version uint32, code byte, fde *FormatDescriptionEvent) *layout.Layout { 29 | return layout.Decl(layout.Number(&e.XID)) 30 | } 31 | -------------------------------------------------------------------------------- /pkg/binlogtool/binlog/layout/layout_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package layout 18 | 19 | import ( 20 | "encoding/json" 21 | ) 22 | 23 | func jsonPrettyFormat(d any) string { 24 | r, err := json.MarshalIndent(d, "", " ") 25 | if err != nil { 26 | panic(err) 27 | } 28 | return string(r) 29 | } 30 | -------------------------------------------------------------------------------- /pkg/binlogtool/cmd/root_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package cmd 18 | -------------------------------------------------------------------------------- /pkg/binlogtool/tx/xa.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package tx 18 | 19 | // Leading characters that XA transaction steps have. 20 | const ( 21 | XAStart = "XA START" 22 | XAEnd = "XA END" 23 | XAPrepare = "XA PREPARE" 24 | XACommit = "XA COMMIT" 25 | XARollback = "XA ROLLBACK" 26 | ) 27 | -------------------------------------------------------------------------------- /pkg/binlogtool/utils/json.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package utils 18 | 19 | import "encoding/json" 20 | 21 | func JsonPrettyFormat(d any) string { 22 | r, err := json.MarshalIndent(d, "", " ") 23 | if err != nil { 24 | panic(err) 25 | } 26 | return string(r) 27 | } 28 | -------------------------------------------------------------------------------- /pkg/binlogtool/utils/map.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package utils 18 | 19 | func OneKey[K comparable, V any](m map[K]V) K { 20 | for k := range m { 21 | return k 22 | } 23 | var k K 24 | return k 25 | } 26 | 27 | func MapKeys[K comparable, V any](m map[K]V) []K { 28 | if m == nil { 29 | return nil 30 | } 31 | 32 | i := 0 33 | keys := make([]K, len(m)) 34 | for k := range m { 35 | keys[i] = k 36 | i++ 37 | } 38 | return keys 39 | } 40 | -------------------------------------------------------------------------------- /pkg/binlogtool/utils/print.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package utils 18 | 19 | import ( 20 | "bytes" 21 | "fmt" 22 | 23 | "golang.org/x/exp/constraints" 24 | ) 25 | 26 | func JoinIntegerSequence[T constraints.Integer](s []T, sep string) string { 27 | buf := &bytes.Buffer{} 28 | for i := 0; i < len(s); i++ { 29 | buf.WriteString(fmt.Sprintf("%d", s[i])) 30 | if i != len(s)-1 { 31 | buf.WriteString(sep) 32 | } 33 | } 34 | return buf.String() 35 | } 36 | -------------------------------------------------------------------------------- /pkg/binlogtool/utils/timestamp.go: -------------------------------------------------------------------------------- 1 | //go:build polardbx 2 | 3 | /* 4 | Copyright 2022 Alibaba Group Holding Limited. 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | */ 18 | 19 | package utils 20 | 21 | import "time" 22 | 23 | type TSOTime uint64 24 | 25 | func NewTSOTimeFromMillis(t uint64) TSOTime { 26 | return TSOTime(t << 22) 27 | } 28 | 29 | func NewTSOTime(t time.Time) TSOTime { 30 | return TSOTime(uint64(t.UnixMilli()) << 22) 31 | } 32 | 33 | func (t TSOTime) Time() time.Time { 34 | return time.UnixMilli(int64(t >> 22)) 35 | } 36 | -------------------------------------------------------------------------------- /pkg/binlogtool/version/const.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package version 18 | 19 | var ( 20 | Version = "unknown" 21 | BuildTime = "unknown" 22 | Dirty string 23 | Tags string 24 | ) 25 | 26 | func PrintVersionAndTags() string { 27 | if Tags == "" { 28 | return Version 29 | } 30 | return Version + " +" + Tags 31 | } 32 | -------------------------------------------------------------------------------- /pkg/debug/debug.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package debug 18 | 19 | var debug = false 20 | 21 | func EnableDebug() { 22 | debug = true 23 | } 24 | 25 | func IsDebugEnabled() bool { 26 | return debug 27 | } 28 | 29 | func Namespace() string { 30 | return "development" 31 | } 32 | -------------------------------------------------------------------------------- /pkg/exporter/cdc/adaptor_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package cdc 18 | 19 | import ( 20 | "fmt" 21 | "os" 22 | "testing" 23 | ) 24 | 25 | func TestAdaptor_parse(t *testing.T) { 26 | f, err := os.Open("testdata/sample.txt") 27 | if err != nil { 28 | t.Fatal(err) 29 | } 30 | 31 | adpt := &Adaptor{} 32 | mf, err := adpt.parse(f) 33 | if err != nil { 34 | t.Fatal(err) 35 | } 36 | 37 | for k, v := range mf { 38 | fmt.Println("KEY: ", k) 39 | fmt.Println("VAL: ", v.Metric) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /pkg/exporter/extensions/jvm/testdata/11/211: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polardb/polardbx-operator/ae33ef90e8c5a36c0c749dc5e492fd6ac23d3ef3/pkg/exporter/extensions/jvm/testdata/11/211 -------------------------------------------------------------------------------- /pkg/exporter/extensions/jvm/testdata/181: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polardb/polardbx-operator/ae33ef90e8c5a36c0c749dc5e492fd6ac23d3ef3/pkg/exporter/extensions/jvm/testdata/181 -------------------------------------------------------------------------------- /pkg/featuregate/featuregates_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package featuregate 18 | 19 | import "testing" 20 | 21 | var testGate = declareFeatureGate("testGate", false, false, "Test gate.") 22 | 23 | func TestSetupFeatureGates(t *testing.T) { 24 | SetupFeatureGates([]string{"testGate"}) 25 | if !testGate.Enabled() { 26 | t.Fatal() 27 | } 28 | 29 | SetupFeatureGates([]string{"testGate-"}) 30 | if testGate.Enabled() { 31 | t.Fatal() 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /pkg/hpfs/backupbinlog/purge_test.go: -------------------------------------------------------------------------------- 1 | package backupbinlog 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | ) 7 | 8 | func TestFindMysqlSock(t *testing.T) { 9 | logDir := "/Users/busu/tmp/mysqldata/log" 10 | rootDirs := []string{"/Users/busu/", "/Users/dingfeng"} 11 | mysqlSockPath, _ := FindMysqlSockByLogDir(logDir, rootDirs) 12 | fmt.Println(mysqlSockPath) 13 | } 14 | -------------------------------------------------------------------------------- /pkg/hpfs/backupbinlog/watcher_test.go: -------------------------------------------------------------------------------- 1 | package backupbinlog 2 | 3 | import ( 4 | "testing" 5 | "time" 6 | ) 7 | 8 | func TestWatcher(t *testing.T) { 9 | NewWatcher("/Users/busu/tmp/litewatchertest", BeforeUpload, FetchStartIndex, Upload, RecordUpload, AfterUpload).Start() 10 | time.Sleep(1 * time.Hour) 11 | } 12 | -------------------------------------------------------------------------------- /pkg/hpfs/cpusetbind/pool/service.go: -------------------------------------------------------------------------------- 1 | package pool 2 | 3 | type CpuSetPool interface { 4 | MarkAllocated(cpus []int) 5 | TestAvailable(cpus []int) bool 6 | AllocateProcessors(processors int) ([]int, error) 7 | SetPreferredNumaNode(numaNode int) 8 | ConsiderNuma() bool 9 | Name() string 10 | } 11 | -------------------------------------------------------------------------------- /pkg/hpfs/cpusetbind/system/io.go: -------------------------------------------------------------------------------- 1 | package cpusetbind 2 | 3 | import ( 4 | "io" 5 | "os" 6 | "strconv" 7 | "strings" 8 | ) 9 | 10 | const NewLineSeparator = "\n" 11 | 12 | func ReadFile(filepath string) (string, error) { 13 | f, err := os.OpenFile(filepath, os.O_RDONLY, os.ModePerm) 14 | if err != nil { 15 | return "", err 16 | } 17 | defer f.Close() 18 | data, err := io.ReadAll(f) 19 | if err != nil { 20 | return "", err 21 | } 22 | return string(data), nil 23 | } 24 | 25 | func ReadIntFromFile(filepath string) (int64, error) { 26 | str, err := ReadFile(filepath) 27 | if err != nil { 28 | return -1, err 29 | } 30 | intVal, err := strconv.ParseInt(strings.TrimSpace(str), 10, 32) 31 | if err != nil { 32 | return -1, err 33 | } 34 | return intVal, nil 35 | } 36 | -------------------------------------------------------------------------------- /pkg/hpfs/cpusetbind/system/proc_test.go: -------------------------------------------------------------------------------- 1 | package cpusetbind 2 | 3 | import ( 4 | . "github.com/onsi/gomega" 5 | "testing" 6 | ) 7 | 8 | func TestGetNumaNodeRight(t *testing.T) { 9 | g := NewGomegaWithT(t) 10 | result := GetNumaNode("56284e99b000 default file=/opt/alibaba/dragonwell-11.0.17.13+8-GA/bin/java anon=1 dirty=1 active=0 N0=1 kernelpagesize_kB=4") 11 | g.Expect(result).Should(BeEquivalentTo("0")) 12 | result = GetNumaNode("56284e99b000 default file=/opt/alibaba/dragonwell-11.0.17.13+8-GA/bin/java anon=1 dirty=1 N12=10 kernelpagesize_kB=4") 13 | g.Expect(result).Should(BeEquivalentTo("12")) 14 | } 15 | 16 | func TestGetNumaNodeWrong(t *testing.T) { 17 | g := NewGomegaWithT(t) 18 | result := GetNumaNode("56284e99b000 default file=/opt/alibaba/dragonwell-11.0.17.13+8-GA/bin/java anon=1 dirty=1 active=0 NN=1 kernelpagesize_kB=4") 19 | g.Expect(result).Should(BeEquivalentTo("")) 20 | result = GetNumaNode("56284e99b000 default file=/opt/alibaba/dragonwell-11.0.17.13+8-GA/bin/java anon=1 dirty=1 NN=10 kernelpagesize_kB=4") 21 | g.Expect(result).Should(BeEquivalentTo("")) 22 | result = GetNumaNode("") 23 | g.Expect(result).Should(BeEquivalentTo("")) 24 | } 25 | -------------------------------------------------------------------------------- /pkg/hpfs/cpusetbind/system/testfiles/node/node0/cpulist: -------------------------------------------------------------------------------- 1 | 0-25,52-77 -------------------------------------------------------------------------------- /pkg/hpfs/cpusetbind/system/testfiles/node/node1/cpulist: -------------------------------------------------------------------------------- 1 | 26-51,78-103 -------------------------------------------------------------------------------- /pkg/hpfs/cpusetbind/system/testfiles/node/online: -------------------------------------------------------------------------------- 1 | 0-1 -------------------------------------------------------------------------------- /pkg/hpfs/cpusetbind/system/testfiles/nodeonline0: -------------------------------------------------------------------------------- 1 | 0 -------------------------------------------------------------------------------- /pkg/hpfs/cpusetbind/system/testfiles/nodeonline1: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /pkg/hpfs/cpusetbind/system/testfiles/nodeonline2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polardb/polardbx-operator/ae33ef90e8c5a36c0c749dc5e492fd6ac23d3ef3/pkg/hpfs/cpusetbind/system/testfiles/nodeonline2 -------------------------------------------------------------------------------- /pkg/hpfs/cpusetbind/system/testfiles/nodeonline3: -------------------------------------------------------------------------------- 1 | 0-1 -------------------------------------------------------------------------------- /pkg/hpfs/filestream/common.go: -------------------------------------------------------------------------------- 1 | package filestream 2 | 3 | import ( 4 | "encoding/json" 5 | "github.com/alibaba/polardbx-operator/pkg/hpfs/config" 6 | "github.com/alibaba/polardbx-operator/pkg/hpfs/discovery" 7 | "os" 8 | ) 9 | 10 | func GetClientActionBySinkType(sinkType string) Action { 11 | switch sinkType { 12 | case config.SinkTypeOss: 13 | return DownloadOss 14 | case config.SinkTypeSftp: 15 | return DownloadSsh 16 | case config.SinkTypeMinio: 17 | return DownloadMinio 18 | } 19 | return InvalidAction 20 | } 21 | 22 | func GetHostInfoFromConfig(filepath string) (map[string]discovery.HostInfo, error) { 23 | data, err := os.ReadFile(filepath) 24 | if err != nil { 25 | return nil, err 26 | } 27 | result := map[string]discovery.HostInfo{} 28 | if err = json.Unmarshal(data, &result); err != nil { 29 | return nil, err 30 | } 31 | return result, nil 32 | } 33 | -------------------------------------------------------------------------------- /pkg/hpfs/filestream/fallocate_darwin.go: -------------------------------------------------------------------------------- 1 | //go:build !linux 2 | 3 | /* 4 | Copyright 2021 Alibaba Group Holding Limited. 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | */ 18 | 19 | package filestream 20 | 21 | import ( 22 | "errors" 23 | ) 24 | 25 | func Fallocate(fd int, mode uint32, off int64, len int64) (err error) { 26 | return errors.New("not supported") 27 | } 28 | -------------------------------------------------------------------------------- /pkg/hpfs/filestream/fallocate_linux.go: -------------------------------------------------------------------------------- 1 | //go:build linux 2 | 3 | /* 4 | Copyright 2021 Alibaba Group Holding Limited. 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | */ 18 | 19 | package filestream 20 | 21 | import ( 22 | "syscall" 23 | ) 24 | 25 | func Fallocate(fd int, mode uint32, off int64, len int64) (err error) { 26 | return syscall.Fallocate(fd, mode, off, len) 27 | } 28 | -------------------------------------------------------------------------------- /pkg/hpfs/generate.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package hpfs 18 | 19 | //go:generate protoc --proto_path=proto --go_opt=module=github.com/alibaba/polardbx-operator/pkg/hpfs --go_out=plugins=grpc:. proto/hpfs.proto 20 | -------------------------------------------------------------------------------- /pkg/k8s/control/trace.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package control 18 | 19 | import "github.com/google/uuid" 20 | 21 | type tracer struct { 22 | stepIndex int 23 | id string 24 | } 25 | 26 | func (t *tracer) currentStepIndex() int { 27 | return t.stepIndex 28 | } 29 | 30 | func (t *tracer) markStepDone() { 31 | t.stepIndex++ 32 | } 33 | 34 | func newTracer() *tracer { 35 | return &tracer{ 36 | stepIndex: 0, 37 | id: uuid.New().String(), 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /pkg/k8s/helper/configmap.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package helper 18 | -------------------------------------------------------------------------------- /pkg/k8s/helper/const.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package helper 18 | 19 | const NodeRoleKey = "kubernetes.io/role" 20 | -------------------------------------------------------------------------------- /pkg/k8s/helper/dnpod.go: -------------------------------------------------------------------------------- 1 | package helper 2 | 3 | import ( 4 | "fmt" 5 | corev1 "k8s.io/api/core/v1" 6 | ) 7 | 8 | func GetPaxosAddr(pod *corev1.Pod) string { 9 | paxosPort := MustGetPortFromContainer(MustGetContainerFromPod(pod, "engine"), "paxos").ContainerPort 10 | addr := fmt.Sprintf("%s:%d", pod.Status.PodIP, paxosPort) 11 | return addr 12 | } 13 | 14 | func GetPaxosAddrs(pods []corev1.Pod) []string { 15 | addrs := make([]string, 0, len(pods)) 16 | for _, pod := range pods { 17 | addrs = append(addrs, GetPaxosAddr(&pod)) 18 | } 19 | return addrs 20 | } 21 | -------------------------------------------------------------------------------- /pkg/k8s/helper/env.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package helper 18 | 19 | import ( 20 | "sort" 21 | 22 | corev1 "k8s.io/api/core/v1" 23 | ) 24 | 25 | func PatchEnvs(origin []corev1.EnvVar, patches ...[]corev1.EnvVar) []corev1.EnvVar { 26 | for _, patch := range patches { 27 | origin = append(origin, patch...) 28 | } 29 | 30 | // Sort to provide a stable slice. 31 | sort.Slice(origin, func(i, j int) bool { 32 | return origin[i].Name < origin[j].Name 33 | }) 34 | 35 | return origin 36 | } 37 | -------------------------------------------------------------------------------- /pkg/k8s/helper/finalizer.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package helper 18 | 19 | import ( 20 | "sigs.k8s.io/controller-runtime/pkg/client" 21 | ) 22 | 23 | func ContainsOnlyFinalizer(obj client.Object, finalizer string) bool { 24 | return len(obj.GetFinalizers()) == 1 && obj.GetFinalizers()[0] == finalizer 25 | } 26 | -------------------------------------------------------------------------------- /pkg/k8s/helper/job.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package helper 18 | 19 | import ( 20 | batchv1 "k8s.io/api/batch/v1" 21 | corev1 "k8s.io/api/core/v1" 22 | ) 23 | 24 | func IsJobCompleted(job *batchv1.Job) bool { 25 | if job == nil { 26 | return false 27 | } 28 | 29 | for _, cond := range job.Status.Conditions { 30 | if cond.Type == batchv1.JobComplete && cond.Status == corev1.ConditionTrue { 31 | return true 32 | } 33 | } 34 | 35 | return false 36 | } 37 | -------------------------------------------------------------------------------- /pkg/k8s/helper/name.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package helper 18 | 19 | import "k8s.io/apimachinery/pkg/types" 20 | 21 | func NewNamespacedNameFrom(key types.NamespacedName, f func(name string) string) types.NamespacedName { 22 | return types.NamespacedName{ 23 | Namespace: key.Namespace, 24 | Name: f(key.Name), 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /pkg/k8s/helper/object.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package helper 18 | 19 | import ( 20 | "errors" 21 | 22 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 23 | ) 24 | 25 | func CheckControllerReference(obj, owner metav1.Object) error { 26 | ref := metav1.GetControllerOfNoCopy(obj) 27 | if ref == nil { 28 | return errors.New("no owner found for " + obj.GetNamespace() + "/" + obj.GetName()) 29 | } 30 | if ref.UID == owner.GetUID() { 31 | return nil 32 | } 33 | return errors.New(string("unexpected owner reference, expect " + owner.GetUID() + ", found " + ref.UID)) 34 | } 35 | -------------------------------------------------------------------------------- /pkg/k8s/helper/pointer.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package helper 18 | 19 | import ( 20 | corev1 "k8s.io/api/core/v1" 21 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 | ) 23 | 24 | func HostPathTypePtr(t corev1.HostPathType) *corev1.HostPathType { 25 | return &t 26 | } 27 | 28 | func MountPropagationModePtr(m corev1.MountPropagationMode) *corev1.MountPropagationMode { 29 | return &m 30 | } 31 | 32 | func TimePtr(time metav1.Time) *metav1.Time { 33 | return &time 34 | } 35 | -------------------------------------------------------------------------------- /pkg/k8s/helper/remotecommand.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package helper 18 | 19 | import "k8s.io/utils/exec" 20 | 21 | func IsExitError(err error) bool { 22 | _, ok := err.(exec.ExitError) 23 | return ok 24 | } 25 | -------------------------------------------------------------------------------- /pkg/k8s/helper/secret.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package helper 18 | -------------------------------------------------------------------------------- /pkg/k8s/prometheus/TBD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polardb/polardbx-operator/ae33ef90e8c5a36c0c749dc5e492fd6ac23d3ef3/pkg/k8s/prometheus/TBD -------------------------------------------------------------------------------- /pkg/meta/core/gms/security/hash_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package security 18 | 19 | import ( 20 | "testing" 21 | 22 | "github.com/onsi/gomega" 23 | ) 24 | 25 | func TestSha1Hash(t *testing.T) { 26 | g := gomega.NewGomegaWithT(t) 27 | hash, err := Sha1Hash("84r7xlzc22nj") 28 | g.Expect(err).To(gomega.BeNil()) 29 | g.Expect(hash).To(gomega.Equal("1abc69f0c63fe079080ee6f8246f14f50a694568")) 30 | } 31 | -------------------------------------------------------------------------------- /pkg/operator/v1/polardbx/factory/deployment_test.go: -------------------------------------------------------------------------------- 1 | package factory 2 | 3 | import ( 4 | "fmt" 5 | "github.com/onsi/gomega" 6 | "testing" 7 | ) 8 | 9 | func TestSplitMatchRules(t *testing.T) { 10 | g := gomega.NewGomegaWithT(t) 11 | matchingRulesMap := map[string]matchingRule{ 12 | "rule1": { 13 | replicas: 1, 14 | }, 15 | "rule2": { 16 | replicas: 2, 17 | }, 18 | "rule3": { 19 | replicas: 3, 20 | }, 21 | } 22 | resultMatchRules := SplitMatchRules(matchingRulesMap, 3, 3) 23 | fmt.Println(resultMatchRules) 24 | g.Expect(len(resultMatchRules), 2) 25 | } 26 | -------------------------------------------------------------------------------- /pkg/operator/v1/polardbx/meta/finalizer.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package meta 18 | 19 | const Finalizer = "polardbx/finalizer" 20 | -------------------------------------------------------------------------------- /pkg/operator/v1/systemtask/common/base_reconciler.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "github.com/go-logr/logr" 5 | "sigs.k8s.io/controller-runtime/pkg/reconcile" 6 | ) 7 | 8 | type Reconciler interface { 9 | Reconcile(rc *Context, log logr.Logger, request reconcile.Request) (reconcile.Result, error) 10 | } 11 | -------------------------------------------------------------------------------- /pkg/operator/v1/systemtask/common/common.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import "github.com/alibaba/polardbx-operator/api/v1/systemtask" 4 | 5 | // reconciler name 6 | 7 | var ( 8 | registeredMap = make(map[systemtask.Type]Reconciler, 0) 9 | ) 10 | 11 | func Register(taskType systemtask.Type, reconciler Reconciler) { 12 | registeredMap[taskType] = reconciler 13 | } 14 | 15 | func MusterFindReconciler(taskType systemtask.Type) Reconciler { 16 | reconciler, ok := registeredMap[taskType] 17 | if !ok { 18 | panic("Failed to find system task reconciler, task type : " + taskType) 19 | } 20 | return reconciler 21 | } 22 | -------------------------------------------------------------------------------- /pkg/operator/v1/systemtask/common/label.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | const ( 4 | LabelBalanceResource = "systemtask/balance-resource" 5 | ) 6 | -------------------------------------------------------------------------------- /pkg/operator/v1/xstore/change/driver/exec/replace_executor.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package exec 18 | 19 | import ( 20 | "sigs.k8s.io/controller-runtime/pkg/reconcile" 21 | 22 | "github.com/alibaba/polardbx-operator/pkg/k8s/control" 23 | xstorev1reconcile "github.com/alibaba/polardbx-operator/pkg/operator/v1/xstore/reconcile" 24 | ) 25 | 26 | type ReplaceExec struct { 27 | baseExec 28 | } 29 | 30 | func (exec *ReplaceExec) Execute(rc *xstorev1reconcile.Context, flow control.Flow) (reconcile.Result, error) { 31 | // TODO implement me 32 | panic("implement me") 33 | } 34 | -------------------------------------------------------------------------------- /pkg/operator/v1/xstore/change/driver/exec/snapshot_executor.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package exec 18 | 19 | import ( 20 | "sigs.k8s.io/controller-runtime/pkg/reconcile" 21 | 22 | "github.com/alibaba/polardbx-operator/pkg/k8s/control" 23 | xstorev1reconcile "github.com/alibaba/polardbx-operator/pkg/operator/v1/xstore/reconcile" 24 | ) 25 | 26 | type SnapshotExec struct { 27 | baseExec 28 | } 29 | 30 | func (exec *SnapshotExec) Execute(rc *xstorev1reconcile.Context, flow control.Flow) (reconcile.Result, error) { 31 | // TODO implement me 32 | panic("implement me") 33 | } 34 | -------------------------------------------------------------------------------- /pkg/operator/v1/xstore/change/driver/util/utils.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package util 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/api/equality" 21 | 22 | polardbxv1xstore "github.com/alibaba/polardbx-operator/api/v1/xstore" 23 | ) 24 | 25 | func AreNodeSetsEqualInPodTemplate(a, b *polardbxv1xstore.NodeTemplate) bool { 26 | return equality.Semantic.DeepEqual(a, b) 27 | } 28 | -------------------------------------------------------------------------------- /pkg/operator/v1/xstore/meta/consensus.go: -------------------------------------------------------------------------------- 1 | package meta 2 | 3 | const HandleIndicateResetClusterInfo = "reset-cluster-info" 4 | -------------------------------------------------------------------------------- /pkg/operator/v1/xstore/meta/finalizer.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package meta 18 | 19 | const Finalizer = "xstore/finalizer" 20 | -------------------------------------------------------------------------------- /pkg/operator/v1/xstore/meta/job_labels.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package meta 18 | 19 | const ( 20 | XStoreJobDomain = "xstore-job" 21 | JobLabelTargetPod = XStoreJobDomain + "/target-pod" 22 | JobLabelTargetNodeName = XStoreJobDomain + "/target-node" 23 | ) 24 | -------------------------------------------------------------------------------- /pkg/operator/v1/xstore/meta/rebuild_config.go: -------------------------------------------------------------------------------- 1 | package meta 2 | 3 | import "github.com/alibaba/polardbx-operator/pkg/meta/core/gms/security" 4 | 5 | type RebuildConfig struct { 6 | LogSeparation string 7 | NodeName string 8 | RpcProtocolVersion string 9 | } 10 | 11 | func (r *RebuildConfig) ComputeHash() string { 12 | objHash, err := security.HashObj(r) 13 | if err != nil { 14 | panic(err) 15 | } 16 | return objHash 17 | } 18 | -------------------------------------------------------------------------------- /pkg/operator/v1/xstore/plugin/adaptor.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package plugin 18 | 19 | import ( 20 | "github.com/alibaba/polardbx-operator/pkg/k8s/control" 21 | xstorev1reconcile "github.com/alibaba/polardbx-operator/pkg/operator/v1/xstore/reconcile" 22 | ) 23 | 24 | func NewStepBinder(engine string, name string, f xstorev1reconcile.StepFunc) control.BindFunc { 25 | return xstorev1reconcile.NewStepBinder(engine+"."+name, f) 26 | } 27 | -------------------------------------------------------------------------------- /pkg/operator/v1/xstore/plugin/backupbinlog_reconciler.go: -------------------------------------------------------------------------------- 1 | package plugin 2 | 3 | import ( 4 | "github.com/alibaba/polardbx-operator/pkg/operator/v1/xstore/reconcile" 5 | "sync" 6 | ) 7 | 8 | var ( 9 | xstoreBackupBinlogReconcilerMap = map[string]reconcile.BackupBinlogReconciler{} 10 | xstoreBackupBinlogReconcilerMu sync.RWMutex 11 | ) 12 | 13 | func RegisterXStoreBackupBinlogReconciler(engine string, reconciler reconcile.BackupBinlogReconciler) { 14 | xstoreBackupBinlogReconcilerMu.Lock() 15 | defer xstoreBackupBinlogReconcilerMu.Unlock() 16 | 17 | _, ok := xstoreBackupBinlogReconcilerMap[engine] 18 | if ok { 19 | panic("duplicate engine: " + engine) 20 | } 21 | xstoreBackupBinlogReconcilerMap[engine] = reconciler 22 | } 23 | 24 | func GetXStoreBackupBinlogReconciler(engine string) reconcile.BackupBinlogReconciler { 25 | xstoreBackupBinlogReconcilerMu.RLock() 26 | defer xstoreBackupBinlogReconcilerMu.RUnlock() 27 | 28 | return xstoreBackupBinlogReconcilerMap[engine] 29 | } 30 | -------------------------------------------------------------------------------- /pkg/operator/v1/xstore/plugin/engines/plugin.generated.go: -------------------------------------------------------------------------------- 1 | // Auto-generated by generate.sh. DO NOT MODIFY!! 2 | 3 | /* 4 | Copyright 2021 Alibaba Group Holding Limited. 5 | 6 | Licensed under the Apache License, Version 2.0 (the License); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an AS IS BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | */ 18 | 19 | package engines 20 | 21 | // Plugins to provide multiple store backends. 22 | import ( 23 | _ "github.com/alibaba/polardbx-operator/pkg/operator/v1/xstore/plugin/galaxy" 24 | ) 25 | -------------------------------------------------------------------------------- /pkg/operator/v1/xstore/plugin/galaxy/galaxy/engine.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package galaxy 18 | 19 | const Engine = "galaxy" 20 | -------------------------------------------------------------------------------- /pkg/operator/v1/xstore/plugin/generate.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package plugin 18 | 19 | //go:generate bash generate.sh 20 | -------------------------------------------------------------------------------- /pkg/pitr/context.go: -------------------------------------------------------------------------------- 1 | package pitr 2 | 3 | import ( 4 | "github.com/alibaba/polardbx-operator/pkg/binlogtool/binlog" 5 | "github.com/go-logr/logr" 6 | "go.uber.org/atomic" 7 | ) 8 | 9 | type Context struct { 10 | TaskConfig *TaskConfig 11 | Logger logr.Logger 12 | RestoreBinlogs []RestoreBinlog 13 | ConsistentXStoreCount int 14 | CpHeartbeatXid uint64 15 | Borders map[string]binlog.EventOffset 16 | LastErr error 17 | RecoverTxsBytes []byte 18 | Closed atomic.Bool 19 | } 20 | 21 | func (pCtx *Context) NeedConsistentPoint() bool { 22 | return pCtx.ConsistentXStoreCount > 1 23 | } 24 | -------------------------------------------------------------------------------- /pkg/util/bool/ptr.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package bool 18 | 19 | func IsTrue(ptr *bool) bool { 20 | return ptr != nil && *ptr 21 | } 22 | -------------------------------------------------------------------------------- /pkg/util/config/bundle/bundle.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package bundle 18 | 19 | import ( 20 | "errors" 21 | "io" 22 | ) 23 | 24 | var ErrNotFound = errors.New("not found") 25 | 26 | type Bundle interface { 27 | Get(key string) (io.Reader, error) 28 | List() ([]string, error) 29 | ListPaths() ([]string, error) 30 | Path(path string) (Bundle, error) 31 | } 32 | -------------------------------------------------------------------------------- /pkg/util/config/bundle/k8s.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package bundle 18 | 19 | import corev1 "k8s.io/api/core/v1" 20 | 21 | func NewK8sConfigMapBundle(cm *corev1.ConfigMap) Bundle { 22 | kv := make(map[string][]byte) 23 | for k, sv := range cm.Data { 24 | kv[k] = []byte(sv) 25 | } 26 | return NewKvBundle(kv) 27 | } 28 | 29 | func NewK8sSecretBundle(secret *corev1.Secret) Bundle { 30 | kv := make(map[string][]byte) 31 | for k, sv := range secret.Data { 32 | kv[k] = sv 33 | } 34 | return NewKvBundle(kv) 35 | } 36 | -------------------------------------------------------------------------------- /pkg/util/config/bundle/util.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package bundle 18 | 19 | import "io" 20 | 21 | func GetOneFromBundle(b Bundle, keys ...string) (io.Reader, error) { 22 | for _, key := range keys { 23 | r, err := b.Get(key) 24 | if err == nil { 25 | return r, nil 26 | } 27 | if err == ErrNotFound { 28 | continue 29 | } 30 | return nil, err 31 | } 32 | return nil, ErrNotFound 33 | } 34 | -------------------------------------------------------------------------------- /pkg/util/config/loader/file.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package loader 18 | 19 | import ( 20 | "context" 21 | 22 | bundle2 "github.com/alibaba/polardbx-operator/pkg/util/config/bundle" 23 | ) 24 | 25 | type fileSystemLoader struct { 26 | path string 27 | } 28 | 29 | func (l *fileSystemLoader) Load(ctx context.Context) (bundle2.Bundle, error) { 30 | return bundle2.NewFileSystemBundle(l.path), nil 31 | } 32 | 33 | func NewFileSystemLoader(path string) Loader { 34 | return &fileSystemLoader{ 35 | path: path, 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /pkg/util/config/loader/loader.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package loader 18 | 19 | import ( 20 | "context" 21 | 22 | "github.com/alibaba/polardbx-operator/pkg/util/config/bundle" 23 | ) 24 | 25 | type Loader interface { 26 | Load(ctx context.Context) (bundle.Bundle, error) 27 | } 28 | -------------------------------------------------------------------------------- /pkg/util/copy/copy.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package copy 18 | 19 | func CopyStrMap(m map[string]string) map[string]string { 20 | if m == nil { 21 | return nil 22 | } 23 | r := make(map[string]string) 24 | for k, v := range m { 25 | r[k] = v 26 | } 27 | return r 28 | } 29 | -------------------------------------------------------------------------------- /pkg/util/defaults/map.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package defaults 18 | 19 | func GetIntOrDefault(m map[string]int, key string, val int) int { 20 | v, ok := m[key] 21 | if ok { 22 | return v 23 | } 24 | return val 25 | } 26 | -------------------------------------------------------------------------------- /pkg/util/defaults/string.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package defaults 18 | 19 | import "hash/fnv" 20 | 21 | func NonEmptyStrOrDefault(s, defaultVal string) string { 22 | if s == "" { 23 | return defaultVal 24 | } 25 | return s 26 | } 27 | 28 | func NonEmptyStrPtrOrDefault(ptr *string, defaultVal string) string { 29 | if ptr == nil || *ptr == "" { 30 | return defaultVal 31 | } 32 | return *ptr 33 | } 34 | 35 | func FNV64(text string) uint64 { 36 | hashAlgorithm := fnv.New64a() 37 | hashAlgorithm.Write([]byte(text)) 38 | return hashAlgorithm.Sum64() 39 | } 40 | -------------------------------------------------------------------------------- /pkg/util/dict/keys_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package dict 18 | 19 | import ( 20 | "sort" 21 | "testing" 22 | 23 | "github.com/onsi/gomega" 24 | ) 25 | 26 | func TestSortedStringKeys(t *testing.T) { 27 | g := gomega.NewGomegaWithT(t) 28 | 29 | strMap := map[string]string{ 30 | "a": "a", 31 | "b": "b", 32 | "c": "c", 33 | } 34 | 35 | keys := SortedStringKeys(strMap) 36 | g.Expect(len(strMap), len(keys)) 37 | 38 | sort.Strings(keys) 39 | g.Expect([]string{"a", "b", "c"}, keys) 40 | } 41 | -------------------------------------------------------------------------------- /pkg/util/error/error.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package error 18 | 19 | func FirstNonNil(errs ...error) error { 20 | for _, err := range errs { 21 | if err != nil { 22 | return err 23 | } 24 | } 25 | return nil 26 | } 27 | -------------------------------------------------------------------------------- /pkg/util/error/exec.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package error 18 | 19 | import ( 20 | utilexec "k8s.io/utils/exec" 21 | ) 22 | 23 | func ExitError(err error) (utilexec.ExitError, bool) { 24 | e, ok := err.(utilexec.ExitError) 25 | return e, ok 26 | } 27 | -------------------------------------------------------------------------------- /pkg/util/gms/gmsparamlist.go: -------------------------------------------------------------------------------- 1 | package gms 2 | 3 | import polardbxv1 "github.com/alibaba/polardbx-operator/api/v1" 4 | 5 | func GetGmsParamList(parameter *polardbxv1.PolarDBXParameter) []polardbxv1.Params { 6 | gmsParamList := make([]polardbxv1.Params, 0) 7 | if parameter.Spec.NodeType.GMS == nil { 8 | gmsParamList = append(gmsParamList, parameter.Spec.NodeType.DN.ParamList...) 9 | } else { 10 | gmsParamList = append(gmsParamList, parameter.Spec.NodeType.GMS.ParamList...) 11 | } 12 | return gmsParamList 13 | } 14 | -------------------------------------------------------------------------------- /pkg/util/io/copy.go: -------------------------------------------------------------------------------- 1 | package io 2 | 3 | import "io" 4 | 5 | func CopyBufferN(dst io.Writer, src io.Reader, n int64, buffer []byte) (written int64, err error) { 6 | written, err = io.CopyBuffer(dst, io.LimitReader(src, n), buffer) 7 | if written == n { 8 | return n, nil 9 | } 10 | if written < n && err == nil { 11 | // src stopped early; must have been EOF. 12 | err = io.EOF 13 | } 14 | return 15 | } 16 | -------------------------------------------------------------------------------- /pkg/util/io/reader.go: -------------------------------------------------------------------------------- 1 | package io 2 | 3 | import "io" 4 | 5 | func ReadBytes(reader io.Reader, len int, bytes []byte) (int, error) { 6 | readLen := 0 7 | for readLen = 0; readLen < len; { 8 | nowReadLen, err := reader.Read(bytes[readLen:]) 9 | if nowReadLen == 0 { 10 | return readLen, err 11 | } 12 | readLen += nowReadLen 13 | } 14 | return readLen, nil 15 | } 16 | -------------------------------------------------------------------------------- /pkg/util/io/writer.go: -------------------------------------------------------------------------------- 1 | package io 2 | 3 | import ( 4 | "encoding/binary" 5 | "io" 6 | ) 7 | 8 | func WriteUint64(writer io.Writer, data uint64) error { 9 | bytes := make([]byte, 8) 10 | binary.BigEndian.PutUint64(bytes, data) 11 | _, err := writer.Write(bytes) 12 | return err 13 | } 14 | -------------------------------------------------------------------------------- /pkg/util/json/string.go: -------------------------------------------------------------------------------- 1 | package json 2 | 3 | import "encoding/json" 4 | 5 | func Convert2JsonString(obj interface{}) string { 6 | if obj == nil { 7 | return "" 8 | } 9 | bytes, err := json.Marshal(obj) 10 | if err != nil { 11 | return "" 12 | } 13 | return string(bytes) 14 | } 15 | -------------------------------------------------------------------------------- /pkg/util/map/map_test.go: -------------------------------------------------------------------------------- 1 | package _map 2 | 3 | import ( 4 | . "github.com/onsi/gomega" 5 | "testing" 6 | ) 7 | 8 | func TestMergeMapOverwriteFalse1(t *testing.T) { 9 | g := NewGomegaWithT(t) 10 | map1 := map[string]string{ 11 | "m1": "m2", 12 | } 13 | map2 := map[string]string{ 14 | "m2": "m1", 15 | } 16 | result := MergeMap(map1, map2, false).(map[string]string) 17 | g.Expect(result["m1"]).Should(BeEquivalentTo("m2")) 18 | g.Expect(result["m2"]).Should(BeEquivalentTo("m1")) 19 | } 20 | 21 | func TestMergeMapOverwriteFalse2(t *testing.T) { 22 | g := NewGomegaWithT(t) 23 | defer func() { 24 | err := recover() 25 | g.Expect(err).Should(BeEquivalentTo("overwriting key is not allowed")) 26 | }() 27 | map1 := map[string]string{ 28 | "m1": "m2", 29 | } 30 | map2 := map[string]string{ 31 | "m1": "m1", 32 | } 33 | MergeMap(map1, map2, false) 34 | } 35 | 36 | func TestMapOverwriteTrue(t *testing.T) { 37 | g := NewGomegaWithT(t) 38 | defer func() { 39 | err := recover() 40 | g.Expect(err).Should(BeNil()) 41 | }() 42 | map1 := map[string]string{ 43 | "m1": "m2", 44 | } 45 | map2 := map[string]string{ 46 | "m1": "m1", 47 | } 48 | MergeMap(map1, map2, true) 49 | } 50 | -------------------------------------------------------------------------------- /pkg/util/network/tcp.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package network 18 | 19 | import ( 20 | "context" 21 | "fmt" 22 | "net" 23 | ) 24 | 25 | func TestTcpConnectivity(ctx context.Context, host string, port uint16) error { 26 | dialer := net.Dialer{} 27 | conn, err := dialer.DialContext(ctx, "tcp", fmt.Sprintf("%s:%d", host, port)) 28 | if err != nil { 29 | return err 30 | } 31 | defer conn.Close() 32 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /pkg/util/path/path.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package path 18 | 19 | import "strings" 20 | 21 | func NewPathFromStringSequence(sequence ...string) string { 22 | return strings.Join(sequence, "/") 23 | } 24 | 25 | // GetBaseNameFromPath gets last non-empty token in the path 26 | func GetBaseNameFromPath(path string) string { 27 | sequence := strings.Split(path, "/") 28 | for i := len(sequence) - 1; i >= 0; i-- { 29 | if len(sequence[i]) != 0 { 30 | return sequence[i] 31 | } 32 | } 33 | return "" 34 | } 35 | -------------------------------------------------------------------------------- /pkg/util/slice/slice.go: -------------------------------------------------------------------------------- 1 | package slice 2 | 3 | func NotIn[T comparable](element T, candidates ...T) bool { 4 | for _, candidate := range candidates { 5 | if element == candidate { 6 | return false 7 | } 8 | } 9 | return true 10 | } 11 | -------------------------------------------------------------------------------- /pkg/util/tso.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package util 18 | 19 | import "time" 20 | 21 | func GetStartTsoFromTime(t time.Time) int64 { 22 | return (t.Unix() * 1000) << 22 23 | } 24 | -------------------------------------------------------------------------------- /pkg/webhook/parameter/webhook.go: -------------------------------------------------------------------------------- 1 | package parameter 2 | 3 | import ( 4 | "context" 5 | 6 | polardbxv1 "github.com/alibaba/polardbx-operator/api/v1" 7 | "github.com/alibaba/polardbx-operator/pkg/webhook/extension" 8 | "k8s.io/apimachinery/pkg/runtime/schema" 9 | ctrl "sigs.k8s.io/controller-runtime" 10 | ) 11 | 12 | func SetupWebhooks(ctx context.Context, mgr ctrl.Manager, apiPath string) error { 13 | gvk := schema.GroupVersionKind{ 14 | Group: polardbxv1.GroupVersion.Group, 15 | Version: polardbxv1.GroupVersion.Version, 16 | Kind: "PolarDBXParameter", 17 | } 18 | 19 | // Validate. 20 | mgr.GetWebhookServer().Register(extension.GenerateValidatePath(apiPath, gvk), 21 | extension.WithCustomValidator( 22 | &polardbxv1.PolarDBXParameter{}, 23 | NewParameterValidator(mgr.GetAPIReader(), mgr.GetLogger().WithName("webhook.validate.polardbxparameter")), 24 | mgr.GetScheme(), 25 | ), 26 | ) 27 | 28 | return nil 29 | } 30 | -------------------------------------------------------------------------------- /pkg/webhook/polardbxbackup/binlog/webhook.go: -------------------------------------------------------------------------------- 1 | package binlog 2 | 3 | import ( 4 | "context" 5 | polardbxv1 "github.com/alibaba/polardbx-operator/api/v1" 6 | "github.com/alibaba/polardbx-operator/pkg/operator/v1/config" 7 | "github.com/alibaba/polardbx-operator/pkg/webhook/extension" 8 | "github.com/alibaba/polardbx-operator/pkg/webhook/polardbxbackup" 9 | "k8s.io/apimachinery/pkg/runtime/schema" 10 | ctrl "sigs.k8s.io/controller-runtime" 11 | ) 12 | 13 | func SetupWebhooks(ctx context.Context, mgr ctrl.Manager, apiPath string, configLoader func() config.Config) error { 14 | gvk := schema.GroupVersionKind{ 15 | Group: polardbxv1.GroupVersion.Group, 16 | Version: polardbxv1.GroupVersion.Version, 17 | Kind: "PolarDBXBackupBinlog", 18 | } 19 | 20 | mgr.GetWebhookServer().Register(extension.GenerateValidatePath(apiPath, gvk), 21 | extension.WithCustomValidator(&polardbxv1.PolarDBXBackupBinlog{}, 22 | polardbxbackup.NewPolarDBXBackupValidator(mgr.GetAPIReader(), 23 | mgr.GetLogger().WithName("webhook.validate.polardbxbackupbinlog"), 24 | configLoader), mgr.GetScheme())) 25 | return nil 26 | } 27 | -------------------------------------------------------------------------------- /pkg/webhook/polardbxcluster/validator_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package polardbxcluster 18 | 19 | import ( 20 | "testing" 21 | 22 | "k8s.io/apimachinery/pkg/util/intstr" 23 | ) 24 | 25 | func TestIntOrStringSupportedValues(t *testing.T) { 26 | v := intstr.FromString("8") 27 | 28 | switch v.String() { 29 | case "5", "5.7", "8", "8.0": // break 30 | default: 31 | t.Fatal("v is not supported") 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /test/e2e/polardbxcluster/configuration/cn_dynamic.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package configuration 18 | -------------------------------------------------------------------------------- /test/e2e/polardbxcluster/configuration/cn_static.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package configuration 18 | -------------------------------------------------------------------------------- /test/e2e/polardbxcluster/ha/drift.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package ha 18 | -------------------------------------------------------------------------------- /test/e2e/polardbxcluster/ha/host.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package ha 18 | -------------------------------------------------------------------------------- /test/e2e/polardbxcluster/ha/process.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package ha 18 | -------------------------------------------------------------------------------- /test/e2e/polardbxcluster/imports.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package polardbxcluster 18 | 19 | import ( 20 | _ "github.com/alibaba/polardbx-operator/test/e2e/polardbxcluster/configuration" 21 | _ "github.com/alibaba/polardbx-operator/test/e2e/polardbxcluster/lifecycle" 22 | ) 23 | -------------------------------------------------------------------------------- /test/e2e/polardbxcluster/rebalance/scale_in.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package rebalance 18 | -------------------------------------------------------------------------------- /test/e2e/polardbxcluster/rebalance/scale_out.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package rebalance 18 | -------------------------------------------------------------------------------- /test/e2e/polardbxcluster/sql/basic/crud.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package basic 18 | -------------------------------------------------------------------------------- /test/e2e/polardbxcluster/sql/basic/ddl.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package basic 18 | -------------------------------------------------------------------------------- /test/e2e/polardbxcluster/sql/functionality/select_version.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package functionality 18 | -------------------------------------------------------------------------------- /test/e2e/polardbxcluster/sql/performance/sysbench.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package performance 18 | -------------------------------------------------------------------------------- /test/e2e/polardbxcluster/sql/performance/tpcc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package performance 18 | -------------------------------------------------------------------------------- /test/e2e/polardbxcluster/sql/transaction/transfer.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package transaction 18 | -------------------------------------------------------------------------------- /test/e2e/polardbxmonitor/imports.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package polardbxmonitor 18 | 19 | import ( 20 | _ "github.com/alibaba/polardbx-operator/test/e2e/polardbxmonitor/lifecycle" 21 | ) 22 | -------------------------------------------------------------------------------- /test/e2e/xstore/ha/host.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package ha 18 | -------------------------------------------------------------------------------- /test/e2e/xstore/ha/process.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package ha 18 | -------------------------------------------------------------------------------- /test/e2e/xstore/ha/storage.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package ha 18 | -------------------------------------------------------------------------------- /test/e2e/xstore/imports.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package xstore 18 | -------------------------------------------------------------------------------- /test/e2e/xstore/lifecycle/creation.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package lifecycle 18 | -------------------------------------------------------------------------------- /test/e2e/xstore/lifecycle/deletion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package lifecycle 18 | -------------------------------------------------------------------------------- /test/e2e/xstore/lifecycle/maintain.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package lifecycle 18 | -------------------------------------------------------------------------------- /test/framework/common/expect.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package common 18 | 19 | import "github.com/onsi/gomega" 20 | 21 | func ExpectErr(err error, explain ...interface{}) { 22 | gomega.ExpectWithOffset(1, err).To(gomega.HaveOccurred(), explain...) 23 | } 24 | 25 | func ExpectNoError(err error, explain ...interface{}) { 26 | gomega.ExpectWithOffset(1, err).NotTo(gomega.HaveOccurred(), explain...) 27 | } 28 | 29 | func ExpectHaveKeys(m interface{}, keys ...string) { 30 | for _, k := range keys { 31 | gomega.ExpectWithOffset(1, m).To(gomega.HaveKey(k)) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /test/framework/expect.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package framework 18 | 19 | import ( 20 | "github.com/onsi/gomega" 21 | ) 22 | 23 | func ExpectNoError(err error, explain ...interface{}) { 24 | gomega.ExpectWithOffset(1, err).NotTo(gomega.HaveOccurred(), explain...) 25 | } 26 | 27 | func ExpectHaveKeys(m interface{}, keys ...string) { 28 | for _, k := range keys { 29 | gomega.ExpectWithOffset(1, m).To(gomega.HaveKey(k)) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /test/framework/fail.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package framework 18 | 19 | import "github.com/onsi/ginkgo" 20 | 21 | func Fail(message string, callerSkip ...int) { 22 | skip := 1 23 | if len(callerSkip) > 0 { 24 | skip += callerSkip[0] 25 | } 26 | // TODO log something here 27 | ginkgo.Fail(message, skip) 28 | } 29 | -------------------------------------------------------------------------------- /third-party/hsperfdata/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 xin053 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /third-party/hsperfdata/ORIGIN: -------------------------------------------------------------------------------- 1 | https://github.com/xin053/hsperfdata 2 | -------------------------------------------------------------------------------- /third-party/hsperfdata/cmd/cli.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "os" 7 | "sort" 8 | 9 | "github.com/alibaba/polardbx-operator/third-party/hsperfdata" 10 | ) 11 | 12 | func main() { 13 | if len(os.Args) == 1 { 14 | fmt.Printf("Usage: hsstat pid\n") 15 | return 16 | } 17 | 18 | filePath := os.Args[1] 19 | // filePath, err := hsperfdata.PerfDataPath(pid) 20 | // if err != nil { 21 | // log.Fatal(err) 22 | // } 23 | 24 | entryMap, err := hsperfdata.ReadPerfData(filePath, true) 25 | if err != nil { 26 | log.Fatal("open fail", err) 27 | } 28 | 29 | var keys []string 30 | for k := range entryMap { 31 | keys = append(keys, k) 32 | } 33 | 34 | sort.Strings(keys) 35 | 36 | for _, key := range keys { 37 | fmt.Printf("%s=%v\n", key, entryMap[key]) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /third-party/hsperfdata/test-data/13223: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polardb/polardbx-operator/ae33ef90e8c5a36c0c749dc5e492fd6ac23d3ef3/third-party/hsperfdata/test-data/13223 -------------------------------------------------------------------------------- /third-party/hsperfdata/test-data/13984: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polardb/polardbx-operator/ae33ef90e8c5a36c0c749dc5e492fd6ac23d3ef3/third-party/hsperfdata/test-data/13984 -------------------------------------------------------------------------------- /third-party/hsperfdata/test-data/15192: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polardb/polardbx-operator/ae33ef90e8c5a36c0c749dc5e492fd6ac23d3ef3/third-party/hsperfdata/test-data/15192 -------------------------------------------------------------------------------- /third-party/hsperfdata/test-data/2036: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polardb/polardbx-operator/ae33ef90e8c5a36c0c749dc5e492fd6ac23d3ef3/third-party/hsperfdata/test-data/2036 -------------------------------------------------------------------------------- /third-party/hsperfdata/test-data/21916: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polardb/polardbx-operator/ae33ef90e8c5a36c0c749dc5e492fd6ac23d3ef3/third-party/hsperfdata/test-data/21916 -------------------------------------------------------------------------------- /third-party/hsperfdata/test-data/2956: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polardb/polardbx-operator/ae33ef90e8c5a36c0c749dc5e492fd6ac23d3ef3/third-party/hsperfdata/test-data/2956 -------------------------------------------------------------------------------- /tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polardb/polardbx-operator/ae33ef90e8c5a36c0c749dc5e492fd6ac23d3ef3/tools/__init__.py -------------------------------------------------------------------------------- /tools/logstash-filter-polardbx/.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | Gemfile.lock 3 | Gemfile.bak 4 | .bundle 5 | vendor 6 | .idea/ 7 | -------------------------------------------------------------------------------- /tools/logstash-filter-polardbx/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gemspec 4 | 5 | logstash_path = ENV["LOGSTASH_PATH"] || "../../logstash" 6 | use_logstash_source = ENV["LOGSTASH_SOURCE"] && ENV["LOGSTASH_SOURCE"].to_s == "1" 7 | 8 | if Dir.exist?(logstash_path) && use_logstash_source 9 | gem 'logstash-core', :path => "#{logstash_path}/logstash-core" 10 | gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api" 11 | end 12 | -------------------------------------------------------------------------------- /tools/logstash-filter-polardbx/NOTICE.TXT: -------------------------------------------------------------------------------- 1 | PolarDB-X 2 | Copyright 2021 Alibaba Group Holding Limited. 3 | 4 | This product includes software developed by The Apache Software 5 | Foundation (http://www.apache.org/). -------------------------------------------------------------------------------- /tools/logstash-filter-polardbx/Rakefile: -------------------------------------------------------------------------------- 1 | require "logstash/devutils/rake" 2 | -------------------------------------------------------------------------------- /tools/logstash-filter-polardbx/logstash-filter-polardbx.gemspec: -------------------------------------------------------------------------------- 1 | Gem::Specification.new do |s| 2 | s.name = 'logstash-filter-polardbx' 3 | s.version = '1.0.0' 4 | s.licenses = ['Apache-2.0'] 5 | s.summary = "This polardbx log filter is used to parse logs from polardbx database." 6 | s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program" 7 | s.authors = ["Feng Ding"] 8 | s.email = 'dingfengnju@gmail.com' 9 | s.homepage = "https://www.polardbx.com/" 10 | s.require_paths = ["lib"] 11 | 12 | # Files 13 | s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT'] 14 | # Tests 15 | s.test_files = s.files.grep(%r{^(test|spec|features)/}) 16 | 17 | # Special flag to let us know this is actually a logstash plugin 18 | s.metadata = { "logstash_plugin" => "true", "logstash_group" => "filter" } 19 | 20 | # Gem dependencies 21 | s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0" 22 | s.add_development_dependency 'logstash-devutils' 23 | end 24 | -------------------------------------------------------------------------------- /tools/logstash-filter-polardbx/spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | require "logstash/devutils/rspec/spec_helper" 3 | -------------------------------------------------------------------------------- /tools/xstore/.dockerignore: -------------------------------------------------------------------------------- 1 | venv -------------------------------------------------------------------------------- /tools/xstore/cli.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | 4 | # Copyright 2021 Alibaba Group Holding Limited. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | 18 | import cli 19 | 20 | if __name__ == '__main__': 21 | cli.run() 22 | -------------------------------------------------------------------------------- /tools/xstore/cli/root.py: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Alibaba Group Holding Limited. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import click 16 | 17 | 18 | @click.group() 19 | def root_group(): 20 | pass 21 | -------------------------------------------------------------------------------- /tools/xstore/cli/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Alibaba Group Holding Limited. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .timer import * 16 | -------------------------------------------------------------------------------- /tools/xstore/cli/variables.py: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Alibaba Group Holding Limited. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import click 16 | 17 | 18 | @click.group(name='vars') 19 | def variables_group(): 20 | pass 21 | -------------------------------------------------------------------------------- /tools/xstore/core/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Alibaba Group Holding Limited. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from . import config 16 | from . import convention 17 | from .context import * 18 | from .manager import Manager 19 | -------------------------------------------------------------------------------- /tools/xstore/core/backup_restore/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Alibaba Group Holding Limited. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | -------------------------------------------------------------------------------- /tools/xstore/core/backup_restore/storage/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Alibaba Group Holding Limited. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | from .filestream_client import * 15 | -------------------------------------------------------------------------------- /tools/xstore/core/channel/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Alibaba Group Holding Limited. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .channel import * 16 | -------------------------------------------------------------------------------- /tools/xstore/core/consensus/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Alibaba Group Holding Limited. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .manager import * 16 | from .manager_impl import ConsensusManager, LegacyConsensusManager 17 | 18 | 19 | class NotSupportedError(Exception): 20 | """ 21 | Raised when consensus manager not supported. 22 | """ 23 | pass 24 | -------------------------------------------------------------------------------- /tools/xstore/core/context/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Alibaba Group Holding Limited. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .context import * 16 | from .mycnf_renderer import * 17 | -------------------------------------------------------------------------------- /tools/xstore/core/engine/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Alibaba Group Holding Limited. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .dynamic import register_found_supported 16 | from .engine import Engine, Mock 17 | from .store import register_engine_class, new_engine 18 | 19 | register_engine_class('mock', Mock) 20 | register_found_supported() 21 | -------------------------------------------------------------------------------- /tools/xstore/core/engine/galaxy/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Alibaba Group Holding Limited. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .engine import GalaxyEngine, ENGINE_NAME 16 | 17 | ENGINE_CLASS = GalaxyEngine 18 | -------------------------------------------------------------------------------- /tools/xstore/core/engine/util/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polardb/polardbx-operator/ae33ef90e8c5a36c0c749dc5e492fd6ac23d3ef3/tools/xstore/core/engine/util/__init__.py -------------------------------------------------------------------------------- /tools/xstore/core/log/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Alibaba Group Holding Limited. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .logger import * 16 | -------------------------------------------------------------------------------- /tools/xstore/requirements.txt: -------------------------------------------------------------------------------- 1 | click==7.1.2 2 | jsons==1.4.0 3 | PyMySQL==1.0.2 4 | typish==1.9.1 5 | oss2==2.15.0 6 | wget==3.2 7 | mysql-connector-python==8.0.29 --------------------------------------------------------------------------------