Commit Graph

103463 Commits

Author SHA1 Message Date
Pushkar Joglekar
64938ea160 Update debian-iptables to pick CVE fixes
- This image has fixes for CVE-2021-3711, CVE-2021-3712
- This will allow kube-proxy to be built on newer base image
  which has fixes for these CVEs
2021-09-13 11:13:08 -07:00
Shivanshu Raj Shrivastava
4916b6cd74
Migrated pkg/proxy/userspace to structured logging (#104931)
* migrated roundrobin.go

* migrated proxysocket.go

* fixed typo

* code formatting
2021-09-13 10:46:18 -07:00
Kubernetes Prow Robot
9205473702
Merge pull request #100373 from fromanirh/tm-e2e-require-devs
e2e: TM: add option to fail instead of skip
2021-09-13 10:46:07 -07:00
Kubernetes Prow Robot
dcfe8f5d5c
Merge pull request #104853 from kitianFresh/feature/avoid-sharedIndexInformer-run-more-than-once
avoid sharedIndexInformer run more than once, avoid more cache and me…
2021-09-13 06:24:07 -07:00
Kubernetes Prow Robot
170f64d58b
Merge pull request #104725 from NoicFank/master
Improve DeltaFIFO function 'ListKeys'
2021-09-13 05:14:07 -07:00
Francesco Romani
54c7d8fbb1 e2e: TM: add option to fail instead of skip
The Topology Manager e2e tests wants to run on real multi-NUMA system
and want to consume real devices supported by device plugins; SRIOV
devices happen to be the most commonly available of such devices.

CI machines aren't multi NUMA nor expose SRIOV devices, so the biggest portion
of the tests will just skip, and we need to keep it like this until we
figure out how to enable these features.

However, some organizations can and want to run the testsuite on bare metal;
in this case, the current test will skip (not fail) with misconfigured
boxes, and this reports a misleading result. It will be much better to
fail if the test preconditions aren't met.

To satisfy both needs, we add an option, controlled by an environment
variable, to fail (not skip) if the machine on which the test run
doesn't meet the expectations (multi-NUMA, 4+ cores per NUMA cell,
expose SRIOV VFs).
We keep the old behaviour as default to keep being CI friendly.

