-
Notifications
You must be signed in to change notification settings - Fork 79
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
Make Fleet Server components resilient if the indices do not exist #68
Conversation
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
|
There was a problem hiding this 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.
internal/pkg/coordinator/monitor.go
Outdated
@@ -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 |
There was a problem hiding this comment.
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?
internal/pkg/coordinator/monitor.go
Outdated
@@ -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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug log?
internal/pkg/policy/monitor.go
Outdated
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug log?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
internal/pkg/policy/monitor.go
Outdated
if errors.Is(err, es.ErrIndexNotFound) { | ||
err = nil | ||
} else { | ||
err = nil |
There was a problem hiding this comment.
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
?
176daae
to
0824f93
Compare
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