Skip to content

Commit

Permalink
move annotations to cloudprovider package
Browse files Browse the repository at this point in the history
  • Loading branch information
marwanad committed Oct 1, 2021
1 parent 1b26f7f commit 836506e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
10 changes: 10 additions & 0 deletions cluster-autoscaler/cloudprovider/cloud_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,16 @@ func (c InstanceErrorClass) String() string {
}
}

const (
// FakeNodeReasonAnnotation is an annotation added to the fake placeholder nodes CA has created
// Note that this don't map to real nodes in k8s and are merely used for error handling
FakeNodeReasonAnnotation = "k8s.io/cluster-autoscaler/fake-node-reason"
// FakeNodeUnregistered represents a node that is identified by CA as unregistered
FakeNodeUnregistered = "unregistered"
// FakeNodeCreateError represents a node that is identified by CA as a created node with errors
FakeNodeCreateError = "create-error"
)

// PricingModel contains information about the node price and how it changes in time.
type PricingModel interface {
// NodePrice returns a price of running the given node for a given period of time.
Expand Down
14 changes: 3 additions & 11 deletions cluster-autoscaler/clusterstate/clusterstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,6 @@ const (

// NodeGroupBackoffResetTimeout is the time after last failed scale-up when the backoff duration is reset.
NodeGroupBackoffResetTimeout = 3 * time.Hour

// FakeNodeReasonAnnotation is an annotation added to the fake placeholder nodes CA has created
// Note that this don't map to real nodes in k8s and are merely used for error handling
FakeNodeReasonAnnotation = "k8s.io/cluster-autoscaler/fake-node-reason"
// FakeNodeUnregistered represents a node that is identified by CA as unregistered
FakeNodeUnregistered = "unregistered"
// FakeNodeCreateError represents a node that is identified by CA as a created node with errors
FakeNodeCreateError = "create-error"
)

// ScaleUpRequest contains information about the requested node group scale up.
Expand Down Expand Up @@ -952,7 +944,7 @@ func getNotRegisteredNodes(allNodes []*apiv1.Node, cloudProviderNodeInstances ma
for _, instance := range instances {
if !registered.Has(instance.Id) {
notRegistered = append(notRegistered, UnregisteredNode{
Node: fakeNode(instance, FakeNodeUnregistered),
Node: fakeNode(instance, cloudprovider.FakeNodeUnregistered),
UnregisteredSince: time,
})
}
Expand Down Expand Up @@ -1099,7 +1091,7 @@ func (csr *ClusterStateRegistry) GetCreatedNodesWithErrors() []*apiv1.Node {
_, _, instancesByErrorCode := csr.buildInstanceToErrorCodeMappings(nodeGroupInstances)
for _, instances := range instancesByErrorCode {
for _, instance := range instances {
nodesWithCreateErrors = append(nodesWithCreateErrors, fakeNode(instance, FakeNodeCreateError))
nodesWithCreateErrors = append(nodesWithCreateErrors, fakeNode(instance, cloudprovider.FakeNodeCreateError))
}
}
}
Expand All @@ -1121,7 +1113,7 @@ func fakeNode(instance cloudprovider.Instance, reason string) *apiv1.Node {
ObjectMeta: metav1.ObjectMeta{
Name: instance.Id,
Annotations: map[string]string{
FakeNodeReasonAnnotation: reason,
cloudprovider.FakeNodeReasonAnnotation: reason,
},
},
Spec: apiv1.NodeSpec{
Expand Down

0 comments on commit 836506e

Please sign in to comment.