Signed-off-by: Francesco Romani <fromani@redhat.com>
2021-09-13 13:23:36 +02:00
Dingzhu Lurong
f0ce875528 Improve DeltaFIFO function 'ListKeys'
In function ListKeys, it better to use ‘queue’ instead of 'items' to get all the keys.
2021-09-13 19:05:53 +08:00
Kubernetes Prow Robot
dd2d12f6dc
Merge pull request #96684 from thockin/rest-hooks-use-by-svc
Simplify and de-layer Service REST implementation
2021-09-11 12:40:06 -07:00
Tim Hockin
009aa36c89 Svc REST: Make transaction-accumulating funcs safe
Identified in review, these funcs are now more reslient to future
changes.
2021-09-11 11:30:02 -07:00
Tim Hockin
e594dd4281 Svc REST: Convert FIXME to TODO 2021-09-11 11:30:02 -07:00
Tim Hockin
03d11c53a8 Svc REST: Rename RESTAllocStuff
This was a dumb placeholder name.
2021-09-11 11:30:02 -07:00
Tim Hockin
5847426e5e Svc REST: Use types for safer arg ordering
In all the places we pass (old, new) or (new, old), use wrapper-types to
make sure that we don't flip the order by accident.
2021-09-11 11:30:02 -07:00
Tim Hockin
d5143bca84 Svc REST: Rename GenericREST -> REST
This is consistent with every other registry.  Service is no longer the
oddball.
2021-09-11 11:30:02 -07:00
Tim Hockin
fe6f278ea1 Svc REST: Move isValidAddress to storage.go 2021-09-11 11:30:02 -07:00
Tim Hockin
d7c8557281 Svc REST: Make update/releaseNodePorts methods
More consistent overall.
2021-09-11 11:30:02 -07:00
Tim Hockin
4c9bc5a53c Svc REST: Move alloc code around
This is detrimental to future `blame` but makes it so much morereadable
I convinced myself it was worthwhile.
2021-09-11 11:30:02 -07:00
Tim Hockin
7ce34e311a Svc REST: rename rest.go -> alloc.go 2021-09-11 11:30:02 -07:00
Tim Hockin
1ce9807de0 Svc REST: Make allocHCNP a method: more consistent 2021-09-11 11:30:02 -07:00
Tim Hockin
c94deffa48 Svc REST: rename allocateHealthCheckNodePort 2021-09-11 11:30:02 -07:00
Tim Hockin
6b06b9bfd3 Svc REST: rename healthCheckNodePortUpdate 2021-09-11 11:30:02 -07:00
Tim Hockin
5dfcb905d1 Svc REST: rename handleClusterIPsForUpdatedService 2021-09-11 11:30:02 -07:00
Tim Hockin
9c622230fc Svc REST: rename releaseServiceClusterIPs 2021-09-11 11:30:02 -07:00
Tim Hockin
4fb338b279 Svc REST: rename releaseServiceClusterIP 2021-09-11 11:30:02 -07:00
Tim Hockin
2a98ec667e Svc REST: rename allocServiceClusterIPs 2021-09-11 11:30:02 -07:00
Tim Hockin
b9f1f4712a Svc REST: rename allocServiceClusterIP 2021-09-11 11:30:02 -07:00
Tim Hockin
1b79bbc9f4 Svc REST: rename releaseClusterIPs -> releaseIPs 2021-09-11 11:30:01 -07:00
Tim Hockin
8e330eb611 Svc REST: rename allocClusterIPs -> allocIPs 2021-09-11 11:30:01 -07:00
Tim Hockin
7d9357b181 Svc REST: rename allocUpdateServiceNodePortsNew 2021-09-11 11:30:01 -07:00
Tim Hockin
bb815e6687 Svc REST: rename allocUpdateServiceClusterIPsNew 2021-09-11 11:30:01 -07:00
Tim Hockin
3b971b137c Svc REST: rename allocServiceNodePortsNew 2021-09-11 11:30:01 -07:00
Tim Hockin
f94782b4f5 Svc REST: rename allocServiceClusterIPsNew 2021-09-11 11:30:01 -07:00
Tim Hockin
8f5189a49f Svc REST: Move tests and scaffolding around
No code edits.  Just a little whitespace, adding comments, and
re-ordering functions.
2021-09-11 11:30:01 -07:00
Tim Hockin
017a430dcd Svc REST: Move patchAllocatedValues to storage pkg
All the meaningful callers of it are in that pkg anyway.  Removes 1
FIXME.
2021-09-11 11:30:01 -07:00
Tim Hockin
4ff4160e34 Svc REST: Move normalizeClusterIPs to storage pkg
All the meaningful callers of it are in that pkg anyway.  Removes some
FIXMEs.
2021-09-11 11:30:01 -07:00
Tim Hockin
4718a0f214 DeepCopy() input objects in Service REST test
Since the PR to do this deeper in the stack was declined, we'll do it
ourselves.  This ensures that we don't accidentally mutate the input and
then compare that mutated form to the result (which caused previous test
failures).
2021-09-11 11:30:01 -07:00
Tim Hockin
4ac7c73b2e Svc REST: Remove old rest_test
All the tests have been ported to storage_test.go
2021-09-11 11:30:01 -07:00
Tim Hockin
b6da6c9c0f Svc REST: Add InternalTrafficPolicy tests
Remove older form.
2021-09-11 11:30:01 -07:00
Tim Hockin
c71467def0 Svc REST: Remove overlapping rest_tests
Most are moved to storage_test
2021-09-11 11:30:01 -07:00
Tim Hockin
12ac38f661 Svc REST: Beef up ports test, remove old form 2021-09-11 11:30:01 -07:00
Tim Hockin
652dc8787c Svc REST: Use "prove" helpers in other tests 2021-09-11 11:30:01 -07:00
Tim Hockin
245a654dec Svc REST: Rename service NewGenericREST to NewREST
Just like all the other registries.
2021-09-11 11:30:01 -07:00
Tim Hockin
03e7690cdb Svc REST: Remove old, now unused stubs 2021-09-11 11:30:01 -07:00
Tim Hockin
8e68b587e8 Svc REST: De-layering done! Convert to 1 layer
This is the culmination of all the previous commits which made this last
move less dramatic.  More tests and cleanup commits will follow.

Background, for future archaeologists:

Service has (had) an "outer" and "inner" REST handler.  This is because of how we do IP and port allocations synchronously, but since we don't have API transactions, we need to roll those back in case of a failure.  Both layers use the same `Strategy`, but the outer calls into the inner, which causes a lot of complexity in the code (including an open-coded partial reimplementation of a date-unknown snapshot of the generic REST code) and results in `Prepare` and `Validate` hooks being called twice.

