Skip to content

Commit

Permalink
Improve --started filter
Browse files Browse the repository at this point in the history
- add example to help
- change behaviour if CMS does not supply the start time info for nodes
  • Loading branch information
Jorres committed Oct 31, 2024
1 parent 6bbc620 commit 877c418
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ ydbops restart --storage \
```

## How to create a new version
### In Github
1. Define new semver version number (e.g. 1.1.0)
2. Update CHANGELOG.md with proper information about new version. Add the following to the beginning of the file, before previous entries:
```
Expand Down
5 changes: 4 additions & 1 deletion pkg/rolling/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,10 @@ after that would be considered a regular cluster failure`)
fmt.Sprintf("How often to query CMS while waiting for new permissions %v", DefaultCMSQueryIntervalSeconds))

fs.StringVar(&startedUnparsedFlag, "started", "",
fmt.Sprintf("Apply filter by node started time. Format: [<>%%Y-%%m-%%dT%%H:%%M:%%SZ], e.g. >2024-03-13T17:20:06Z"))
fmt.Sprintf(`Apply filter by node started time.
Format: "<>%%Y-%%m-%%dT%%H:%%M:%%SZ", quotes are necessary, otherwise shell treats '<' or '>' as stream redirection.
For example, --started ">2024-03-13T17:20:06Z" means all nodes started LATER than 2024 March 13, 17:20:06 UTC.
If you reverse the sign (--started ">2024-03-13T17:20:06Z"), you will select nodes with LARGER uptimes.`))

fs.StringVar(&versionUnparsedFlag, "version", "",
`Apply filter by node version.
Expand Down
16 changes: 16 additions & 0 deletions pkg/rolling/restarters/primitives.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ func SatisfiesStartingTime(node *Ydb_Maintenance.Node, startedTime *options.Star

nodeStartTime := node.GetStartTime().AsTime()

if nodeStartTime.IsZero() {
zap.S().Warnf(
"Node %s did not have startTime specified by CMS (possibly an old YDB version). Avoid using --started filter on current YDB cluster",
node.Host,
)
return false
}

if startedTime.Direction == '<' {
return startedTime.Timestamp.After(nodeStartTime)
}
Expand Down Expand Up @@ -139,6 +147,14 @@ func ExcludeByCommonFields(nodes []*Ydb_Maintenance.Node, spec FilterNodeParams)
}

if spec.Version != nil {
if node.Version == "" {
zap.S().Warnf(
"Node %s did not have version field specified by CMS (possibly an old YDB version). Avoid using --version filter on current YDB cluster",
node.Host,
)
continue
}

satisfiesVersion, err := spec.Version.Satisfies(node.Version)
if err != nil {
unknownVersions[node.Version] = append(unknownVersions[node.Version], node.Host)
Expand Down

0 comments on commit 877c418

Please sign in to comment.