forked from kubernetes/autoscaler
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
288 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
cluster-autoscaler/dynamicresources/snapshot_claim_tracker.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
Copyright 2024 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package dynamicresources | ||
|
||
import ( | ||
"fmt" | ||
|
||
resourceapi "k8s.io/api/resource/v1alpha3" | ||
"k8s.io/apimachinery/pkg/types" | ||
) | ||
|
||
type snapshotClaimTracker Snapshot | ||
|
||
func (s snapshotClaimTracker) List() ([]*resourceapi.ResourceClaim, error) { | ||
var result []*resourceapi.ResourceClaim | ||
for _, claim := range s.resourceClaimsByRef { | ||
result = append(result, claim) | ||
} | ||
return result, nil | ||
} | ||
|
||
func (s snapshotClaimTracker) Get(namespace, claimName string) (*resourceapi.ResourceClaim, error) { | ||
claim, found := s.resourceClaimsByRef[resourceClaimRef{Name: claimName, Namespace: namespace}] | ||
if !found { | ||
return nil, fmt.Errorf("claim %s/%s not found", namespace, claimName) | ||
} | ||
return claim, nil | ||
} | ||
|
||
func (s snapshotClaimTracker) ListAllAllocated() ([]*resourceapi.ResourceClaim, error) { | ||
var result []*resourceapi.ResourceClaim | ||
for _, claim := range s.resourceClaimsByRef { | ||
if ClaimAllocated(claim) { | ||
result = append(result, claim) | ||
} | ||
} | ||
return result, nil | ||
} | ||
|
||
func (s snapshotClaimTracker) SignalClaimPendingAllocation(claimUid types.UID, allocatedClaim *resourceapi.ResourceClaim) error { | ||
ref := resourceClaimRef{Name: allocatedClaim.Name, Namespace: allocatedClaim.Namespace} | ||
claim, found := s.resourceClaimsByRef[ref] | ||
if !found { | ||
return fmt.Errorf("claim %s/%s not found", allocatedClaim.Namespace, allocatedClaim.Name) | ||
} | ||
if claim.UID != claimUid { | ||
return fmt.Errorf("claim %s/%s: snapshot has UID %q, allocation came for UID %q - shouldn't happenn", allocatedClaim.Namespace, allocatedClaim.Name, claim.UID, claimUid) | ||
} | ||
s.resourceClaimsByRef[ref] = allocatedClaim | ||
return nil | ||
} | ||
|
||
func (s snapshotClaimTracker) ClaimHasPendingAllocation(claimUid types.UID) bool { | ||
return false | ||
} | ||
|
||
func (s snapshotClaimTracker) RemoveClaimPendingAllocation(claimUid types.UID) (deleted bool) { | ||
//TODO implement me | ||
panic("implement me") | ||
} | ||
|
||
func (s snapshotClaimTracker) AssumeClaimAfterAPICall(claim *resourceapi.ResourceClaim) error { | ||
//TODO implement me | ||
panic("implement me") | ||
} | ||
|
||
func (s snapshotClaimTracker) AssumedClaimRestore(namespace, claimName string) { | ||
//TODO implement me | ||
panic("implement me") | ||
} | ||
|
||
func (s snapshotClaimTracker) GetOriginal(namespace, claimName string) (*resourceapi.ResourceClaim, error) { | ||
//TODO implement me | ||
panic("implement me") | ||
} |
41 changes: 41 additions & 0 deletions
41
cluster-autoscaler/dynamicresources/snapshot_class_lister.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
Copyright 2024 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package dynamicresources | ||
|
||
import ( | ||
"fmt" | ||
|
||
resourceapi "k8s.io/api/resource/v1alpha3" | ||
) | ||
|
||
type snapshotClassLister Snapshot | ||
|
||
func (s snapshotClassLister) List() ([]*resourceapi.DeviceClass, error) { | ||
var result []*resourceapi.DeviceClass | ||
for _, class := range s.deviceClasses { | ||
result = append(result, class) | ||
} | ||
return result, nil | ||
} | ||
|
||
func (s snapshotClassLister) Get(className string) (*resourceapi.DeviceClass, error) { | ||
class, found := s.deviceClasses[className] | ||
if !found { | ||
return nil, fmt.Errorf("DeviceClass %q not found", className) | ||
} | ||
return class, nil | ||
} |
32 changes: 32 additions & 0 deletions
32
cluster-autoscaler/dynamicresources/snapshot_slice_lister.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
Copyright 2024 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package dynamicresources | ||
|
||
import resourceapi "k8s.io/api/resource/v1alpha3" | ||
|
||
type snapshotSliceLister Snapshot | ||
|
||
func (s snapshotSliceLister) List() ([]*resourceapi.ResourceSlice, error) { | ||
var result []*resourceapi.ResourceSlice | ||
for _, slices := range s.resourceSlicesByNodeName { | ||
for _, slice := range slices { | ||
result = append(result, slice) | ||
} | ||
} | ||
result = append(result, s.nonNodeLocalResourceSlices...) | ||
return result, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.