Skip to content

Commit 6113014

Browse files
committed
retry policy update && use incoming license object for checks
1 parent ef99277 commit 6113014

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

x-pack/plugins/security_solution/server/endpoint/lib/policy/license_watch.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
isEndpointPolicyValidForLicense,
2020
unsetPolicyFeaturesAboveLicenseLevel,
2121
} from '../../../../common/license/policy_config';
22+
import { isAtLeast } from '../../../../common/license/license';
2223
import { licenseService } from '../../../lib/license/license';
2324

2425
export class PolicyWatcher {
@@ -66,6 +67,10 @@ export class PolicyWatcher {
6667
}
6768

6869
public async watch(license: ILicense) {
70+
if (isAtLeast(license, 'platinum')) {
71+
return;
72+
}
73+
6974
let page = 1;
7075
let response: {
7176
items: PackagePolicy[];
@@ -86,14 +91,25 @@ export class PolicyWatcher {
8691
);
8792
return;
8893
}
89-
response.items.forEach((policy) => {
94+
response.items.forEach(async (policy) => {
9095
const policyConfig = policy.inputs[0].config?.policy.value;
91-
if (!isEndpointPolicyValidForLicense(policyConfig, licenseService)) {
96+
if (!isEndpointPolicyValidForLicense(policyConfig, license)) {
9297
policy.inputs[0].config!.policy.value = unsetPolicyFeaturesAboveLicenseLevel(
9398
policyConfig,
94-
licenseService
99+
license
95100
);
96-
this.policyService.update(this.soClient, policy.id, policy);
101+
try {
102+
await this.policyService.update(this.soClient, policy.id, policy);
103+
} catch (e) {
104+
// try again for transient issues
105+
try {
106+
await this.policyService.update(this.soClient, policy.id, policy);
107+
} catch (ee) {
108+
this.logger.warn(
109+
`Unable to remove platinum features from policy ${policy.id}: ${ee.message}`
110+
);
111+
}
112+
}
97113
}
98114
});
99115
} while (response.page * response.perPage < response.total);

0 commit comments

Comments
 (0)