Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
67d079ec
Unverified
Commit
67d079ec
authored
Nov 09, 2021
by
Luther Monson
Committed by
GitHub
Nov 09, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[engine-1.21] updating to new signals package in wrangler (#4434)
* updating to new signals package in wrangler Signed-off-by:
Luther Monson
<
luther.monson@gmail.com
>
parent
14cf9632
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
58 additions
and
27 deletions
+58
-27
Makefile
Makefile
+1
-1
go.mod
go.mod
+1
-1
go.sum
go.sum
+2
-2
containerd.go
pkg/agent/containerd/containerd.go
+1
-1
agent.go
pkg/cli/agent/agent.go
+1
-2
etcd_snapshot.go
pkg/cli/etcdsnapshot/etcd_snapshot.go
+4
-5
server.go
pkg/cli/server/server.go
+1
-1
desiredset_apply.go
...github.com/rancher/wrangler/pkg/apply/desiredset_apply.go
+1
-0
desiredset_compare.go
...thub.com/rancher/wrangler/pkg/apply/desiredset_compare.go
+1
-2
desiredset_process.go
...thub.com/rancher/wrangler/pkg/apply/desiredset_process.go
+12
-2
signal.go
vendor/github.com/rancher/wrangler/pkg/signals/signal.go
+32
-9
modules.txt
vendor/modules.txt
+1
-1
No files found.
Makefile
View file @
67d079ec
...
@@ -2,7 +2,7 @@ TARGETS := $(shell ls scripts | grep -v \\.sh)
...
@@ -2,7 +2,7 @@ TARGETS := $(shell ls scripts | grep -v \\.sh)
.dapper
:
.dapper
:
@
echo
Downloading dapper
@
echo
Downloading dapper
@
curl
-sL
https://releases.rancher.com/dapper/v0.5.
1
/dapper-
$$
(
uname
-s
)
-
$$
(
uname
-m
)
>
.dapper.tmp
@
curl
-sL
https://releases.rancher.com/dapper/v0.5.
7
/dapper-
$$
(
uname
-s
)
-
$$
(
uname
-m
)
>
.dapper.tmp
@
@chmod +x .dapper.tmp
@
@chmod +x .dapper.tmp
@
./.dapper.tmp
-v
@
./.dapper.tmp
-v
@
mv
.dapper.tmp .dapper
@
mv
.dapper.tmp .dapper
...
...
go.mod
View file @
67d079ec
...
@@ -108,7 +108,7 @@ require (
...
@@ -108,7 +108,7 @@ require (
github.com/rancher/lasso v0.0.0-20210616224652-fc3ebd901c08
github.com/rancher/lasso v0.0.0-20210616224652-fc3ebd901c08
github.com/rancher/remotedialer v0.2.0
github.com/rancher/remotedialer v0.2.0
github.com/rancher/wharfie v0.3.4
github.com/rancher/wharfie v0.3.4
github.com/rancher/wrangler v0.8.
5
github.com/rancher/wrangler v0.8.
8
github.com/robfig/cron/v3 v3.0.1
github.com/robfig/cron/v3 v3.0.1
github.com/rootless-containers/rootlesskit v0.14.0
github.com/rootless-containers/rootlesskit v0.14.0
github.com/sirupsen/logrus v1.8.1
github.com/sirupsen/logrus v1.8.1
...
...
go.sum
View file @
67d079ec
...
@@ -822,8 +822,8 @@ github.com/rancher/wharfie v0.3.4 h1:wVqFW1cyRA20zY90Z56VrjG0lWg3oFmf/4ryr5Dkkis
...
@@ -822,8 +822,8 @@ github.com/rancher/wharfie v0.3.4 h1:wVqFW1cyRA20zY90Z56VrjG0lWg3oFmf/4ryr5Dkkis
github.com/rancher/wharfie v0.3.4/go.mod h1:cb8mSczpmw7ItbPF3K1W7crWuJLVdyV49sZZuaY4BS8=
github.com/rancher/wharfie v0.3.4/go.mod h1:cb8mSczpmw7ItbPF3K1W7crWuJLVdyV49sZZuaY4BS8=
github.com/rancher/wrangler v0.4.0/go.mod h1:1cR91WLhZgkZ+U4fV9nVuXqKurWbgXcIReU4wnQvTN8=
github.com/rancher/wrangler v0.4.0/go.mod h1:1cR91WLhZgkZ+U4fV9nVuXqKurWbgXcIReU4wnQvTN8=
github.com/rancher/wrangler v0.8.3/go.mod h1:dKEaHNB4izxmPUtpq1Hvr3z3Oh+9k5pCZyFO9sUhlaY=
github.com/rancher/wrangler v0.8.3/go.mod h1:dKEaHNB4izxmPUtpq1Hvr3z3Oh+9k5pCZyFO9sUhlaY=
github.com/rancher/wrangler v0.8.
5 h1:aHUVvJrOhD6CGrAELWKDpo1MBDC8vKtEQZvjMPnw2cs
=
github.com/rancher/wrangler v0.8.
8 h1:3EEQmfUqZ/UG4hERHhihB+Q2F1s/W4CmfsPmXv17wS8
=
github.com/rancher/wrangler v0.8.
5
/go.mod h1:dKEaHNB4izxmPUtpq1Hvr3z3Oh+9k5pCZyFO9sUhlaY=
github.com/rancher/wrangler v0.8.
8
/go.mod h1:dKEaHNB4izxmPUtpq1Hvr3z3Oh+9k5pCZyFO9sUhlaY=
github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M=
github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M=
github.com/robfig/cron v1.1.0 h1:jk4/Hud3TTdcrJgUOBgsqrZBarcxl6ADIjSC2iniwLY=
github.com/robfig/cron v1.1.0 h1:jk4/Hud3TTdcrJgUOBgsqrZBarcxl6ADIjSC2iniwLY=
github.com/robfig/cron v1.1.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k=
github.com/robfig/cron v1.1.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k=
...
...
pkg/agent/containerd/containerd.go
View file @
67d079ec
...
@@ -86,7 +86,7 @@ func Run(ctx context.Context, cfg *config.Node) error {
...
@@ -86,7 +86,7 @@ func Run(ctx context.Context, cfg *config.Node) error {
}
}
logrus
.
Infof
(
"Running containerd %s"
,
config
.
ArgString
(
args
[
1
:
]))
logrus
.
Infof
(
"Running containerd %s"
,
config
.
ArgString
(
args
[
1
:
]))
cmd
:=
exec
.
Command
(
args
[
0
],
args
[
1
:
]
...
)
cmd
:=
exec
.
Command
Context
(
ctx
,
args
[
0
],
args
[
1
:
]
...
)
cmd
.
Stdout
=
stdOut
cmd
.
Stdout
=
stdOut
cmd
.
Stderr
=
stdErr
cmd
.
Stderr
=
stdErr
cmd
.
Env
=
env
cmd
.
Env
=
env
...
...
pkg/cli/agent/agent.go
View file @
67d079ec
package
agent
package
agent
import
(
import
(
"context"
"fmt"
"fmt"
"os"
"os"
"runtime"
"runtime"
...
@@ -73,7 +72,7 @@ func Run(ctx *cli.Context) error {
...
@@ -73,7 +72,7 @@ func Run(ctx *cli.Context) error {
cfg
.
Debug
=
ctx
.
GlobalBool
(
"debug"
)
cfg
.
Debug
=
ctx
.
GlobalBool
(
"debug"
)
cfg
.
DataDir
=
dataDir
cfg
.
DataDir
=
dataDir
contextCtx
:=
signals
.
SetupSignal
Handler
(
context
.
Background
()
)
contextCtx
:=
signals
.
SetupSignal
Context
(
)
return
agent
.
Run
(
contextCtx
,
cfg
)
return
agent
.
Run
(
contextCtx
,
cfg
)
}
}
pkg/cli/etcdsnapshot/etcd_snapshot.go
View file @
67d079ec
package
etcdsnapshot
package
etcdsnapshot
import
(
import
(
"context"
"errors"
"errors"
"fmt"
"fmt"
"os"
"os"
...
@@ -82,7 +81,7 @@ func run(app *cli.Context, cfg *cmds.Server) error {
...
@@ -82,7 +81,7 @@ func run(app *cli.Context, cfg *cmds.Server) error {
serverConfig
.
ControlConfig
.
Runtime
.
ClientETCDKey
=
filepath
.
Join
(
dataDir
,
"tls"
,
"etcd"
,
"client.key"
)
serverConfig
.
ControlConfig
.
Runtime
.
ClientETCDKey
=
filepath
.
Join
(
dataDir
,
"tls"
,
"etcd"
,
"client.key"
)
serverConfig
.
ControlConfig
.
Runtime
.
KubeConfigAdmin
=
filepath
.
Join
(
dataDir
,
"cred"
,
"admin.kubeconfig"
)
serverConfig
.
ControlConfig
.
Runtime
.
KubeConfigAdmin
=
filepath
.
Join
(
dataDir
,
"cred"
,
"admin.kubeconfig"
)
ctx
:=
signals
.
SetupSignal
Handler
(
context
.
Background
()
)
ctx
:=
signals
.
SetupSignal
Context
(
)
e
:=
etcd
.
NewETCD
()
e
:=
etcd
.
NewETCD
()
e
.
SetControlConfig
(
&
serverConfig
.
ControlConfig
)
e
.
SetControlConfig
(
&
serverConfig
.
ControlConfig
)
...
@@ -132,7 +131,7 @@ func delete(app *cli.Context, cfg *cmds.Server) error {
...
@@ -132,7 +131,7 @@ func delete(app *cli.Context, cfg *cmds.Server) error {
serverConfig
.
ControlConfig
.
DataDir
=
dataDir
serverConfig
.
ControlConfig
.
DataDir
=
dataDir
serverConfig
.
ControlConfig
.
Runtime
.
KubeConfigAdmin
=
filepath
.
Join
(
dataDir
,
"cred"
,
"admin.kubeconfig"
)
serverConfig
.
ControlConfig
.
Runtime
.
KubeConfigAdmin
=
filepath
.
Join
(
dataDir
,
"cred"
,
"admin.kubeconfig"
)
ctx
:=
signals
.
SetupSignal
Handler
(
context
.
Background
()
)
ctx
:=
signals
.
SetupSignal
Context
(
)
e
:=
etcd
.
NewETCD
()
e
:=
etcd
.
NewETCD
()
e
.
SetControlConfig
(
&
serverConfig
.
ControlConfig
)
e
.
SetControlConfig
(
&
serverConfig
.
ControlConfig
)
...
@@ -162,7 +161,7 @@ func list(app *cli.Context, cfg *cmds.Server) error {
...
@@ -162,7 +161,7 @@ func list(app *cli.Context, cfg *cmds.Server) error {
serverConfig
.
ControlConfig
.
DataDir
=
dataDir
serverConfig
.
ControlConfig
.
DataDir
=
dataDir
ctx
:=
signals
.
SetupSignal
Handler
(
context
.
Background
()
)
ctx
:=
signals
.
SetupSignal
Context
(
)
e
:=
etcd
.
NewETCD
()
e
:=
etcd
.
NewETCD
()
e
.
SetControlConfig
(
&
serverConfig
.
ControlConfig
)
e
.
SetControlConfig
(
&
serverConfig
.
ControlConfig
)
...
@@ -203,7 +202,7 @@ func prune(app *cli.Context, cfg *cmds.Server) error {
...
@@ -203,7 +202,7 @@ func prune(app *cli.Context, cfg *cmds.Server) error {
serverConfig
.
ControlConfig
.
DataDir
=
dataDir
serverConfig
.
ControlConfig
.
DataDir
=
dataDir
serverConfig
.
ControlConfig
.
EtcdSnapshotRetention
=
cfg
.
EtcdSnapshotRetention
serverConfig
.
ControlConfig
.
EtcdSnapshotRetention
=
cfg
.
EtcdSnapshotRetention
ctx
:=
signals
.
SetupSignal
Handler
(
context
.
Background
()
)
ctx
:=
signals
.
SetupSignal
Context
(
)
e
:=
etcd
.
NewETCD
()
e
:=
etcd
.
NewETCD
()
e
.
SetControlConfig
(
&
serverConfig
.
ControlConfig
)
e
.
SetControlConfig
(
&
serverConfig
.
ControlConfig
)
...
...
pkg/cli/server/server.go
View file @
67d079ec
...
@@ -397,7 +397,7 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
...
@@ -397,7 +397,7 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
notifySocket
:=
os
.
Getenv
(
"NOTIFY_SOCKET"
)
notifySocket
:=
os
.
Getenv
(
"NOTIFY_SOCKET"
)
ctx
:=
signals
.
SetupSignal
Handler
(
context
.
Background
()
)
ctx
:=
signals
.
SetupSignal
Context
(
)
if
err
:=
server
.
StartServer
(
ctx
,
&
serverConfig
,
cfg
);
err
!=
nil
{
if
err
:=
server
.
StartServer
(
ctx
,
&
serverConfig
,
cfg
);
err
!=
nil
{
return
err
return
err
...
...
vendor/github.com/rancher/wrangler/pkg/apply/desiredset_apply.go
View file @
67d079ec
...
@@ -30,6 +30,7 @@ const (
...
@@ -30,6 +30,7 @@ const (
LabelNamespace
=
"objectset.rio.cattle.io/owner-namespace"
LabelNamespace
=
"objectset.rio.cattle.io/owner-namespace"
LabelHash
=
"objectset.rio.cattle.io/hash"
LabelHash
=
"objectset.rio.cattle.io/hash"
LabelPrefix
=
"objectset.rio.cattle.io/"
LabelPrefix
=
"objectset.rio.cattle.io/"
LabelPrune
=
"objectset.rio.cattle.io/prune"
)
)
var
(
var
(
...
...
vendor/github.com/rancher/wrangler/pkg/apply/desiredset_compare.go
View file @
67d079ec
...
@@ -207,8 +207,7 @@ func applyPatch(gvk schema.GroupVersionKind, reconciler Reconciler, patcher Patc
...
@@ -207,8 +207,7 @@ func applyPatch(gvk schema.GroupVersionKind, reconciler Reconciler, patcher Patc
return
false
,
nil
return
false
,
nil
}
}
logrus
.
Debugf
(
"DesiredSet - Patch %s %s/%s for %s -- [%s, %s, %s, %s]"
,
gvk
,
oldMetadata
.
GetNamespace
(),
oldMetadata
.
GetName
(),
debugID
,
patch
,
original
,
modified
,
current
)
logrus
.
Debugf
(
"DesiredSet - Patch %s %s/%s for %s -- [PATCH:%s, ORIGINAL:%s, MODIFIED:%s, CURRENT:%s]"
,
gvk
,
oldMetadata
.
GetNamespace
(),
oldMetadata
.
GetName
(),
debugID
,
patch
,
original
,
modified
,
current
)
if
reconciler
!=
nil
{
if
reconciler
!=
nil
{
newObject
,
err
:=
prepareObjectForCreate
(
gvk
,
newObject
)
newObject
,
err
:=
prepareObjectForCreate
(
gvk
,
newObject
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
vendor/github.com/rancher/wrangler/pkg/apply/desiredset_process.go
View file @
67d079ec
...
@@ -382,6 +382,14 @@ func (o *desiredSet) list(namespaced bool, informer cache.SharedIndexInformer, c
...
@@ -382,6 +382,14 @@ func (o *desiredSet) list(namespaced bool, informer cache.SharedIndexInformer, c
return
objs
,
merr
.
NewErrors
(
errs
...
)
return
objs
,
merr
.
NewErrors
(
errs
...
)
}
}
func
shouldPrune
(
obj
runtime
.
Object
)
bool
{
meta
,
err
:=
meta
.
Accessor
(
obj
)
if
err
!=
nil
{
return
true
}
return
meta
.
GetLabels
()[
LabelPrune
]
!=
"false"
}
func
compareSets
(
existingSet
,
newSet
map
[
objectset
.
ObjectKey
]
runtime
.
Object
)
(
toCreate
,
toDelete
,
toUpdate
[]
objectset
.
ObjectKey
)
{
func
compareSets
(
existingSet
,
newSet
map
[
objectset
.
ObjectKey
]
runtime
.
Object
)
(
toCreate
,
toDelete
,
toUpdate
[]
objectset
.
ObjectKey
)
{
for
k
:=
range
newSet
{
for
k
:=
range
newSet
{
if
_
,
ok
:=
existingSet
[
k
];
ok
{
if
_
,
ok
:=
existingSet
[
k
];
ok
{
...
@@ -391,9 +399,11 @@ func compareSets(existingSet, newSet map[objectset.ObjectKey]runtime.Object) (to
...
@@ -391,9 +399,11 @@ func compareSets(existingSet, newSet map[objectset.ObjectKey]runtime.Object) (to
}
}
}
}
for
k
:=
range
existingSet
{
for
k
,
obj
:=
range
existingSet
{
if
_
,
ok
:=
newSet
[
k
];
!
ok
{
if
_
,
ok
:=
newSet
[
k
];
!
ok
{
toDelete
=
append
(
toDelete
,
k
)
if
shouldPrune
(
obj
)
{
toDelete
=
append
(
toDelete
,
k
)
}
}
}
}
}
...
...
vendor/github.com/rancher/wrangler/pkg/signals/signal.go
View file @
67d079ec
/*
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
@@ -23,22 +20,47 @@ import (
...
@@ -23,22 +20,47 @@ import (
)
)
var
onlyOneSignalHandler
=
make
(
chan
struct
{})
var
onlyOneSignalHandler
=
make
(
chan
struct
{})
var
shutdownHandler
chan
os
.
Signal
// SetupSignalHandler registered for SIGTERM and SIGINT. A stop channel is returned
// SetupSignalHandler registered for SIGTERM and SIGINT. A stop channel is returned
// which is closed on one of these signals. If a second signal is caught, the program
// which is closed on one of these signals. If a second signal is caught, the program
// is terminated with exit code 1.
// is terminated with exit code 1.
func
SetupSignalHandler
(
parent
context
.
Context
)
context
.
Context
{
// Only one of SetupSignalContext and SetupSignalHandler should be called, and only can
// be called once.
func
SetupSignalHandler
()
<-
chan
struct
{}
{
return
SetupSignalContext
()
.
Done
()
}
// SetupSignalContext is same as SetupSignalHandler, but a context.Context is returned.
// Only one of SetupSignalContext and SetupSignalHandler should be called, and only can
// be called once.
func
SetupSignalContext
()
context
.
Context
{
close
(
onlyOneSignalHandler
)
// panics when called twice
close
(
onlyOneSignalHandler
)
// panics when called twice
ctx
,
cancel
:=
context
.
WithCancel
(
parent
)
c
:=
make
(
chan
os
.
Signal
,
2
)
shutdownHandler
=
make
(
chan
os
.
Signal
,
2
)
signal
.
Notify
(
c
,
shutdownSignals
...
)
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
signal
.
Notify
(
shutdownHandler
,
shutdownSignals
...
)
go
func
()
{
go
func
()
{
<-
c
<-
shutdownHandler
cancel
()
cancel
()
<-
c
<-
shutdownHandler
os
.
Exit
(
1
)
// second signal. Exit directly.
os
.
Exit
(
1
)
// second signal. Exit directly.
}()
}()
return
ctx
return
ctx
}
}
// RequestShutdown emulates a received event that is considered as shutdown signal (SIGTERM/SIGINT)
// This returns whether a handler was notified
func
RequestShutdown
()
bool
{
if
shutdownHandler
!=
nil
{
select
{
case
shutdownHandler
<-
shutdownSignals
[
0
]
:
return
true
default
:
}
}
return
false
}
\ No newline at end of file
vendor/modules.txt
View file @
67d079ec
...
@@ -954,7 +954,7 @@ github.com/rancher/remotedialer
...
@@ -954,7 +954,7 @@ github.com/rancher/remotedialer
# github.com/rancher/wharfie v0.3.4
# github.com/rancher/wharfie v0.3.4
## explicit
## explicit
github.com/rancher/wharfie/pkg/registries
github.com/rancher/wharfie/pkg/registries
# github.com/rancher/wrangler v0.8.
5
# github.com/rancher/wrangler v0.8.
8
## explicit
## explicit
github.com/rancher/wrangler/pkg/apply
github.com/rancher/wrangler/pkg/apply
github.com/rancher/wrangler/pkg/apply/injectors
github.com/rancher/wrangler/pkg/apply/injectors
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment