-
Notifications
You must be signed in to change notification settings - Fork 4k
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
1 parent
6c14a3a
commit ea387cd
Showing
18 changed files
with
454 additions
and
81 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
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 loopstart | ||
|
||
// Observer interface is used to store object that needed to be refreshed in each CA loop. | ||
// It returns error and a bool value whether the loop should be skipped. | ||
type Observer interface { | ||
Refresh() | ||
} | ||
|
||
// ObserversList interface is used to store objects that needed to be refreshed in each CA loop. | ||
type ObserversList struct { | ||
observers []Observer | ||
} | ||
|
||
// Refresh refresh observers each CA loop. | ||
func (l *ObserversList) Refresh() { | ||
for _, observer := range l.observers { | ||
observer.Refresh() | ||
} | ||
} | ||
|
||
// NewObserversList return new ObserversList. | ||
func NewObserversList(observers []Observer) *ObserversList { | ||
return &ObserversList{observers} | ||
} |
File renamed without changes.
File renamed without changes.
67 changes: 67 additions & 0 deletions
67
cluster-autoscaler/processors/provreq/provisioning_request_processor.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,67 @@ | ||
/* | ||
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 provreq | ||
|
||
import ( | ||
"k8s.io/autoscaler/cluster-autoscaler/observers/loopstart" | ||
"k8s.io/autoscaler/cluster-autoscaler/provisioningrequest/provreqclient" | ||
"k8s.io/autoscaler/cluster-autoscaler/provisioningrequest/provreqwrapper" | ||
"k8s.io/client-go/rest" | ||
"k8s.io/klog/v2" | ||
) | ||
|
||
// ProvisioningRequestProcessor process ProvisioningRequests in the cluster. | ||
type ProvisioningRequestProcessor interface { | ||
Process([]*provreqwrapper.ProvisioningRequest) | ||
CleanUp() | ||
} | ||
|
||
type provisioningRequestClient interface { | ||
ProvisioningRequests() ([]*provreqwrapper.ProvisioningRequest, error) | ||
ProvisioningRequest(namespace, name string) (*provreqwrapper.ProvisioningRequest, error) | ||
} | ||
|
||
// CombinedProvReqProcessor is responsible for processing ProvisioningRequest for each ProvisioningClass | ||
// every CA loop and updating conditions for expired ProvisioningRequests. | ||
type CombinedProvReqProcessor struct { | ||
client provisioningRequestClient | ||
processors []ProvisioningRequestProcessor | ||
} | ||
|
||
// NewCombinedProvReqProcessor return new CombinedProvReqProcessor. | ||
func NewCombinedProvReqProcessor(kubeConfig *rest.Config, processors []ProvisioningRequestProcessor) (loopstart.Observer, error) { | ||
client, err := provreqclient.NewProvisioningRequestClient(kubeConfig) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &CombinedProvReqProcessor{client: client, processors: processors}, nil | ||
} | ||
|
||
// Refresh iterates over ProvisioningRequests and updates its conditions/state. | ||
func (cp *CombinedProvReqProcessor) Refresh() { | ||
provReqs, err := cp.client.ProvisioningRequests() | ||
if err != nil { | ||
klog.Errorf("Failed to get ProvisioningRequests list, err: %v", err) | ||
return | ||
} | ||
for _, p := range cp.processors { | ||
p.Process(provReqs) | ||
} | ||
} | ||
|
||
// CleanUp cleans up internal state | ||
func (cp *CombinedProvReqProcessor) CleanUp() {} |
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.