Skip to content

Commit

Permalink
Add new licence status: expired (elastic#22180)
Browse files Browse the repository at this point in the history
## What does this PR do?

This PR adds a new licence state named `Expired`. Previously, this prevented Beats from connecting to ES.

## Why is it important?

Beats were not able to parse expired licences. This problem prevented users from using the features of the software which does not require a licence.

## Related issues

Closes elastic#21112
  • Loading branch information
kvch authored Oct 27, 2020
1 parent d671e52 commit f0da681
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- The `o365input` and `o365` module now recover from an authentication problem or other fatal errors, instead of terminating. {pull}21259[21258]
- Orderly close processors when processing pipelines are not needed anymore to release their resources. {pull}16349[16349]
- Fix memory leak and events duplication in docker autodiscover and add_docker_metadata. {pull}21851[21851]
- Fix parsing of expired licences. {issue}21112[21112] {pull}22180[22180]

*Auditbeat*

Expand Down
5 changes: 5 additions & 0 deletions x-pack/libbeat/licenser/license.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ func (l *License) IsActive() bool {
return l.Status == Active
}

// IsExpired returns true if the licence has expired.
func (l *License) IsExpired() bool {
return l.Status == Expired
}

// IsTrial returns true if the remote cluster is in trial mode.
func (l *License) IsTrial() bool {
return l.Type == Trial
Expand Down
5 changes: 5 additions & 0 deletions x-pack/libbeat/licenser/license_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ func TestIsActive(t *testing.T) {
l: License{Status: Inactive},
expected: false,
},
{
name: "expired",
l: License{Status: Expired},
expected: false,
},
}

for _, test := range tests {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"build": {
"hash": "053779d",
"date": "2018-07-20T05:25:16.206115Z"
},
"license": {
"uid": "hello-license",
"type": "platinum",
"mode": "platinum",
"status": "expired",
"expiry_date_in_millis": 1588261199999
}
}
2 changes: 2 additions & 0 deletions x-pack/libbeat/licenser/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ type State int
const (
Inactive State = iota
Active
Expired
)

var stateLookup = map[string]State{
"inactive": Inactive,
"active": Active,
"expired": Expired,
}

var licenseLookup = map[string]LicenseType{
Expand Down

0 comments on commit f0da681

Please sign in to comment.