74 Commits

Author SHA1 Message Date
Alex Stanfield
b4238b3319 Use Go client for flaky report GitHub API calls (#11523)
## What changed?
- Replace the `gh api` subprocesses used by `flakereport` with a shared
Go HTTP client.
- Rate-limit GitHub API requests to 10 RPS by default; allow an explicit
`--rps` override.
- Stream artifact downloads to temporary files while preserving the
existing 60-second download deadline and artifact worker pool.

## Why?
The report performs a GitHub API request for every artifact. Avoiding a
new `gh` process for each request removes that per-request overhead
without adding a more complex processing pipeline.

## How did you test it?
- [x] added new unit test(s)
- [x] checked the diff for whitespace errors
- [ ] built
- [ ] run locally and tested manually
- [ ] covered by existing tests
- [ ] added new functional test(s)

## Potential risks
The client uses the existing `GH_TOKEN`/`GITHUB_TOKEN` environment
variables, falling back to one `gh auth token` call. Transient API
errors are surfaced to the existing per-artifact error handling rather
than retried.
2026-08-15 14:48:11 -05:00
Stephan Behnke
02075b937b Extract shared JUnit XML handling (#11480)
## What changed?
Extract generic JUnit XML file reading and writing into
`tools/common/junit`.

## Why?

Centralizing format-level JUnit handling.

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Sean Kane <spkane31@gmail.com>
2026-08-13 07:54:21 -07:00
Sean Kane
b9f7c9edad refactor(tools): share Slack utilities (#11319)
## What changed?
* Extracted shared Slack Block Kit message construction, Markdown
rendering, text-limit truncation, and webhook delivery into
`tools/common/slack`.
* Migrated `ci-notify` and `flakereport` to use the shared package while
preserving their report-specific content and ordering.

## Why?
Both tools maintained duplicate Slack payload types and webhook logic.

## How did you test it?
- [x] covered by existing tests
- [x] added new unit test(s)

## Potential risks

Slack block text is now centrally truncated to Slack’s documented
per-block limits. This affects only oversized content and prevents
rejected webhook payloads.
2026-07-28 18:41:18 +00:00
Stephan Behnke
4c3bd8329a Extract reusable GitHub helpers (#11018)
## What changed?

Extract various github helpers into `temporal/tools/common/github`.

No behavioral change expected/intended.

## Why?

Make it easier to re-use github-related code.
2026-07-14 21:19:46 +00:00
Stephan Behnke
d91f3af3e3 Apply testifylint fixes (#10792)
## What changed?

- Applied the server-owned subset of testifylint auto-fixes.
- Exact commands that were run:

```sh
.bin/golangci-lint-v2.9.0 run --allow-parallel-runners --concurrency 4 --fix --enable-only testifylint --build-tags disable_grpc_modules,test_dep --timeout 20m --config=.github/.golangci.yml
make goimports
git diff --check
```

- No manual or AI changes were made; unless commented as such.
- Some fixes caused lint errors; those were reverted again.
- Changes were all reviewed by me.
2026-06-24 07:22:13 -07:00
Stephan Behnke
4a2e88a173 Parallelize integration tests (#9292)
## What changed?

Made integration tests run in parallel.

## Why?

Before: ~8min
[[run](https://github.com/temporalio/temporal/actions/runs/21930252400/job/63333789136#step:7:1)]
🐢
After: ~3m
[[run](https://github.com/temporalio/temporal/actions/runs/22114061618/job/63917852614?pr=9292)]
🐰

## How did you test it?
- [ ] built
- [ ] run locally and tested manually
- [x] covered by existing tests
- [ ] added new unit test(s)
- [ ] added new functional test(s)

## Potential risks

They are not known to be flaky; and anecdotally all passed on the first
run.
2026-02-18 09:13:26 -08:00
Stephan Behnke
5b49acfaf9 go fix (#9337)
## What changed?

Integrate Go 1.26's new `go fix` into workflow.

NOTE that the changes caused our linter to fire; a [separate
commit](1b23f787ae)
addresses those.

## Why?

Ensure Go code is standardized/modernized.

## How did you test it?
- [ ] built
- [ ] run locally and tested manually
- [x] covered by existing tests
- [ ] added new unit test(s)
- [ ] added new functional test(s)
2026-02-18 09:12:19 -08:00
Tim Deeb-Swihart
e13ebf04cc chore: update code to use new log aliases where applicable (#9177)
## What changed?

This updates the server code to use the shorthand log tag constructors
introduced in #9174.

As part of this it _does_ make a breaking change to the `Bool`
constructor: it now takes in the key as a string to be consistent.

The only inconsistent one is now `Error`, but that's used so heavily
that changing it is likely not worth the time.


## Why?

Consistency!

## How did you test it?
Existing tests

## Potential risks
The only risk is that I _have_ introduced a breaking change to the Bool
constructor. I'm happy to undo that if my reviewers desire: my goal is
minimal breaking changes.

I'd prefer none, but I made this change to stir up discussion
2026-02-02 17:58:20 +00:00
Daniel Kim
98e4a9022e fix(schema): check for extension before creating (#7002)
## What changed?
`CREATE EXTENSION` sql query is replaced with a pgsql script that checks
for the existence of the extension programatically.

## Why?
`CREATE EXTENSION` can cause issues in environment where creating
extensions are limited to certain users. (e.g. Azure)

## How did you test it?
I've ran the updated schema setup in both environments where btree_gin
is installed and and not installed.

## Potential risks
Regression in visibility database setup.

## Documentation
Not needed.

## Is hotfix candidate?
No

---------

Co-authored-by: Rodrigo Zhou <rodrigo.zhou@gmail.com>
2025-09-29 13:02:22 -05:00
Alex Shtin
91893f1064 Remove license header from every file (#7689)
## What changed?
<!-- Describe what has changed in this PR -->
Remove license header from every file. Because it is really hard to
follow in this PR here is the summary:
1. License header is removed from all `.go` and `.proto` files
:fireworks::fireworks:🎆.
2. `LICENSE` file in the root directory has only Temporal and Uber
copyrights.
3. 5 other `LICENSE` files added to the packages which have copyrights
different from Temporal and Uber: Datadog, Xargin, "Mat Ryer, Tyler
Bunnell and contributors".
4. `license_file` flag is removed from all code generation tools.
5. `copyright_file` flag is removed from `go:generate mockgen`
directive.
6. All copyright related targets are removed from `Makefile`.
7. Updated Temporal copyright year to 2025 everywhere.

## Why?
<!-- Tell your future self why have you made these changes -->
I double checked with legal department that it is not needed to have
license header in every file. One file per repo is enough. I put all
copyrights to the root `LICENSE` file and removed header from all other
files. Also updated tools and `Makefile`.
2025-05-01 18:50:21 -07:00
Gary Lee
20156eb1ad Fix sql tool error in windows (#7519)
## What changed?
Use `path.Join()` instead of `filepath.Join()`

## Why?
#7454

## How did you test it?
Tested locally

## Potential risks
<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
None

## Documentation
<!-- Have you made sure this change doesn't falsify anything currently
stated in `docs/`? If significant
new behavior is added, have you described that in `docs/`? -->
None

## Is hotfix candidate?
<!-- Is this PR a hotfix candidate or does it require a notification to
be sent to the broader community? (Yes/No) -->
No
2025-04-11 18:51:14 +00:00
Daniel Kim
60d96512f9 Update schema setuptask and updatetask to use path.Join when using embed.FS (#6830)
## What changed?
The setuptask and updatetask uses `path.Join` when `embed.FS` is used as
the file system.

## Why?
When using `filepath.Join` on Windows environment, the forward slashes
are converted to back slashes. However, `embed.FS` always expects the
paths to be composed with forward slashes. This causes the setuptask and
updatetask to fail in Windows environment.

## How did you test it?
Tested locally on a Windows environment.

## Potential risks
Schema setup and update tasks can break.

## Documentation
All good.

## Is hotfix candidate?
No
2024-11-19 18:27:12 -08:00
Jacob Barzee
88f33dd818 add make target for cleaning up imports (#6726)
## What changed?
New make target to lint imports. added to github workflow for linting as
well

## Why?
To prevent import statements from not aligning.

## How did you test it?
Ran the target locally. Also checking the workflow for this PR

## Potential risks
None

## Documentation
N/A

## Is hotfix candidate?
no

---------

Co-authored-by: Stephan Behnke <stephanos@users.noreply.github.com>
2024-10-30 12:00:32 -06:00
Jacob Barzee
0836b0fff0 Import alignment (#6426)
## What changed?
Make import formatting a part of the build, and test validity with
"ensure-no-changes" target

## Why?
So we never discuss import order again (hopefully)

## How did you test it?
its a build change, so the build will test it!

## Potential risks
As long as build works, the only thing I risk is the ire of coworker who
want imports to be different ;)

## Documentation
N/A

## Is hotfix candidate?
No
2024-08-23 14:48:10 -06:00
Chetan Gowda
cf1cd8ae21 Set allowed authenticators in tools and via env variables (#6194)
## What changed?
https://github.com/temporalio/temporal/pull/6155 introduced the config
value `allowedAuthenticators`. This PR updates the
`temporal-cassandra-tool` to use this config value. It also updates
`config_template.yaml` so that the config value can be set in docker
images as well.

## Why?
Cassandra supports several authenticators to verify the login
credentials. Gocql implements a subset of them as [default allowed list
of
authenticators](34fdeebefc/conn.go (L27)).
It allows customization of this list to allow supporting additional
authenticators.
So with this change Temporal can connect to Cassandra clusters that have
authenticators other than the default ones provided by Gocql.

## How did you test it?
Ran `./temporal-cassandra-tool` and verified that it picked up the
values in environment variable `CASSANDRA_ALLOWED_AUTHENTICATORS`.
Couldn't test docker build since it's in a different repo.

## Potential risks
<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->

## Documentation
<!-- Have you made sure this change doesn't falsify anything currently
stated in `docs/`? If significant
new behavior is added, have you described that in `docs/`? -->

## Is hotfix candidate?
No

---------

Co-authored-by: Rob Holland <rob@temporal.io>
2024-06-28 14:19:48 -07:00
Daniel Kim
f57fcba0e5 feat: export setuptask and updatetask (#5985)
## What changed?
Setup and Update schema tasks have been exported.

## Why?
These utilities are useful for setting up the database via code.

## How did you test it?
I've invoked these functions inside a host application.

## Potential risks
No risks. These are utility functions.

## Documentation
Yes.

## Is hotfix candidate?
No.
2024-05-24 18:32:35 +00:00
Roey Berman
e56584aebf Allow empty manifest in schema migration script (#5645)
## What changed?

Add a `manifest.AllowNoCqlFiles` to allow bumping schema version without
any schema changes.

## Why?

Some persistence implementations need to opt-out of applying schema
changes.

## How did you test it?

I added a unit test with partial coverage and traced the errors I got
while trying apply an empty schema upgrade and seems like this should
work ™️ .
2024-04-02 12:57:37 -07:00
Rodrigo Zhou
f6937601ef Remove support for standard visibility (#5387)
## What changed?
<!-- Describe what has changed in this PR -->
Remove support for standard visibility

## Why?
<!-- Tell your future self why have you made these changes -->
Standard visibility is deprecated.

## How did you test it?
<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->

## Potential risks
<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->

## Is hotfix candidate?
<!-- Is this PR a hotfix candidate or does it require a notification to
be sent to the broader community? (Yes/No) -->
2024-02-29 12:05:20 -06:00
Carly de Frondeville
46e90391f4 support embedded schema for cassandra and sql update-schema and setup-schema (#5195)
## What changed?


This change adds a flag to `temporal-sql-tool` and
`temporal-cassandra-tool`'s `update-schema` and `setup-schema` to
specify an embedded schema instead of a path to the schema directory or
schema file.

```
NAME:
   temporal-cassandra-tool update-schema - update cassandra schema to a specific version

USAGE:
   temporal-cassandra-tool update-schema [command options] [arguments...]

OPTIONS:
   --version value, -v value      target version for the schema update, defaults to latest
   --schema-dir value, -d value   path to directory containing versioned schema
   --schema-name value, -s value  name of embedded versioned schema, one of: [cassandra/temporal cassandra/visibility]
```

```
NAME:
   temporal-sql-tool update-schema - update sql schema to a specific version

USAGE:
   temporal-sql-tool update-schema [command options] [arguments...]

OPTIONS:
   --version value, -v value      target version for the schema update, defaults to latest
   --schema-dir value, -d value   path to directory containing versioned schema
   --schema-name value, -s value  name of embedded versioned schema, one of: [mysql/v57/temporal mysql/v57/visibility mysql/v8/temporal mysql/v8/visibility postgresql/v96/temporal postgresql/v96/visibility postgresql/v12/temporal postgresql/v12/visibility]
```


## Why?
We want to embed the db schemas in the `temporal-sql-tool` and
`temporal-cassandra-tool` with `go:embed` so that customers can simply
specify which schema they want using a flag instead of having to copy
the schema files to wherever they're running the db tool and passing the
path to the schema.

https://github.com/temporalio/temporal/issues/2059

## How did you test it?
I wrote a new unit test for reading the embedded file system, and the
existing codepath of the changed functions are all tested by the
existing unit tests. I also updated the unit test for config validation
to reflect the new changes.

I tested this locally with a locally running Postgres. Since the more
complex changes are in `updatetask.go`, which is shared by the sql and
the cassandra tool, I think there is no need to also test with a real
cassandra db. I also built the cassandra command line tool and confirmed
that the flags and validation checks behaved as expected.

## Potential risks
Schema updates could fail. But the changes are pretty contained to the
new `-s` flag which isn't used anywhere in production yet, so the risk
is very low. The code for the `-d` flag remained basically the same.

## Is hotfix candidate?
No
2023-12-05 12:22:06 -08:00
Yimin Chen
274de9870f Make cassandra schema update idempotent (#4761)
<!-- Describe what has changed in this PR -->
**What changed?**
Make cassandra schema update tool idempotent

<!-- Tell your future self why have you made these changes -->
**Why?**
So schema upgrade can be retried on partial failure case.

<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
**How did you test it?**
Tested locally, manually reset the schema_version back to older version
and run the tool. Observed the logging of 'Duplicate update...'

<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
**Potential risks**
No

<!-- Is this PR a hotfix candidate or require that a notification be
sent to the broader community? (Yes/No) -->
**Is hotfix candidate?**
No
2023-08-10 13:47:25 -07:00
Mind.R
d6d7a0b0b7 Add more logging (#4252) 2023-04-28 20:59:09 -07:00
Rodrigo Zhou
3abd50d317 Better SQL query splitter (#3791) 2023-01-24 12:00:58 -08:00
Yu Xia
851c634c6d Rename host tests to functional tests (#3782)
* Rename host tests to functional tests
2023-01-11 11:47:19 -08:00
Štefan Miklošovič
4d56df95e3 add address translation to Cassandra persistence (#3076) 2022-07-31 16:21:34 -07:00
Yimin Chen
04988f6cb9 Add optional --defaultdb flag to sql tool (#2950)
* Add optional --defaultdb flag to sql tool

* Fix unit tests

Co-authored-by: Alex Shtin <alex@shtin.com>
2022-07-13 12:01:22 -07:00
David Reiss
9d632d7af0 Change a bunch of code to use generics (#3078) 2022-07-11 13:00:56 -07:00
Alexander Mays
92c866c5e6 Remove rds iam auth plugin (#3079)
* Revert "Fix auth plugin configuration to match the new SQLAuthPlugin config block (#2844)"

This reverts commit 5acbdd70b1.

* Revert rds-iam-auth - current drivers dont support authentication callbacks

Signed-off-by: Alexander Mays <alex@eastside.io>
2022-07-10 14:31:02 -07:00
Alexander Mays
690ad54276 Add RDS IAM auth plugin for SQL drivers (#2830)
Signed-off-by: Alexander Mays <alex@eastside.io>
Added:
A new environment variable to the CLI: SQL_AUTH_PLUGIN=rds-iam-auth
A new flag arg to the CLI: --sql-auth-plugin rds-iam-auth
2 new docker template variables: authPlugin: {{ default .Env.SQL_AUTH_PLUGIN "" }} and authPlugin: {{ default .Env.SQL_VIS_AUTH_PLUGIN "" }}
A new SQL configuration attribute authPlugin
2022-05-12 16:28:26 -07:00
Alex Shtin
e3e48c95c6 Rename clockpb to clocksbp import alias (#2815) 2022-05-07 10:01:58 -07:00
mastermanu
169d03bcfa Adds flag to temporal-cassandra-tool to disable Initial Host Lookup #2594
Adds optional flag to disable initial host lookup when performing operations via the temporal-cassandra-tool. This is useful for some configurations of Cassandra where not having this flag enabled can significantly increase connection time or cause other issues. Validated that this worked against a test cluster.

Note that the server configuration also exposes this option, so we are just achieving parity between the server configuration and the tool configuration
2022-03-09 12:02:54 -05:00
Jason Roselander
b80a54fa6a Updated schema tool to work with full semantic versions, i.e., MAJOR.MINOR.PATCH (#2417)
* Added UnitTestLogger which sends log messages to the testing.T.Log API.

* Updated schema tool to work with full semantic versions, i.e., MAJOR.MINOR.PATCH

* Responded to PR comments
2022-01-27 16:09:19 -08:00
wxing1292
adf5747f9b Use persistence config consistency for schema version check (#2291)
* Use persistence config consistency for Cassandra schema version checking
* Update CQL schema tools accordingly
2021-12-14 13:42:33 -08:00
Lam Tran
e741533d41 Add testhelper package to create temp file and dir (#2214)
* Add testhelper package to create temp file and dir

* Reorder imports
2021-11-24 13:51:31 -08:00
Michael Nussbaum
d2405acd25 Make SQL CLI tool more idempotent (#2104)
* Make PostgreSQL CLI tool DB create and schema create idempotent
* Don't error if a target schema version is specified and schema is up-to-date
2021-10-28 23:02:56 -07:00
Eng Zer Jun
bdeff26cfe Move from io/ioutil to io and os package (#2062)
* This PR replaces the existing io/ioutil functions with their new definitions in io and os packages.
2021-10-25 17:20:08 -07:00
Alex Shtin
923a45c3fa Remove standard logger dependency (#1951) 2021-09-21 15:47:18 -07:00
Jacob LeGrone
d6c9b4af8a Add custom logger option to schema tool (#1943) 2021-09-20 20:48:11 -07:00
Sergey Bykov
91a6593d22 Rename log.NewDefaultLogger() to log.NewTestLogger() (#1543)
Add log.NewCLILogger() to decouple it from log.NewTestLogger()
2021-05-12 16:04:40 -07:00
wxing1292
4aa0c5141c Add TLS host name override config for Cassandra / SQL tool (#1480)
* Allow overriding host name for TLS host name verification in schema tools
* Disable TLS host name verification when `tls_disable_host_verification` or `tls-disable-host-verification` is set
2021-04-20 15:47:28 -07:00
wxing1292
132c8c72d3 Change CLI default TLS host name verification behavior (#1478)
* Change CLI default TLS host name verification behavior
* CLI TLS default to perform host name verification
* Remove CLI TLS enable host verification flag, `tls_enable_host_verification` and `tls-enable-host-verification`
* Add CLI TLS disable host verification flag `tls_disable_host_verification` and `tls-disable-host-verification`
2021-04-20 12:54:52 -07:00
Alex Shtin
2dd1919a44 Expose logger interface as server extension option (#1371) 2021-03-11 17:56:31 -08:00
Derek Wilson
86fef706ff Remove dryrun option in schema tools (#1300)
* remove dryrun instead of making it "safer"

because it didn't actually show what it would do when the command was run anyway - it would just create a dummy db/keyspace and do a real schema update
2021-02-18 23:21:11 +00:00
wxing1292
c71d197c39 Unify db version check (#1299)
* Add version check method to SQL interface
* Remove tools version check method in favor of functions defined in persistence package
* Refactor tests to not depend on tools package
2021-02-18 10:41:44 -08:00
Alex Shtin
d3bc2a9216 Bugfix: NoopResolver was always used for version compatibility check (#1233) 2021-01-28 07:47:41 -08:00
Alex Shtin
38c51a43be Add force flag to drop command of database tools (#1196) 2021-01-16 13:39:42 -08:00
Derek Wilson
dfb9ba5128 Enable NetworkTopologyStrategy for cassandra (#938)
Add a --datacenter flag to temporal-cassandra-tool on create that will
use NetworkTopologyStrategy for replication with the specified
replication factor.

This is highly useful for clusters with topologies more complex than
either single node or single node per rack with number of racks equal to
replication factor. Any other layout will benefit from this.
2020-11-02 02:20:19 +00:00
wxing1292
d70e7d6b41 Bugfix SQL 1.1 schema change (#907) 2020-10-27 13:56:17 -07:00
wxing1292
ac9f59379c Add PostgreSQL specific tests for CLI (#828) 2020-10-12 17:43:55 -07:00
wxing1292
7370293c0c Change shard ID type from int to int32 (#811)
* Unify the shard ID type to int32
* Remove unused admin Kafka resend command
2020-10-07 23:46:48 -07:00
Vitaly
b63d577e74 Adding mutable metadata and cluster id (#803)
Adding mutable metadata and cluster id
2020-10-07 19:28:22 -07:00