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

refactor(manifest): remove commented code #67

Merged
merged 1 commit into from
Jul 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
177 changes: 0 additions & 177 deletions go/manifest/v2beta2/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,180 +43,3 @@ func (m Manifest) CheckAgainstDeployment(dgroups []dtypes.Group) error {
func (m Manifest) CheckAgainstGSpecs(gspecs dtypes.GroupSpecs) error {
return m.GetGroups().CheckAgainstGSpecs(gspecs)
}

// func (g Group) isMatchingResourceList(rlists dtypes.ResourcesList) error {
// mlist := make([]types.Resources, len(g.Services))
//
// httpOnlyEndpointsCountForDeploymentGroup := 0
// otherEndpointsCountForDeploymentGroup := 0
//
// // for idx, svc := range mgroup.Services {
// // if !svc.Resources.InGroup(groupResources) {
// // jSvc, _ := json.Marshal(svc.Resources)
// // jGroup, _ := json.Marshal(dgroup.GetResources()[idx].Units)
// // return fmt.Errorf("invalid manifest: mismatch between service and group resources\n\tservice: %s\n\tgroup: %s",
// // string(jSvc), string(jGroup))
// // }
// // }
//
// // Iterate over all deployment groups
//
// deploymentGroupLoop:
// for _, rlist := range rlists {
// for _, endpoint := range rlist.Endpoints {
// switch endpoint.Kind {
// case types.Endpoint_SHARED_HTTP:
// httpOnlyEndpointsCountForDeploymentGroup++
// case types.Endpoint_RANDOM_PORT:
// otherEndpointsCountForDeploymentGroup++
// }
// }
// // Find a matching manifest group
// for idx := range mlist {
// mrec := mlist[idx]
//
// // Check that this manifest group is not yet exhausted
// if mrec.Count == 0 {
// continue
// }
//
// if !drec.Units.CPU.Equal(mrec.Units.CPU) ||
// !drec.Units.GPU.Equal(mrec.Units.GPU) ||
// !drec.Units.Memory.Equal(mrec.Units.Memory) ||
// !drec.Units.Storage.Equal(mrec.Units.Storage) {
// continue
// }
//
// // If the manifest group contains more resources than the deployment group, then
// // fulfill the deployment group entirely
// if mrec.Count >= drec.Count {
// mrec.Count -= drec.Count
// drec.Count = 0
// } else {
// // Partially fulfill the deployment group since the manifest group contains less
// drec.Count -= mrec.Count
// mrec.Count = 0
// }
//
// // Update the value stored in the list
// mlist[idx] = mrec
//
// // If the deployment group is fulfilled then break out and
// // move to the next deployment
// if drec.Count == 0 {
// continue deploymentGroupLoop
// }
// }
// // If this point is reached then the deployment group cannot be fully matched
// // against the given manifest groups
// return fmt.Errorf("%w: underutilized deployment group %q", ErrManifestCrossValidation, dgroup.GetName())
// }
//
// return nil
// }
//
// func validateManifestDeploymentGroup(mgroup Group, dgroup dtypes.ResourcesList) error {
// mlist := make(types.Resources, len(mgroup.GetResources()))
// copy(mlist, mgroup.GetResources())
//
// httpOnlyEndpointsCountForDeploymentGroup := 0
// otherEndpointsCountForDeploymentGroup := 0
//
// groupResources := dgroup.GetResources()
//
// for idx, svc := range mgroup.Services {
// if !svc.Resources.InGroup(groupResources) {
// jSvc, _ := json.Marshal(svc.Resources)
// jGroup, _ := json.Marshal(dgroup.GetResources()[idx].Units)
// return fmt.Errorf("invalid manifest: mismatch between service and group resources\n\tservice: %s\n\tgroup: %s",
// string(jSvc), string(jGroup))
// }
// }
//
// // Iterate over all deployment groups
// deploymentGroupLoop:
// for _, drec := range dgroup.GetResources() {
// for _, endpoint := range drec.Units.Endpoints {
// switch endpoint.Kind {
// case types.Endpoint_SHARED_HTTP:
// httpOnlyEndpointsCountForDeploymentGroup++
// case types.Endpoint_RANDOM_PORT:
// otherEndpointsCountForDeploymentGroup++
// }
// }
// // Find a matching manifest group
// for idx := range mlist {
// mrec := mlist[idx]
//
// // Check that this manifest group is not yet exhausted
// if mrec.Count == 0 {
// continue
// }
//
// if !drec.Units.CPU.Equal(mrec.Units.CPU) ||
// !drec.Units.GPU.Equal(mrec.Units.GPU) ||
// !drec.Units.Memory.Equal(mrec.Units.Memory) ||
// !drec.Units.Storage.Equal(mrec.Units.Storage) {
// continue
// }
//
// // If the manifest group contains more resources than the deployment group, then
// // fulfill the deployment group entirely
// if mrec.Count >= drec.Count {
// mrec.Count -= drec.Count
// drec.Count = 0
// } else {
// // Partially fulfill the deployment group since the manifest group contains less
// drec.Count -= mrec.Count
// mrec.Count = 0
// }
//
// // Update the value stored in the list
// mlist[idx] = mrec
//
// // If the deployment group is fulfilled then break out and
// // move to the next deployment
// if drec.Count == 0 {
// continue deploymentGroupLoop
// }
// }
// // If this point is reached then the deployment group cannot be fully matched
// // against the given manifest groups
// return fmt.Errorf("%w: underutilized deployment group %q", ErrManifestCrossValidation, dgroup.GetName())
// }
//
// // Search for any manifest groups which are not fully satisfied
// for _, mrec := range mlist {
// if mrec.Count > 0 {
// return fmt.Errorf("%w: manifest resources %q is not fully matched with deployment groups",
// ErrManifestCrossValidation, mgroup.GetName())
// }
// }
//
// httpOnlyEndpointCount := 0
// otherEndpointCount := 0
//
// for _, service := range mgroup.Services {
// for _, serviceExpose := range service.Expose {
// if serviceExpose.Global {
// if IsIngress(serviceExpose) {
// httpOnlyEndpointCount++
// } else {
// otherEndpointCount++
// }
// }
// }
// }
//
// if otherEndpointCount != otherEndpointsCountForDeploymentGroup {
// return fmt.Errorf("invalid manifest: mismatch on number of endpoints %d != %d",
// otherEndpointCount, otherEndpointsCountForDeploymentGroup)
// }
//
// if httpOnlyEndpointCount != httpOnlyEndpointsCountForDeploymentGroup {
// return fmt.Errorf("invalid manifest: mismatch on number of HTTP only endpoints %d != %d",
// httpOnlyEndpointCount, httpOnlyEndpointsCountForDeploymentGroup)
// }
//
// return nil
// }