Skip to content

Commit 4e86e78

Browse files
committed
Revert Instance changes to original
1 parent b467eb0 commit 4e86e78

5 files changed

Lines changed: 21 additions & 53 deletions

File tree

api/pkg/api/handler/instance.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4585,15 +4585,15 @@ func (dih DeleteInstanceHandler) Handle(c echo.Context) error {
45854585
}
45864586

45874587
// This is for enhanced break-fix flow:
4588-
if apiRequest.HealthIssue != nil {
4588+
if apiRequest.MachineHealthIssue != nil {
45894589
releaseInstanceRequest.Issue = &cwssaws.Issue{
4590-
Category: cwssaws.IssueCategory(model.MachineIssueCategoriesFromAPIToProtobuf[apiRequest.HealthIssue.Category]),
4590+
Category: cwssaws.IssueCategory(model.MachineIssueCategoriesFromAPIToProtobuf[apiRequest.MachineHealthIssue.Category]),
45914591
}
4592-
if apiRequest.HealthIssue.Summary != nil {
4593-
releaseInstanceRequest.Issue.Summary = *apiRequest.HealthIssue.Summary
4592+
if apiRequest.MachineHealthIssue.Summary != nil {
4593+
releaseInstanceRequest.Issue.Summary = *apiRequest.MachineHealthIssue.Summary
45944594
}
4595-
if apiRequest.HealthIssue.Details != nil {
4596-
releaseInstanceRequest.Issue.Details = *apiRequest.HealthIssue.Details
4595+
if apiRequest.MachineHealthIssue.Details != nil {
4596+
releaseInstanceRequest.Issue.Details = *apiRequest.MachineHealthIssue.Details
45974597
}
45984598
}
45994599
// if caller attempt to set IsRepairTenant then it must be a tenant with targetedInstanceCreation capability

api/pkg/api/handler/instance_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8836,15 +8836,15 @@ func TestDeleteInstanceHandler_Handle(t *testing.T) {
88368836
verifyChildSpanner bool
88378837
}{
88388838
{
8839-
name: "test Instance delete API endpoint with HealthIssue passes issue to workflow with success",
8839+
name: "test Instance delete API endpoint with MachineHealthIssue passes issue to workflow with success",
88408840
fields: fields{
88418841
dbSession: dbSession,
88428842
tc: tc,
88438843
scp: scp,
88448844
cfg: cfg,
88458845
},
88468846
args: args{
8847-
reqData: &model.APIInstanceDeleteRequest{HealthIssue: &model.APIHealthIssueReport{
8847+
reqData: &model.APIInstanceDeleteRequest{MachineHealthIssue: &model.APIMachineHealthIssueReport{
88488848
Category: "Hardware", Summary: cdb.GetStrPtr("Some summary"), Details: cdb.GetStrPtr("Some details"),
88498849
}},
88508850
reqInstance: inst1.ID.String(),
@@ -8856,15 +8856,15 @@ func TestDeleteInstanceHandler_Handle(t *testing.T) {
88568856
verifyChildSpanner: true,
88578857
},
88588858
{
8859-
name: "test Instance delete API endpoint failure due to HealthIssue with unspecified category",
8859+
name: "test Instance delete API endpoint failure due to MachineHealthIssue with unspecified category",
88608860
fields: fields{
88618861
dbSession: dbSession,
88628862
tc: tc,
88638863
scp: scp,
88648864
cfg: cfg,
88658865
},
88668866
args: args{
8867-
reqData: &model.APIInstanceDeleteRequest{HealthIssue: &model.APIHealthIssueReport{
8867+
reqData: &model.APIInstanceDeleteRequest{MachineHealthIssue: &model.APIMachineHealthIssueReport{
88688868
Category: "UNSPECIFIED", Summary: cdb.GetStrPtr("Some summary"), Details: cdb.GetStrPtr("Some details"),
88698869
}},
88708870
reqInstance: inst1.ID.String(),

api/pkg/api/handler/machine.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,22 +1480,22 @@ func (umh UpdateMachineHandler) Handle(c echo.Context) error {
14801480

14811481
we, err := stc.ExecuteWorkflow(wfCtx, wfOpts, "ApplyMachineHealthReportOverride", insReq)
14821482
if err != nil {
1483-
logger.Error().Err(err).Msg("failed to start Temporal workflow for online repair health override")
1484-
return cutil.NewAPIErrorResponse(c, http.StatusInternalServerError, fmt.Sprintf("Failed to start online repair workflow on Site: %s", err), nil)
1483+
logger.Error().Err(err).Msg("failed to start Temporal workflow for applying online repair health override")
1484+
return cutil.NewAPIErrorResponse(c, http.StatusInternalServerError, fmt.Sprintf("Failed to start applying online repair health override workflow on Site: %s", err), nil)
14851485
}
14861486
wid := we.GetID()
1487-
logger.Info().Str("Workflow ID", wid).Msg("executed synchronous ApplyMachineHealthReportOverride workflow")
1487+
logger.Info().Str("Workflow ID", wid).Msg("executed synchronous applying online repair health override workflow")
14881488
err = we.Get(wfCtx, nil)
14891489
if err != nil {
14901490
var timeoutErr *tp.TimeoutError
14911491
if errors.As(err, &timeoutErr) || err == context.DeadlineExceeded || wfCtx.Err() != nil || ctx.Err() != nil {
14921492
return common.TerminateWorkflowOnTimeOut(c, logger, stc, wid, err, "Machine", "ApplyMachineHealthReportOverride")
14931493
}
14941494
code, werr := common.UnwrapWorkflowError(err)
1495-
logger.Error().Err(werr).Msg("online repair health override workflow failed")
1496-
return cutil.NewAPIErrorResponse(c, code, fmt.Sprintf("Failed to execute online repair workflow on Site: %s", werr), nil)
1495+
logger.Error().Err(werr).Msg("applying online repair health override workflow failed")
1496+
return cutil.NewAPIErrorResponse(c, code, fmt.Sprintf("Failed to execute applying online repair health override workflow on Site: %s", werr), nil)
14971497
}
1498-
logger.Info().Str("Workflow ID", wid).Msg("completed synchronous ApplyMachineHealthReportOverride workflow")
1498+
logger.Info().Str("Workflow ID", wid).Msg("completed synchronous applying online repair health override workflow")
14991499
} else {
15001500
if inst.Status != cdbm.InstanceStatusRepairing {
15011501
return cutil.NewAPIErrorResponse(c, http.StatusBadRequest, fmt.Sprintf("Instance must be in Repairing state to exit online repair (current state: %s)", inst.Status), nil)
@@ -1590,7 +1590,7 @@ func buildOnlineRepairHealthInsertRequest(machineID string, req *model.APIMachin
15901590
TenantMessage: cdb.GetStrPtr(fmt.Sprintf("TenantReportedIssue: %s", mhi.Summary)),
15911591
Classifications: []string{
15921592
"PreventAllocations",
1593-
"PreventDeletion",
1593+
"PreventInstanceDeletion",
15941594
"SuppressExternalAlerting",
15951595
},
15961596
}

api/pkg/api/model/instance.go

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,6 @@ var (
7575
MachineIssueCategoryNetwork: int32(cwssaws.IssueCategory_NETWORK),
7676
MachineIssueCategoryPerformance: int32(cwssaws.IssueCategory_PERFORMANCE),
7777
MachineIssueCategoryOther: int32(cwssaws.IssueCategory_OTHER),
78-
"HARDWARE": int32(cwssaws.IssueCategory_HARDWARE),
79-
"NETWORK": int32(cwssaws.IssueCategory_NETWORK),
80-
"PERFORMANCE": int32(cwssaws.IssueCategory_PERFORMANCE),
81-
"OTHER": int32(cwssaws.IssueCategory_OTHER),
82-
// Proto IssueCategory has no distinct values for storage/software; treat as OTHER.
83-
"STORAGE": int32(cwssaws.IssueCategory_OTHER),
84-
"SOFTWARE": int32(cwssaws.IssueCategory_OTHER),
85-
}
86-
87-
instanceDeleteHealthIssueCategories = []string{
88-
MachineIssueCategoryHardware, MachineIssueCategoryNetwork, MachineIssueCategoryPerformance, MachineIssueCategoryOther,
89-
"HARDWARE", "NETWORK", "PERFORMANCE", "STORAGE", "SOFTWARE", "OTHER",
9078
}
9179
)
9280

@@ -1508,23 +1496,14 @@ func (idr APIInstanceDeleteRequest) Validate() error {
15081496
err := validation.ValidateStruct(idr.MachineHealthIssue,
15091497
validation.Field(&idr.MachineHealthIssue.Category,
15101498
validation.Required,
1511-
validation.By(func(value any) error {
1512-
s, ok := value.(string)
1513-
if !ok {
1514-
return fmt.Errorf("category must be a string")
1515-
}
1516-
if !slices.Contains(instanceDeleteHealthIssueCategories, s) {
1517-
return fmt.Errorf("category must be one of %v", instanceDeleteHealthIssueCategories)
1518-
}
1519-
return nil
1520-
}),
1499+
validation.In(MachineIssueCategoryHardware, MachineIssueCategoryNetwork, MachineIssueCategoryPerformance, MachineIssueCategoryOther),
15211500
),
15221501
validation.Field(&idr.MachineHealthIssue.Summary,
15231502
validation.Required,
1524-
validation.Length(1, 512).Error(validationErrorStringLength)),
1503+
validation.Length(0, 1024).Error(validationErrorStringLength)),
1504+
// TODO: what are the constrains on Summary and Details? For now limiting to 1024..
15251505
validation.Field(&idr.MachineHealthIssue.Details,
1526-
validation.Required,
1527-
validation.Length(1, 8192).Error(validationErrorStringLength)),
1506+
validation.Length(0, 1024).Error(validationErrorStringLength)),
15281507
)
15291508

15301509
if err != nil {

api/pkg/api/model/instance_test.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2356,17 +2356,6 @@ func TestAPIInstanceDeleteRequest_Validate(t *testing.T) {
23562356
},
23572357
wantErr: true,
23582358
},
2359-
{
2360-
name: "test invalid Instance delete request - required machine health issue details",
2361-
fields: fields{
2362-
MachineHealthIssue: &APIMachineHealthIssueReport{
2363-
Category: "Hardware",
2364-
Summary: cdb.GetStrPtr("Test summary"),
2365-
},
2366-
IsRepairTenant: cdb.GetBoolPtr(true),
2367-
},
2368-
wantErr: true,
2369-
},
23702359
{
23712360
name: "test invalid Instance delete request - invalid category",
23722361
fields: fields{

0 commit comments

Comments
 (0)