Skip to content

Commit e0ce823

Browse files
authored
Merge pull request #5787 from hpcng/master
Merge without-seccomp and detached build message for 3.7.1
2 parents f170875 + 55a4fbf commit e0ce823

File tree

8 files changed

+42
-17
lines changed

8 files changed

+42
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ _The old changelog can be found in the `release-2.6` branch_
2222
when using plugins.
2323
- Remove spurious warning in parseTokenSection()
2424
- e2e test fixes for new kernels, new unsquashfs version.
25+
- Show correct web URI for detached builds against alternate remotes.
2526

2627

2728
# v3.7.0 - [2020-11-24]

cmd/internal/cli/build.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ var buildArgs struct {
3333
builderURL string
3434
libraryURL string
3535
keyServerURL string
36+
webURL string
3637
detached bool
3738
encrypt bool
3839
fakeroot bool

cmd/internal/cli/build_darwin.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ func runBuild(cmd *cobra.Command, args []string) {
4040
buildArgs.libraryURL = lc.BaseURL
4141
buildArgs.builderURL = bc.BaseURL
4242

43+
// To provide a web link to detached remote builds we need to know the web frontend URI.
44+
// We only know this working forward from a remote config, and not if the user has set custom
45+
// service URLs, since there is no straightforward foolproof way to work back from them to a
46+
// matching frontend URL.
47+
if !cmd.Flag("builder").Changed && !cmd.Flag("library").Changed {
48+
buildArgs.webURL = URI()
49+
}
50+
4351
// Submiting a remote build requires a valid authToken
4452
if bc.AuthToken == "" {
4553
sylog.Fatalf("Unable to submit build job: %v", remoteWarning)
@@ -50,7 +58,7 @@ func runBuild(cmd *cobra.Command, args []string) {
5058
sylog.Fatalf("Unable to build from %s: %v", spec, err)
5159
}
5260

53-
b, err := remotebuilder.New(dest, buildArgs.libraryURL, def, buildArgs.detached, forceOverwrite, buildArgs.builderURL, bc.AuthToken, buildArgs.arch)
61+
b, err := remotebuilder.New(dest, buildArgs.libraryURL, def, buildArgs.detached, forceOverwrite, buildArgs.builderURL, bc.AuthToken, buildArgs.arch, buildArgs.webURL)
5462
if err != nil {
5563
sylog.Fatalf("Failed to create builder: %v", err)
5664
}

cmd/internal/cli/build_linux.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ func runBuildRemote(ctx context.Context, cmd *cobra.Command, dst, spec string) {
133133
buildArgs.libraryURL = lc.BaseURL
134134
buildArgs.builderURL = bc.BaseURL
135135

136+
// To provide a web link to detached remote builds we need to know the web frontend URI.
137+
// We only know this working forward from a remote config, and not if the user has set custom
138+
// service URLs, since there is no straightforward foolproof way to work back from them to a
139+
// matching frontend URL.
140+
if !cmd.Flag("builder").Changed && !cmd.Flag("library").Changed {
141+
buildArgs.webURL = URI()
142+
}
143+
136144
// submitting a remote build requires a valid authToken
137145
if bc.AuthToken == "" {
138146
sylog.Fatalf("Unable to submit build job: %v", remoteWarning)
@@ -202,7 +210,7 @@ func runBuildRemote(ctx context.Context, cmd *cobra.Command, dst, spec string) {
202210
}()
203211
}
204212

205-
b, err := remotebuilder.New(rbDst, buildArgs.libraryURL, def, buildArgs.detached, forceOverwrite, buildArgs.builderURL, bc.AuthToken, buildArgs.arch)
213+
b, err := remotebuilder.New(rbDst, buildArgs.libraryURL, def, buildArgs.detached, forceOverwrite, buildArgs.builderURL, bc.AuthToken, buildArgs.arch, buildArgs.webURL)
206214
if err != nil {
207215
sylog.Fatalf("Failed to create builder: %v", err)
208216
}

internal/pkg/build/remotebuilder/remotebuilder.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ import (
3131
useragent "github.com/sylabs/singularity/pkg/util/user-agent"
3232
)
3333

34-
// CloudURI holds the URI of the Library web front-end.
35-
const CloudURI = "https://cloud.sylabs.io"
36-
3734
// RemoteBuilder contains the build request and response
3835
type RemoteBuilder struct {
3936
BuildClient *buildclient.Client
@@ -45,10 +42,11 @@ type RemoteBuilder struct {
4542
Force bool
4643
IsDetached bool
4744
BuilderRequirements map[string]string
45+
WebURL string
4846
}
4947

5048
// New creates a RemoteBuilder with the specified details.
51-
func New(imagePath, libraryURL string, d types.Definition, isDetached, force bool, builderAddr, authToken, buildArch string) (rb *RemoteBuilder, err error) {
49+
func New(imagePath, libraryURL string, d types.Definition, isDetached, force bool, builderAddr, authToken, buildArch, webURL string) (rb *RemoteBuilder, err error) {
5250
bc, err := buildclient.New(&buildclient.Config{
5351
BaseURL: builderAddr,
5452
AuthToken: authToken,
@@ -73,6 +71,7 @@ func New(imagePath, libraryURL string, d types.Definition, isDetached, force boo
7371
BuilderRequirements: map[string]string{
7472
"arch": buildArch,
7573
},
74+
WebURL: webURL,
7675
}, nil
7776
}
7877

@@ -107,7 +106,9 @@ func (rb *RemoteBuilder) Build(ctx context.Context) (err error) {
107106
if rb.IsDetached {
108107
fmt.Printf("Build submitted! Once it is complete, the image can be retrieved by running:\n")
109108
fmt.Printf("\tsingularity pull --library %s library://%s\n\n", bi.LibraryURL, libraryRefRaw)
110-
fmt.Printf("Alternatively, you can access it from a browser at:\n\t%s/library/%s\n", CloudURI, libraryRefRaw)
109+
if rb.WebURL != "" {
110+
fmt.Printf("Alternatively, you can access it from a browser at:\n\t%s/library/%s\n", rb.WebURL, libraryRefRaw)
111+
}
111112
return nil
112113
}
113114

internal/pkg/build/remotebuilder/remotebuilder_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestBuild(t *testing.T) {
3939
// Loop over test cases
4040
for _, tt := range tests {
4141
t.Run(tt.description, test.WithoutPrivilege(func(t *testing.T) {
42-
_, err := New("", "", types.Definition{}, false, false, tt.builderAddr, "", runtime.GOARCH)
42+
_, err := New("", "", types.Definition{}, false, false, tt.builderAddr, "", runtime.GOARCH, "")
4343
if tt.expectSuccess {
4444
// Ensure the handler returned no error, and the response is as expected
4545
if err != nil {

mconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ fi
5757

5858
with_network=1
5959
with_suid=1
60+
with_seccomp_check=1
6061

6162
prefix=
6263
exec_prefix=
@@ -111,6 +112,7 @@ usage_args () {
111112
echo " Singularity options:"
112113
echo " --without-suid do not install SUID binary (linux only)"
113114
echo " --without-network do not compile/install network plugins (linux only)"
115+
echo " --without-seccomp do not compile/install seccomp support even if available"
114116
echo
115117
echo " Path modification options:"
116118
echo " --prefix install project in \`prefix'"
@@ -361,6 +363,8 @@ while [ $# -ne 0 ]; do
361363
with_suid=0; shift;;
362364
--without-network)
363365
with_network=0; shift;;
366+
--without-seccomp)
367+
with_seccomp_check=0; shift;;
364368
-V)
365369
if ! echo "$2" | awk '/^-.*/ || /^$/ { exit 2 }'; then
366370
echo "error: option requires an argument: $1"

mlocal/checks/project-post.chk

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -303,15 +303,17 @@ fi
303303
########################
304304
# libseccomp dev
305305
########################
306-
printf " checking: libseccomp+headers... "
307-
seccomp_iflags=`pkg-config --cflags-only-I libseccomp 2>/dev/null || true`
308-
if ! printf "#include <seccomp.h>\nint main() { seccomp_syscall_resolve_name(\"read\"); }" | \
309-
$tgtcc $user_cflags $ldflags $seccomp_iflags -x c -o /dev/null - -lseccomp >/dev/null 2>&1; then
310-
tgtstatic=0
311-
echo "no"
312-
else
313-
echo "yes"
314-
appsec=1
306+
if [ "$with_seccomp_check" = "1" ];then
307+
printf " checking: libseccomp+headers... "
308+
seccomp_iflags=`pkg-config --cflags-only-I libseccomp 2>/dev/null || true`
309+
if ! printf "#include <seccomp.h>\nint main() { seccomp_syscall_resolve_name(\"read\"); }" | \
310+
$tgtcc $user_cflags $ldflags $seccomp_iflags -x c -o /dev/null - -lseccomp >/dev/null 2>&1; then
311+
tgtstatic=0
312+
echo "no"
313+
else
314+
echo "yes"
315+
appsec=1
316+
fi
315317
fi
316318

317319
########################

0 commit comments

Comments
 (0)