Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Fleet Server components resilient if the indices do not exist #68

Merged
merged 2 commits into from
Jan 21, 2021

Conversation

aleksmaus
Copy link
Member

What does this PR do?

The new package based approach installs the indices templates and ILM policies, but doesn't create the indexes. This change allows the fleet server to run if indexes do not exists without exiting with error.

The bootstrapping code is commented out now, expecting the bootstrap to happen from the integration package.
elastic/integrations#544

@aleksmaus aleksmaus added the enhancement New feature or request label Jan 20, 2021
@elasticmachine
Copy link
Collaborator

elasticmachine commented Jan 20, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Pull request #68 updated

    • Start Time: 2021-01-21T15:16:38.757+0000
  • Duration: 4 min 2 sec

  • Commit: 0824f93

Test stats 🧪

Test Results
Failed 0
Passed 48
Skipped 0
Total 48

Copy link
Member

@ruflin ruflin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++ on being able to run if indices not exist and wait for until the indices are fully setup. But I think we should have at least some debug logs that indicate why things are not working yet.

I wonder for the methods if we could most of the time return / exist early and just do nothing or if we have to run all the code in the methods.

@@ -184,7 +185,11 @@ func (m *monitorT) ensureLeadership(ctx context.Context) error {
leaders := map[string]model.PolicyLeader{}
policies, err := dl.QueryLatestPolicies(ctx, m.bulker, dl.WithIndexName(m.policiesIndex))
if err != nil {
return err
if errors.Is(err, es.ErrIndexNotFound) {
err = nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have a debug log here to make it easier to debug issues?

@@ -193,7 +198,11 @@ func (m *monitorT) ensureLeadership(ctx context.Context) error {
}
leaders, err = dl.SearchPolicyLeaders(ctx, m.bulker, ids, dl.WithIndexName(m.leadersIndex))
if err != nil {
return err
if errors.Is(err, es.ErrIndexNotFound) {
err = nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, debug log?

res, err := bulker.Search(ctx, []string{dl.FleetEnrollmentAPIKeys}, raw, bulk.WithRefresh())
if err != nil {
return err
if errors.Is(err, es.ErrIndexNotFound) {
err = nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug log?

Could we directly return nil here or do we need to run the rest of the code below?


if err != nil {
if errors.Is(err, es.ErrIndexNotFound) {
return nil, nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug log?

@@ -125,6 +126,11 @@ LOOP:
func (m *monitorT) process(ctx context.Context) error {
policies, err := m.policyF(ctx, m.bulker, dl.WithIndexName(m.policiesIndex))
if err != nil {
if errors.Is(err, es.ErrIndexNotFound) {
err = nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug log?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also return here immediately? There won't be any policies yet.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't know what I was thinking yesterday. will update.

if errors.Is(err, es.ErrIndexNotFound) {
err = nil
} else {
err = nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be return err?

@aleksmaus aleksmaus merged commit f931091 into elastic:master Jan 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants