Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ jobs:
go-version: '^1.26'
- run: go version
- run: go install github.com/mattn/goveralls@latest
- run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
- run: mv "$(go env GOPATH)/bin/golangci-lint" "$(go env GOPATH)/bin/golangci-lint-v2"
- run: make check
- run: make test
- run: make build.docker
Expand Down
9 changes: 7 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
version: "2"

run:
concurrency: 4

linters:
disable-all: true
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- unused
exclusions:
rules:
- linters:
- staticcheck
text: "QF1008"
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ GENERATED = pkg/apis/zalando.org/v1/zz_generated.deepcopy.go
GOPKGS = $(shell go list ./... | grep -v /e2e)
BUILD_FLAGS ?= -v
LDFLAGS ?= -X main.version=$(VERSION) -w -s
GOLANGCI_LINT ?= golangci-lint-v2

default: build.local

Expand All @@ -29,7 +30,7 @@ test: $(GENERATED)

check: $(GENERATED)
go mod download
golangci-lint run --timeout=2m ./...
$(GOLANGCI_LINT) run --timeout=2m ./...

$(GENERATED): go.mod $(CRD_TYPE_SOURCE)
./hack/update-codegen.sh
Expand Down
2 changes: 1 addition & 1 deletion cmd/e2e/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ func verifyStack(t *testing.T, stacksetName, currentVersion string, stacksetSpec
require.EqualValues(t, stackResourceLabels, deployment.Labels)
require.EqualValues(
t, replicas(deployment.Spec.Replicas),
replicas(stack.Spec.StackSpec.Replicas),
replicas(stack.Spec.Replicas),
)
require.EqualValues(t, stackResourceLabels, deployment.Spec.Template.Labels)
if stacksetSpec.StackTemplate.Spec.Strategy != nil {
Expand Down
1 change: 0 additions & 1 deletion cmd/stackset-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ func configureKubeConfig(apiServerURL *url.URL, timeout time.Duration, stopCh <-
DialContext: (&net.Dialer{
Timeout: timeout,
KeepAlive: 30 * time.Second,
DualStack: false, // K8s do not work well with IPv6
}).DialContext,
TLSHandshakeTimeout: timeout,
ResponseHeaderTimeout: 10 * time.Second,
Expand Down
22 changes: 15 additions & 7 deletions cmd/traffic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,31 +60,39 @@ func main() {
if err != nil {
log.Fatal(err)
}
printTrafficTable(stacks)
if err := printTrafficTable(stacks); err != nil {
log.Fatal(err)
}
return
}

stacks, err := trafficSwitcher.TrafficWeights(ctx, config.Stackset, config.Namespace)
if err != nil {
log.Fatal(err)
}
printTrafficTable(stacks)
if err := printTrafficTable(stacks); err != nil {
log.Fatal(err)
}
}

func printTrafficTable(stacks []traffic.StackTrafficWeight) {
func printTrafficTable(stacks []traffic.StackTrafficWeight) error {
w := tabwriter.NewWriter(os.Stdout, 8, 8, 4, ' ', 0)
fmt.Fprintf(w, "%s\t%s\t%s\n", "STACK", "DESIRED TRAFFIC", "ACTUAL TRAFFIC")
if _, err := fmt.Fprintf(w, "%s\t%s\t%s\n", "STACK", "DESIRED TRAFFIC", "ACTUAL TRAFFIC"); err != nil {
return err
}

for _, stack := range stacks {
fmt.Fprintf(w,
if _, err := fmt.Fprintf(w,
"%s\t%s\t%s\n",
stack.Name,
fmt.Sprintf("%.1f%%", stack.Weight),
fmt.Sprintf("%.1f%%", stack.ActualWeight),
)
); err != nil {
return err
}
}

w.Flush()
return w.Flush()
}

func newKubeConfig() (*rest.Config, error) {
Expand Down
8 changes: 5 additions & 3 deletions controller/stackset.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ func (c *StackSetController) collectIngresses(ctx context.Context, stacksets map
for _, stackset := range stacksets {
if s, ok := stackset.StackContainers[uid]; ok {
if strings.HasSuffix(
ingress.ObjectMeta.Name,
ingress.Name,
core.SegmentSuffix,
) {
// Traffic Segment
Expand Down Expand Up @@ -378,7 +378,7 @@ func (c *StackSetController) collectRouteGroups(ctx context.Context, stacksets m
for _, stackset := range stacksets {
if s, ok := stackset.StackContainers[uid]; ok {
if strings.HasSuffix(
routegroup.ObjectMeta.Name,
routegroup.Name,
core.SegmentSuffix,
) {
// Traffic Segment
Expand Down Expand Up @@ -584,6 +584,7 @@ func (c *StackSetController) errorEventf(object runtime.Object, reason string, e
object,
v1.EventTypeWarning,
reason,
"%s",
err.Error())
return &eventedError{err: err}
}
Expand Down Expand Up @@ -1113,7 +1114,8 @@ func (c *StackSetController) ReconcileStackSet(ctx context.Context, container *c
container.StackSet,
v1.EventTypeWarning,
"TrafficNotSwitched",
"Failed to switch traffic: "+err.Error())
"Failed to switch traffic: %s",
err.Error())
}

// Mark stacks that should be removed
Expand Down
106 changes: 46 additions & 60 deletions docs/stack_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1998,12 +1998,6 @@ spec:
Must be set if and only if type is "Localhost".
type: string
type:
description: |-
type indicates which kind of AppArmor profile will be applied.
Valid options are:
Localhost - a profile pre-loaded on the node.
RuntimeDefault - the container runtime's default profile.
Unconfined - no AppArmor enforcement.
type: string
required:
- type
Expand Down Expand Up @@ -2039,7 +2033,6 @@ spec:
procMount denotes the type of proc mount to use for the containers.
The default value is Default which uses the container runtime defaults for
readonly paths and masked paths.
This requires the ProcMountType feature flag to be enabled.
Note that this field cannot be set when spec.os.name is windows.
type: string
readOnlyRootFilesystem:
Expand Down Expand Up @@ -3338,19 +3331,8 @@ spec:
Note that this field cannot be set when spec.os.name is windows.
properties:
localhostProfile:
description: |-
localhostProfile indicates a profile loaded on the node that should be used.
The profile must be preconfigured on the node to work.
Must match the loaded name of the profile.
Must be set if and only if type is "Localhost".
type: string
type:
description: |-
type indicates which kind of AppArmor profile will be applied.
Valid options are:
Localhost - a profile pre-loaded on the node.
RuntimeDefault - the container runtime's default profile.
Unconfined - no AppArmor enforcement.
type: string
required:
- type
Expand Down Expand Up @@ -3386,7 +3368,6 @@ spec:
procMount denotes the type of proc mount to use for the containers.
The default value is Default which uses the container runtime defaults for
readonly paths and masked paths.
This requires the ProcMountType feature flag to be enabled.
Note that this field cannot be set when spec.os.name is windows.
type: string
readOnlyRootFilesystem:
Expand Down Expand Up @@ -3836,7 +3817,6 @@ spec:
When set to false, a new userns is created for the pod. Setting false is useful for
mitigating container breakout vulnerabilities even allowing users to run their
containers as root without actually having root privileges on the host.
This field is alpha-level and is only honored by servers that enable the UserNamespacesSupport feature.
type: boolean
hostname:
description: |-
Expand Down Expand Up @@ -4810,7 +4790,6 @@ spec:
procMount denotes the type of proc mount to use for the containers.
The default value is Default which uses the container runtime defaults for
readonly paths and masked paths.
This requires the ProcMountType feature flag to be enabled.
Note that this field cannot be set when spec.os.name is windows.
type: string
readOnlyRootFilesystem:
Expand Down Expand Up @@ -5345,6 +5324,14 @@ spec:

It adds a name to it that uniquely identifies the ResourceClaim inside the Pod.
Containers that need access to the ResourceClaim reference it with this name.

When the DRAWorkloadResourceClaims feature gate is enabled and this Pod
belongs to a PodGroup, a PodResourceClaim is matched to a
PodGroupResourceClaim if all of their fields are equal (Name,
ResourceClaimName, and ResourceClaimTemplateName). A matched claim references
a single ResourceClaim shared across all Pods in the PodGroup, reserved for
the PodGroup in ResourceClaimStatus.ReservedFor rather than for individual
Pods.
properties:
name:
description: |-
Expand All @@ -5370,6 +5357,16 @@ spec:
generated component, will be used to form a unique name for the
ResourceClaim, which will be recorded in pod.status.resourceClaimStatuses.

When the DRAWorkloadResourceClaims feature gate is enabled and the pod
belongs to a PodGroup that defines a PodGroupResourceClaim with the same
Name and ResourceClaimTemplateName, this PodResourceClaim resolves to the
ResourceClaim generated for the PodGroup. All pods in the group that
define an equivalent PodResourceClaim matching the
PodGroupResourceClaim's Name and ResourceClaimTemplateName share the same
generated ResourceClaim. ResourceClaims generated for a PodGroup are
owned by the PodGroup and their lifecycles are tied to the PodGroup
instead of any individual pod.

This field is immutable and no changes will be made to the
corresponding ResourceClaim by the control plane after creating the
ResourceClaim.
Expand Down Expand Up @@ -5495,6 +5492,28 @@ spec:
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
schedulingGroup:
description: |-
SchedulingGroup provides a reference to the immediate scheduling runtime
grouping object that this Pod belongs to.
This field is used by the scheduler to identify the group and apply the
correct group scheduling policies. The association with a group also
impacts other lifecycle aspects of a Pod that are relevant in a wider context
of scheduling like preemption, resource attachment, etc. If not specified,
the Pod is treated as a single unit in all of these aspects.
The group object referenced by this field may not exist at the time the
Pod is created.
This field is immutable, but a group object with the same name may be
recreated with different policies. Doing this during pod scheduling
may result in the placement not conforming to the expected policies.
properties:
podGroupName:
description: |-
PodGroupName specifies the name of the standalone PodGroup object
that represents the runtime instance of this group.
Must be a DNS subdomain.
type: string
type: object
securityContext:
description: |-
SecurityContext holds pod-level security attributes and common container settings.
Expand Down Expand Up @@ -6752,7 +6771,7 @@ spec:
A failure to resolve or pull the image during pod startup will block containers from starting and may add significant latency. Failures will be retried using normal volume backoff and will be reported on the pod reason and message.
The types of objects that may be mounted by this volume are defined by the container runtime implementation on a host machine and at minimum must include all valid types supported by the container image field.
The OCI object gets mounted in a single directory (spec.containers[*].volumeMounts.mountPath) by merging the manifest layers in the same way as for container images.
The volume will be mounted read-only (ro) and non-executable files (noexec).
The volume will be mounted read-only (ro).
Sub path mounts for containers are not supported (spec.containers[*].volumeMounts.subpath) before 1.33.
The field spec.securityContext.fsGroupChangePolicy has no effect on this volume type.
properties:
Expand Down Expand Up @@ -6918,8 +6937,7 @@ spec:
description: |-
portworxVolume represents a portworx volume attached and mounted on kubelets host machine.
Deprecated: PortworxVolume is deprecated. All operations for the in-tree portworxVolume type
are redirected to the pxd.portworx.com CSI driver when the CSIMigrationPortworx feature-gate
is on.
are redirected to the pxd.portworx.com CSI driver.
properties:
fsType:
description: |-
Expand Down Expand Up @@ -7431,42 +7449,6 @@ spec:
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
workloadRef:
description: |-
WorkloadRef provides a reference to the Workload object that this Pod belongs to.
This field is used by the scheduler to identify the PodGroup and apply the
correct group scheduling policies. The Workload object referenced
by this field may not exist at the time the Pod is created.
This field is immutable, but a Workload object with the same name
may be recreated with different policies. Doing this during pod scheduling
may result in the placement not conforming to the expected policies.
properties:
name:
description: |-
Name defines the name of the Workload object this Pod belongs to.
Workload must be in the same namespace as the Pod.
If it doesn't match any existing Workload, the Pod will remain unschedulable
until a Workload object is created and observed by the kube-scheduler.
It must be a DNS subdomain.
type: string
podGroup:
description: |-
PodGroup is the name of the PodGroup within the Workload that this Pod
belongs to. If it doesn't match any existing PodGroup within the Workload,
the Pod will remain unschedulable until the Workload object is recreated
and observed by the kube-scheduler. It must be a DNS label.
type: string
podGroupReplicaKey:
description: |-
PodGroupReplicaKey specifies the replica key of the PodGroup to which this
Pod belongs. It is used to distinguish pods belonging to different replicas
of the same pod group. The pod group policy is applied separately to each replica.
When set, it must be a DNS label.
type: string
required:
- name
- podGroup
type: object
required:
- containers
type: object
Expand Down Expand Up @@ -7497,11 +7479,15 @@ spec:
`random` - backend is chosen at random.
`consistentHash` - backend is chosen by [consistent hashing](https://en.wikipedia.org/wiki/Consistent_hashing) algorithm based on the request key. The request key is derived from `X-Forwarded-For` header or request remote IP address as the fallback. Use [`consistentHashKey`](filters.md#consistenthashkey) filter to set the request key. Use [`consistentHashBalanceFactor`](filters.md#consistenthashbalancefactor) to prevent popular keys from overloading a single backend endpoint.
`powerOfRandomNChoices` - backend is chosen by selecting N random endpoints and picking the one with least outstanding requests from them (see http://www.eecs.harvard.edu/~michaelm/postscripts/handbook2001.pdf).
`weightedRoundRobin` - backend is chosen by smooth weighted round robin with dynamic weights based on the ratio of successful round trips per endpoint, weights are updated by the passive health check when enabled.
`leastRequests` - backend is chosen as the endpoint with the lowest load factor, defined as inflight requests divided by endpoint weight. Ties are broken by smooth weighted round-robin over the tied set proportional to endpoint weights. With equal weights and no inflight requests it behaves like roundRobin.
enum:
- roundRobin
- random
- consistentHash
- powerOfRandomNChoices
- weightedRoundRobin
- leastRequests
type: string
endpoints:
description: Endpoints is required for type `lb`
Expand Down
Loading