The "normal" REST flow seems to be:

```
mutating webhooks
generic REST store Create {
    cleanup = BeginCreate
    BeforeCreate {
        strategy.PrepareForCreate {
            dropDisabledFields
        }
        strategy.Validate
        strategy.Canonicalize
    }
    createValidation (validating webhooks)
    storage Create
    cleanup
    AfterCreate
    Decorator
}
```

Service (before this series of commits) does:

```
mutating webhooks
svc custom Create {
    BeforeCreate {
        strategy.PrepareForCreate {
            dropDisabledFields
        }
        strategy.Validate
        strategy.Canonicalize
    }
    Allocations
    inner (generic) Create {
        cleanup = BeginCreate
        BeforeCreate {
            strategy.PrepareForCreate {
                dropDisabledFields
            }
            strategy.Validate
            strategy.Canonicalize
        }
        createValidation (validating webhooks)
        storage Create
        cleanup
        AfterCreate
        Decorator
    }
}
```

After this:

```
mutating webhooks
generic REST store Create {
    cleanup = BeginCreate
        Allocations
    BeforeCreate {
        strategy.PrepareForCreate {
            dropDisabledFields
        }
        strategy.Validate
        strategy.Canonicalize
    }
    createValidation (validating webhooks)
    storage Create
    cleanup
    AfterCreate
        Rollback allocations on error
    Decorator
}
```
2021-09-11 11:30:01 -07:00
Tim Hockin
cf4804643a Svc REST: Remove obviously unused args
This is part of the de-layering conclusion and cleanup.

Bridge the old tests into the new REST.  This will all be removed soon.
2021-09-11 11:30:01 -07:00
Tim Hockin
d30ae6a5ab Svc REST: Make ipFamilyPolicy authoritative
Previously we would try to infer the `ipFamilyPolicy` from `clusterIPs`
and/or `ipFamilies`.  That is too tricky.  Now you MUST specify
`ipFamilyPolicy` as one of the dual-stack options in order to get a
dual-stack service.
2021-09-11 11:30:01 -07:00
Tim Hockin
ca8cfdcae9 Svc REST: Fix single<->dual-stack updates
This removes the old rest_tests and adds significantly more coverage.
Maybe too much.  The v4,v6 and v6,v4 tables are identical but for the
order of families.

This exposed that `trimFieldsForDualStackDowngrade` is called too late
to do anything (since we don't run strategy twice any more).  I moved
similar logic to `PatchAllocatedValues` but I hit on some unclarity.

Specifically, consider a PATCH operation.

Assume I have a valid dual-stack service (with 2 IPs, 2 families, and
policy either require or prefer). What fields can I patch, on their own,
to trigger a downgrade to single-stack?

I think patching policy to "single" is pretty clear intent.

But what if I leave policy and only patch `ipFamilies` down to a single
value (without violating the "can't change first family" rule)?

Or what if I patch `clusterIPs` down to a single IP value?

After much discussion, we decided to make a small API change (OK since
we are beta).  When you want a dual-stack Service you MUST specify the
`ipFamilyPolicy`.  Now we can infer less and avoid ambiguity.
2021-09-11 11:30:01 -07:00
Tim Hockin
650f8cfd35 Svc REST: Validate input before IP allocation
This commit started as removing FIXME comments, but in doing so I
realized that the IP allocation process was using unvalidated user
input.  Before de-layering, validation was called twice - once before
init and once after, which the init code depended on.

Fortunately (or not?) we had duplicative checks that caught errors but
with less friendly messages.

This commit calls validation before initializing the rest of the
IP-related fields.

This also re-organizes that code a bit, cleans up error messages and
comments, and adds a test SPECIFICALLY for the errors in those cases.
2021-09-11 11:30:01 -07:00
Tim Hockin
7602260d0a Svc REST: Fix comments to make next commits easier 2021-09-11 11:30:01 -07:00
Tim Hockin
d1b83bad67 Svc REST: Move ResourceLocation() to 'inner' layer
Part of the de-layering effort.

Also move the test.
2021-09-11 11:30:01 -07:00
Tim Hockin
7887c4c8fc Svc REST: allow tests to set cluster IP families 2021-09-11 11:30:01 -07:00