Skip to content

Conversation

@jfsiii
Copy link
Contributor

@jfsiii jfsiii commented Jul 27, 2020

Summary

Broke the changes from b4f4051 out to a separate PR & added a test

getDefaultAgentConfigId errors if there isn't a default config. The config is added by setupIngestManager which was always called during plugin#start but is no longer.

We could add the setup call to the test/suite, but instead I changed AgentConfigService.delete to use ensureDefaultAgentConfig instead of getDefaultAgentConfigId.

ensureDefaultAgentConfig adds one if it's missing. The check in delete is to make sure we don't delete the default config. We can still do that and now we add a config if it wasn't already there (which seems like A Good Thing)

Checklist

Delete any items that are not applicable to this PR.

@jfsiii jfsiii requested a review from a team July 27, 2020 22:40
@botelastic botelastic bot added the Team:Fleet Team label for Observability Data Collection Fleet team label Jul 27, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/ingest-management (Team:Ingest Management)

@jfsiii jfsiii added release_note:skip Skip the PR/issue when compiling release notes v7.10.0 v8.0.0 labels Jul 28, 2020
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

✅ unchanged

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

}

const defaultConfigId = await this.getDefaultAgentConfigId(soClient);
const { id: defaultConfigId } = await this.ensureDefaultAgentConfig(soClient);
Copy link
Member

Choose a reason for hiding this comment

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

Not sure it's the perfect solution, as it's going to eventually create the default config outside of the setup (not sure of the side effect of this)

What do you think of catching 404 of the previous call?

something like

try {
  const defaultConfigId = await this.getDefaultAgentConfigId(soClient);

  if (id === defaultConfigId) {
      throw new Error('The default agent configuration cannot be deleted');	      throw new Error('The default agent configuration cannot be deleted');
    }	    }
} catch (err) {
  // implement real test here :) 
  if (err !== 404) { throw err; }
}

@jfsiii
Copy link
Contributor Author

jfsiii commented Aug 10, 2020

closed by #73212

@jfsiii jfsiii closed this Aug 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v7.10.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants