Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

CLI: Update Detector Configurations #233

Merged
merged 7 commits into from
Oct 7, 2020

Conversation

VijayanB
Copy link
Member

Update Detector Configurations

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@VijayanB VijayanB self-assigned this Sep 14, 2020
@VijayanB VijayanB added the feature new feature label Sep 14, 2020
@codecov
Copy link

codecov bot commented Sep 14, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@502c8c5). Click here to learn what that means.
The diff coverage is 87.09%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #233   +/-   ##
=========================================
  Coverage          ?   72.90%           
  Complexity        ?     1331           
=========================================
  Files             ?      149           
  Lines             ?     6194           
  Branches          ?      480           
=========================================
  Hits              ?     4516           
  Misses            ?     1453           
  Partials          ?      225           
Flag Coverage Δ Complexity Δ
#cli 79.27% <87.09%> (?) 0.00 <0.00> (?)
#plugin 72.07% <ø> (?) 1331.00 <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ Complexity Δ
cli/internal/gateway/ad/ad.go 62.26% <73.33%> (ø) 0.00 <0.00> (?)
cli/internal/handler/ad/ad.go 88.39% <80.95%> (ø) 0.00 <0.00> (?)
cli/internal/mapper/ad/ad.go 86.39% <92.00%> (ø) 0.00 <0.00> (?)
cli/internal/controller/ad/ad.go 77.07% <93.75%> (ø) 0.00 <0.00> (?)

@VijayanB VijayanB changed the title Update CLI: Update Detector Configurations Sep 14, 2020
@VijayanB
Copy link
Member Author

VijayanB commented Sep 21, 2020

Update Feature Workflow:

  1. User will download detector configuration using download command. This is already merged.
  2. User will make changes to the downloaded file
  3. User will use update command to pass file name
  4. if detector is updated after user downloaded file, cmd will fail with message please download latest version and merge
  5. if detector is running, it will fail saying that detector is running.
  6. User can either stop detector using stop command or by passing --force cmd will automatically stop the detector and override the existing setting.
  7. if user pass --restart, the detector will also start after successful update.

const (
commandUpdate = "update"
flagForce = "force"
flagRestart = "restart"
Copy link
Contributor

Choose a reason for hiding this comment

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

User can only "restart" a running detector? If current detector hasn't been started, is it possible user only set "restart" as true to start it after update ?
From the description "Will start detector if update is successful", it's better to name the flag as "start".

Copy link
Member Author

Choose a reason for hiding this comment

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

Ack

if !proceed {
return nil
}
err := c.StopDetector(ctx, input.ID)
Copy link
Contributor

Choose a reason for hiding this comment

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

If "force" is false, no need to stop detector.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ack

if latestDetector.LastUpdatedAt > input.LastUpdatedAt {
return fmt.Errorf(
"new version for detector is available. Please fetch latest version and then merge your changes")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Check if detector is running? If detector is running and force is false, we should fail immediately.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ack.
Screen Shot 2020-10-06 at 3 36 47 PM

Add Update detector method to call update rest api.
Create Update Detector Entity as an alias from Create Detector.
Add mapper function to map user input to request
Add controller method to update detecor based on configurations.
Added handler to process user input and call controller method,
later process output from controller for command status.
Create Update command to accept update detector's configuration.
Updated restart to start
Only stop detector if force is true
Copy link
Contributor

@ylwu-amzn ylwu-amzn left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the change!

@VijayanB VijayanB merged commit b97516a into opendistro-for-elasticsearch:master Oct 7, 2020
@VijayanB VijayanB deleted the update branch October 7, 2020 00:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants