Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoral2 committed May 28, 2024
2 parents 3f71184 + 6e6f799 commit b73f2f8
Show file tree
Hide file tree
Showing 97 changed files with 912 additions and 685 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.dapper
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GOLANG=golang:1.21.9-alpine3.18
ARG GOLANG=golang:1.22.2-alpine3.18
FROM ${GOLANG}

# Set proxy environment variables
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.local
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GOLANG=golang:1.21.9-alpine3.18
ARG GOLANG=golang:1.22.2-alpine3.18
FROM ${GOLANG} as infra

ARG http_proxy=$http_proxy
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.manifest
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GOLANG=golang:1.21.9-alpine3.18
ARG GOLANG=golang:1.22.2-alpine3.18
FROM ${GOLANG}

COPY --from=plugins/manifest:1.2.3 /bin/* /bin/
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GOLANG=golang:1.21.9-alpine3.18
ARG GOLANG=golang:1.22.2-alpine3.18
FROM ${GOLANG} as test-base

RUN apk -U --no-cache add bash jq
Expand Down
3 changes: 3 additions & 0 deletions channel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ channels:
- name: v1.29
latestRegexp: v1\.29\..*
excludeRegexp: ^[^+]+-
- name: v1.30
latestRegexp: v1\.30\..*
excludeRegexp: ^[^+]+-
github:
owner: k3s-io
repo: k3s
Expand Down
2 changes: 1 addition & 1 deletion cmd/k3s/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/k3s-io/k3s/pkg/untar"
"github.com/k3s-io/k3s/pkg/version"
"github.com/pkg/errors"
"github.com/rancher/wrangler/pkg/resolvehome"
"github.com/rancher/wrangler/v3/pkg/resolvehome"
"github.com/sirupsen/logrus"
"github.com/spf13/pflag"
"github.com/urfave/cli"
Expand Down
2 changes: 1 addition & 1 deletion contrib/util/check-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ flags="
CGROUPS CGROUP_PIDS CGROUP_CPUACCT CGROUP_DEVICE CGROUP_FREEZER CGROUP_SCHED CPUSETS MEMCG
KEYS
VETH BRIDGE BRIDGE_NETFILTER
IP_NF_FILTER IP_NF_TARGET_MASQUERADE
IP_NF_FILTER IP_NF_TARGET_MASQUERADE IP_NF_TARGET_REJECT
NETFILTER_XT_MATCH_ADDRTYPE NETFILTER_XT_MATCH_CONNTRACK NETFILTER_XT_MATCH_IPVS NETFILTER_XT_MATCH_COMMENT NETFILTER_XT_MATCH_MULTIPORT
IP_NF_NAT NF_NAT
POSIX_MQUEUE
Expand Down
21 changes: 21 additions & 0 deletions docs/adrs/gh-branch-strategy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Branching Strategy in Github

Proposal Date: 2024-05-23

## Status

Accepted

## Context

K3s is released at the same cadence as upstream Kubernetes. This requires management of multiple versions at any given point in time. The current branching strategy uses `release-v[MAJOR].[MINOR]`, with the `master` branch corresponding to the highest version released based on [semver](https://semver.org/). Github's Tags are then used to cut releases, which are just point-in-time snapshots of the specified branch at a given point. As there is the potential for bugs and regressions to be on present on any given branch, this branching and release strategy requires a code freeze to QA the branch without new potentially breaking changes going in.

## Decision
All code changes go into the `master` branch. We maintain branches for all current release versions in the format `release-v[MAJOR].[MINOR]`. When changes made in master are necessary in a release, they should be backported directly into the release branches. If ever there are changes required only in the release branches and not in master, such as when bumping the kubernetes version from upstream, those can be made directly into the release branches themselves.

## Consequences

- Allows for constant development, with code freeze only relevant for the release branches.
- This requires maintaining one additional branch than the current workflow, which also means one additional issue.
- Testing would be more constant from the master branch.
- Minor release captain will have to cut the new branch as soon as they bring in that new minor version.
2 changes: 1 addition & 1 deletion docs/contrib/development.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ As described in the [Testing documentation](../../tests/TESTING.md), all the smo

These topics already have been addressed on their respective documents:

- [Git Workflow](./git-workflow.md)
- [Git Workflow](./git_workflow.md)
- [Building](../../BUILDING.md)
- [Testing](../../tests/TESTING.md)

Expand Down
239 changes: 107 additions & 132 deletions go.mod

Large diffs are not rendered by default.

407 changes: 186 additions & 221 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion hack/crdgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

k3scrd "github.com/k3s-io/k3s/pkg/crd"
_ "github.com/k3s-io/k3s/pkg/generated/controllers/k3s.cattle.io/v1"
"github.com/rancher/wrangler/pkg/crd"
"github.com/rancher/wrangler/v3/pkg/crd"
)

func main() {
Expand Down
15 changes: 7 additions & 8 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -474,30 +474,29 @@ installed_hash_matches() {

# Use the GitHub API to identify the artifact associated with a given PR
get_pr_artifact_url() {
GITHUB_API_URL=https://api.github.com/repos/k3s-io/k3s
github_api_url=https://api.github.com/repos/k3s-io/k3s

# Check if jq is installed
if ! [ -x "$(command -v jq)" ]; then
echo "jq is required to use INSTALL_K3S_PR. Please install jq and try again"
exit 1
fatal "Installing PR builds requires jq"
fi

if [ -z "${GITHUB_TOKEN}" ]; then
fatal "Installing PR builds requires GITHUB_TOKEN with k3s-io/k3s repo authorization"
fi

# GET request to the GitHub API to retrieve the latest commit SHA from the pull request
COMMIT_ID=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" "$GITHUB_API_URL/pulls/$INSTALL_K3S_PR" | jq -r '.head.sha')
commit_id=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" "$github_api_url/pulls/$INSTALL_K3S_PR" | jq -r '.head.sha')

# GET request to the GitHub API to retrieve the Build workflow associated with the commit
wf_raw=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" "$GITHUB_API_URL/commits/$COMMIT_ID/check-runs")
wf_raw=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" "$github_api_url/commits/$commit_id/check-runs")
build_workflow=$(printf "%s" "$wf_raw" | jq -r '.check_runs[] | select(.name == "build / Build")')

# Extract the Run ID from the build workflow and lookup artifacts associated with the run
RUN_ID=$(echo "$build_workflow" | jq -r ' .details_url' | awk -F'/' '{print $(NF-2)}')
run_id=$(echo "$build_workflow" | jq -r ' .details_url' | awk -F'/' '{print $(NF-2)}' | sort -rn | head -1)

# Extract the artifat ID for the "k3s" artifact
artifacts=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" "$GITHUB_API_URL/actions/runs/$RUN_ID/artifacts")
# Extract the artifact ID for the "k3s" artifact
artifacts=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" "$github_api_url/actions/runs/$run_id/artifacts")
artifacts_url=$(echo "$artifacts" | jq -r '.artifacts[] | select(.name == "k3s") | .archive_download_url')
GITHUB_PR_URL=$artifacts_url
}
Expand Down
2 changes: 1 addition & 1 deletion install.sh.sha256sum
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3ce239d57d43b2d836d2b561043433e6decae8b9dc41f5d13908c0fafb0340cd install.sh
696c6a93262b3e1f06a78841b8a82c238a8f17755824c024baad652b18bc92bc install.sh
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func main() {
secretsencrypt.RotateKeys,
),
cmds.NewCertCommands(
cert.Check,
cert.Rotate,
cert.RotateCA,
),
Expand Down
36 changes: 5 additions & 31 deletions manifests/local-storage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,39 +115,13 @@ data:
}
setup: |-
#!/bin/sh
while getopts "m:s:p:" opt
do
case $opt in
p)
absolutePath=$OPTARG
;;
s)
sizeInBytes=$OPTARG
;;
m)
volMode=$OPTARG
;;
esac
done
mkdir -m 0777 -p ${absolutePath}
chmod 700 ${absolutePath}/..
set -eu
mkdir -m 0777 -p "${VOL_DIR}"
chmod 700 "${VOL_DIR}/.."
teardown: |-
#!/bin/sh
while getopts "m:s:p:" opt
do
case $opt in
p)
absolutePath=$OPTARG
;;
s)
sizeInBytes=$OPTARG
;;
m)
volMode=$OPTARG
;;
esac
done
rm -rf ${absolutePath}
set -eu
rm -rf "${VOL_DIR}"
helperPod.yaml: |-
apiVersion: v1
kind: Pod
Expand Down
18 changes: 15 additions & 3 deletions pkg/agent/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"github.com/k3s-io/k3s/pkg/vpn"
"github.com/pkg/errors"
"github.com/rancher/wharfie/pkg/registries"
"github.com/rancher/wrangler/pkg/slice"
"github.com/rancher/wrangler/v3/pkg/slice"
"github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/util/json"
"k8s.io/apimachinery/pkg/util/wait"
Expand Down Expand Up @@ -200,7 +200,16 @@ func ensureNodePassword(nodePasswordFile string) (string, error) {
return "", err
}
nodePassword := hex.EncodeToString(password)
return nodePassword, os.WriteFile(nodePasswordFile, []byte(nodePassword+"\n"), 0600)

if err = os.WriteFile(nodePasswordFile, []byte(nodePassword+"\n"), 0600); err != nil {
return nodePassword, err
}

if err = configureACL(nodePassword); err != nil {
return nodePassword, err
}

return nodePassword, nil
}

func upgradeOldNodePasswordPath(oldNodePasswordFile, newNodePasswordFile string) {
Expand Down Expand Up @@ -307,19 +316,22 @@ func isValidResolvConf(resolvConfFile string) bool {

nameserver := regexp.MustCompile(`^nameserver\s+([^\s]*)`)
scanner := bufio.NewScanner(file)
foundNameserver := false
for scanner.Scan() {
ipMatch := nameserver.FindStringSubmatch(scanner.Text())
if len(ipMatch) == 2 {
ip := net.ParseIP(ipMatch[1])
if ip == nil || !ip.IsGlobalUnicast() {
return false
} else {
foundNameserver = true
}
}
}
if err := scanner.Err(); err != nil {
return false
}
return true
return foundNameserver
}

func locateOrGenerateResolvConf(envInfo *cmds.Agent) string {
Expand Down
8 changes: 7 additions & 1 deletion pkg/agent/config/config_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func applyCRIDockerdAddress(nodeConfig *config.Node) {
}

func applyContainerdQoSClassConfigFileIfPresent(envInfo *cmds.Agent, containerdConfig *config.Containerd) {
containerdConfigDir := filepath.Join(envInfo.DataDir, "agent", "etc", "containerd")
containerdConfigDir := filepath.Join(envInfo.DataDir, "agent", "etc", "containerd")

blockioPath := filepath.Join(containerdConfigDir, "blockio_config.yaml")

Expand All @@ -45,3 +45,9 @@ func applyContainerdQoSClassConfigFileIfPresent(envInfo *cmds.Agent, containerdC
}
}
}

// configureACL will configure an Access Control List for the specified file.
// On Linux, this function is a no-op
func configureACL(file string) error {
return nil
}
19 changes: 19 additions & 0 deletions pkg/agent/config/config_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ package config
import (
"path/filepath"

"github.com/k3s-io/k3s/pkg/agent/util/acl"
"github.com/k3s-io/k3s/pkg/cli/cmds"
"github.com/k3s-io/k3s/pkg/daemons/config"
"github.com/pkg/errors"
"golang.org/x/sys/windows"
)

func applyContainerdStateAndAddress(nodeConfig *config.Node) {
Expand All @@ -22,3 +25,19 @@ func applyCRIDockerdAddress(nodeConfig *config.Node) {
func applyContainerdQoSClassConfigFileIfPresent(envInfo *cmds.Agent, containerdConfig *config.Containerd) {
// QoS-class resource management not supported on windows.
}

// configureACL will configure an Access Control List for the specified file,
// ensuring that only the LocalSystem and Administrators Group have access to the file contents
func configureACL(file string) error {
// by default Apply will use the current user (LocalSystem in the case of a Windows service)
// as the owner and current user group as the allowed group
// additionally, we define a DACL to permit access to the file to the local system and all administrators
if err := acl.Apply(file, nil, nil, []windows.EXPLICIT_ACCESS{
acl.GrantSid(windows.GENERIC_ALL, acl.LocalSystemSID()),
acl.GrantSid(windows.GENERIC_ALL, acl.BuiltinAdministratorsSID()),
}...); err != nil {
return errors.Wrapf(err, "failed to configure Access Control List For %s", file)
}

return nil
}
19 changes: 13 additions & 6 deletions pkg/agent/containerd/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1471,14 +1471,25 @@ func Test_UnitGetHostConfigs(t *testing.T) {
t.Fatalf("failed to parse %s: %v\n", registriesFile, err)
}

nodeConfig := &config.Node{
Containerd: config.Containerd{
Registry: tempDir + "/hosts.d",
},
AgentConfig: config.Agent{
ImageServiceSocket: "containerd-stargz-grpc.sock",
Registry: registry.Registry,
Snapshotter: "stargz",
},
}

// set up embedded registry, if enabled for the test
if tt.args.mirrorAddr != "" {
conf := spegel.DefaultRegistry
conf.ServerCAFile = "server-ca"
conf.ClientKeyFile = "client-key"
conf.ClientCertFile = "client-cert"
conf.InternalAddress, conf.RegistryPort, _ = net.SplitHostPort(tt.args.mirrorAddr)
conf.InjectMirror(&config.Node{AgentConfig: config.Agent{Registry: registry.Registry}})
conf.InjectMirror(nodeConfig)
}

// Generate config template struct for all hosts
Expand All @@ -1494,11 +1505,7 @@ func Test_UnitGetHostConfigs(t *testing.T) {

// Confirm that the main containerd config.toml renders properly
containerdConfig := templates.ContainerdConfig{
NodeConfig: &config.Node{
Containerd: config.Containerd{
Registry: tempDir + "/hosts.d",
},
},
NodeConfig: nodeConfig,
PrivateRegistryConfig: registry.Registry,
Program: "k3s",
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/agent/containerd/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/natefinch/lumberjack"
"github.com/pkg/errors"
"github.com/rancher/wharfie/pkg/tarfile"
"github.com/rancher/wrangler/pkg/merr"
"github.com/rancher/wrangler/v3/pkg/merr"
"github.com/sirupsen/logrus"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
)
Expand Down Expand Up @@ -208,7 +208,7 @@ func preloadFile(ctx context.Context, cfg *config.Node, client *containerd.Clien
defer imageReader.Close()

logrus.Infof("Importing images from %s", filePath)
images, err = client.Import(ctx, imageReader, containerd.WithAllPlatforms(true))
images, err = client.Import(ctx, imageReader, containerd.WithAllPlatforms(true), containerd.WithSkipMissing())
if err != nil {
return errors.Wrap(err, "failed to import images from "+filePath)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/agent/cridockerd/cridockerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func getDockerCRIArgs(cfg *config.Node) []string {
argsMap := map[string]string{
"container-runtime-endpoint": cfg.CRIDockerd.Address,
"cri-dockerd-root-directory": cfg.CRIDockerd.Root,
"streaming-bind-addr": "127.0.0.1:10010",
}

if dualNode, _ := utilsnet.IsDualStackIPs(cfg.AgentConfig.NodeIPs); dualNode {
Expand Down
Loading

0 comments on commit b73f2f8

Please sign in to comment.